using System; using System.Collections.Generic; namespace HDL_ON.Entity { public class FloorHeating : Function { /* *地热:trait: [switch, mode, temperature, lock] *属性 描述 *switch on/off *mode day, night,away, vacation, timer *temperature up,down,value *lock boolean(Lock锁定控制) */ public FloorHeating() { } /// /// 当前温度模式 /// 0:摄氏度 /// 1:华氏度 /// [Newtonsoft.Json.JsonIgnore] public int curTempType = 0; /// /// 工作模式 /// 0:地热模式;1:地冷模式; /// 2:地热功率模式;3:地冷功率模式; /// public int workMode = 0; /// /// 当前温度模式字符 /// public string curTempTypeString { get { if (curTempType == 0) { return "°C"; } else { return "°F"; } } } /// /// 当前模式 /// [Newtonsoft.Json.JsonIgnore] public string curMode = "day"; /// /// 工作模式对应的工作温度 /// public Dictionary modeTemp = new Dictionary(); /// /// 当前模式索引 /// bus控制命令使用 /// public byte curModeIndex { get { try { byte index = 0; switch (curMode) { case "day": index = 2; break; case "night": index = 3; break; case "away": index = 4; break; case "ordinary": index = 1; break; case "timer": index = 5; break; default: index = 0; break; } return index; } catch (Exception ex) { MainPage.Log($"get curModeIndex error : {ex.Message}"); return 0; } } set { switch (value) { case 5: curMode = "timer"; break; case 1: curMode = "ordinary"; break; case 2: curMode = "day"; break; case 3: curMode = "night"; break; case 4: curMode = "away"; break; default: curMode = "cool"; break; } } } [Newtonsoft.Json.JsonIgnore] public Trait trait_mode; /// /// 模式列表 /// [Newtonsoft.Json.JsonIgnore] public List modeList { get { try { if (trait_mode == null) { trait_mode = function.Find((obj) => obj.attri == "mode"); //找不到属性需要声明一个,防止报错闪退 if (trait_mode == null) { trait_mode = new Trait() { attri = "mode", value = new List { "day", "night", "away", "timer", "ordinary" }, max = 4, min = 0, }; } trait_mode.curValues = trait_mode.value[trait_mode.min]; } return trait_mode.value; } catch (Exception ex) { MainPage.Log($"ac get mode error : {ex.Message}"); return new List { "day", "night", "away", "timer", "ordinary" }; } } } /// /// 时间标记 /// 0:白天;1:夜晚 /// public byte timeFlag = 0; /// /// 室内温度 /// [Newtonsoft.Json.JsonIgnore] public int indoorTemp = 20; /// /// 当前温度 /// [Newtonsoft.Json.JsonIgnore] public int curTemp { get { switch (curMode) { case "day": if (!modeTemp.ContainsKey("day")) { modeTemp.Add("day", 20); } return modeTemp["day"]; case "night": if (!modeTemp.ContainsKey("night")) { modeTemp.Add("night", 20); } return modeTemp["night"]; case "away": if (!modeTemp.ContainsKey("away")) { modeTemp.Add("away", 20); } return modeTemp["away"]; case "ordinary": if (!modeTemp.ContainsKey("ordinary")) { modeTemp.Add("ordinary", 20); } return modeTemp["ordinary"]; case "timer": if (timeFlag == 0) { if (!modeTemp.ContainsKey("day")) { modeTemp.Add("day", 20); } return modeTemp["day"]; } else { if (!modeTemp.ContainsKey("night")) { modeTemp.Add("night", 20); } return modeTemp["night"]; } } return 20; } set { switch (curMode) { case "day": if (!modeTemp.ContainsKey("day")) { modeTemp.Add("day", (byte)value); } else { modeTemp["day"] = (byte)value; } return; case "night": if (!modeTemp.ContainsKey("night")) { modeTemp.Add("night", (byte)value); } else { modeTemp["night"] = (byte)value; } break; case "away": if (!modeTemp.ContainsKey("away")) { modeTemp.Add("away", (byte)value); } else { modeTemp["away"] = (byte)value; } break; case "ordinary": if (!modeTemp.ContainsKey("ordinary")) { modeTemp.Add("ordinary", (byte)value); } else { modeTemp["ordinary"] = (byte)value; } break; case "timer": if (timeFlag == 0) { if (!modeTemp.ContainsKey("day")) { modeTemp.Add("day", (byte)value); } else { modeTemp["day"] = (byte)value; } } else { if (!modeTemp.ContainsKey("night")) { modeTemp.Add("night", (byte)value); } else { modeTemp["night"] = (byte)value; } } break; } } } /// /// 当前模式的icon路径 /// [Newtonsoft.Json.JsonIgnore] public string curModeImage { get { try { var imagePath = "FunctionIcon/AC/HeatingIcon.png"; switch (curMode) { case "day": imagePath = "FunctionIcon/AC/HeatingIcon.png"; break; case "night": imagePath = "FunctionIcon/FloorHeating/NightIcon.png"; break; case "away": imagePath = "FunctionIcon/FloorHeating/AwayIcon.png"; break; case "timer": imagePath = "FunctionIcon/AC/AutoIcon.png"; break; case "ordinary": imagePath = "FunctionIcon/FloorHeating/OrdinaryIcon.png"; break; default: imagePath = "FunctionIcon/AC/HeatingIcon.png"; break; } return imagePath; } catch (Exception ex) { MainPage.Log($"ac ge curModeImage error : {ex.Message}"); return "FunctionIcon/AC/CoolIcon.png"; } } } } }