| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using Shared; |
| | | |
| | | namespace HDL_ON.Entity |
| | | { |
| | | public class FloorHeating : Function |
| | | public class FloorHeating |
| | | { |
| | | /* |
| | | *地热:trait: [switch, mode, temperature, lock] |
| | | *属性 描述
|
| | | *switch on/off
|
| | | *mode day, night,away, vacation, timer
|
| | | *temperature up,down,value
|
| | | *lock boolean(Lock锁定控制) |
| | | */ |
| | | public FloorHeating() |
| | | /// <summary> |
| | | /// 获取温度单位bus标识 |
| | | /// </summary> |
| | | /// <param name="function"></param> |
| | | /// <returns></returns> |
| | | public int GetTempUintIndex(Function function) |
| | | { |
| | | var tt = function.GetAttrState(FunctionAttributeKey.TempType); |
| | | if (tt == "°F") |
| | | { |
| | | return 1; |
| | | } |
| | | else |
| | | { |
| | | return 0; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 当前温度模式 |
| | | /// 0:摄氏度 |
| | | /// 1:华氏度 |
| | | /// 根据bus标识设置温度单位 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public int curTempType = 0; |
| | | /// <param name="function"></param> |
| | | /// <returns></returns> |
| | | public void SetTempUint(Function function, int index) |
| | | { |
| | | if (index == 0) |
| | | { |
| | | function.SetAttrState(FunctionAttributeKey.TempType, "°C"); |
| | | } |
| | | else |
| | | { |
| | | function.SetAttrState(FunctionAttributeKey.TempType, "°F"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 工作模式 |
| | | /// 获取bus协议工作模式index |
| | | /// 0:地热模式;1:地冷模式; |
| | | /// 2:地热功率模式;3:地冷功率模式; |
| | | /// </summary> |
| | | public int workMode = 0; |
| | | /// <summary> |
| | | /// 当前温度模式字符 |
| | | /// </summary> |
| | | public string curTempTypeString |
| | | public int GetWorkModeIndex(Function function) |
| | | { |
| | | get |
| | | { |
| | | if (curTempType == 0) |
| | | { |
| | | return "°C"; |
| | | } |
| | | else |
| | | { |
| | | return "°F"; |
| | | } |
| | | } |
| | | var attr = function.GetAttrState(FunctionAttributeKey.WorkMode); |
| | | if (attr == "cool") |
| | | return 1; |
| | | return 0; |
| | | } |
| | | /// <summary> |
| | | /// 当前模式 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string curMode = "day"; |
| | | /// <summary> |
| | | /// 工作模式对应的工作温度 |
| | | /// </summary> |
| | | public Dictionary<string, byte> modeTemp = new Dictionary<string, byte>(); |
| | | |
| | | /// <summary> |
| | | /// 当前模式索引 |
| | | /// bus控制命令使用 |
| | | /// 设置bus协议工作模式index |
| | | /// 0:地热模式;1:地冷模式; |
| | | /// 2:地热功率模式;3:地冷功率模式; |
| | | /// </summary> |
| | | public byte curModeIndex |
| | | public void SetWorkModeIndex(Function function, int index) |
| | | { |
| | | 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; |
| | | if (index == 1) |
| | | function.SetAttrState(FunctionAttributeKey.WorkMode, "cool"); |
| | | else |
| | | function.SetAttrState(FunctionAttributeKey.WorkMode, "heat"); |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 获取温度模式字符 |
| | | /// </summary> |
| | | public string GetTempUnitString(Function function) |
| | | { |
| | | var tt = function.GetAttrState(FunctionAttributeKey.TempType); |
| | | if (tt == "0") |
| | | { |
| | | return "°C"; |
| | | } |
| | | else |
| | | { |
| | | return tt; |
| | | } |
| | | } |
| | | |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public Trait trait_mode; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 模式列表 |
| | | /// 获取bus协议模式索引 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public List<string> modeList |
| | | public byte GetModeIndex(Function function) |
| | | { |
| | | get |
| | | byte index = 0; |
| | | var mode = function.GetAttrState(FunctionAttributeKey.Mode); |
| | | switch (mode) |
| | | { |
| | | 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<string> { "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<string> { "day", "night", "away", "timer", "ordinary" }; |
| | | } |
| | | case "day": |
| | | index = 2; |
| | | break; |
| | | case "night": |
| | | index = 3; |
| | | break; |
| | | case "away": |
| | | index = 4; |
| | | break; |
| | | case "normal": |
| | | index = 1; |
| | | break; |
| | | case "timer": |
| | | index = 5; |
| | | break; |
| | | default: |
| | | index = 0; |
| | | break; |
| | | } |
| | | return index; |
| | | } |
| | | /// <summary> |
| | | /// 设置bus协议模式索引 |
| | | /// </summary> |
| | | public void SetModeIndex(int value, Function function) |
| | | { |
| | | string mode = "timer"; |
| | | switch (value) |
| | | { |
| | | case 5: |
| | | mode = "timer"; |
| | | break; |
| | | case 1: |
| | | mode = "normal"; |
| | | break; |
| | | case 2: |
| | | mode = "day"; |
| | | break; |
| | | case 3: |
| | | mode = "night"; |
| | | break; |
| | | case 4: |
| | | mode = "away"; |
| | | break; |
| | | default: |
| | | mode = "cool"; |
| | | break; |
| | | } |
| | | function.SetAttrState(FunctionAttributeKey.Mode, mode); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | public byte timeFlag = 0; |
| | | |
| | | /// <summary> |
| | | /// 室内温度 |
| | | /// 获取模式的icon路径 |
| | | /// <param name="lightingIcon">获取的图标类型,默认是点亮</param> |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public int indoorTemp = 20; |
| | | /// <summary> |
| | | /// 当前温度 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public int curTemp |
| | | public string GetModeIconPath(string modeValue, bool lighting = true) |
| | | { |
| | | get |
| | | var imagePath = "FunctionIcon/AC/HeatingIcon.png"; |
| | | //var key = function.GetAttrState(FunctionAttributeKey.Mode); |
| | | if (lighting) |
| | | { |
| | | switch (curMode) |
| | | switch (modeValue) |
| | | { |
| | | case "day": |
| | | if (!modeTemp.ContainsKey("day")) |
| | | { |
| | | modeTemp.Add("day", 20); |
| | | } |
| | | return modeTemp["day"]; |
| | | imagePath = "FunctionIcon/AC/HeatingIcon.png"; |
| | | break; |
| | | case "night": |
| | | if (!modeTemp.ContainsKey("night")) |
| | | { |
| | | modeTemp.Add("night", 20); |
| | | } |
| | | return modeTemp["night"]; |
| | | imagePath = "FunctionIcon/FloorHeating/NightIcon.png"; |
| | | break; |
| | | 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"]; |
| | | imagePath = "FunctionIcon/FloorHeating/AwayIcon.png"; |
| | | break; |
| | | 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"]; |
| | | } |
| | | imagePath = "FunctionIcon/AC/AutoIcon.png"; |
| | | break; |
| | | case "normal": |
| | | imagePath = "FunctionIcon/FloorHeating/OrdinaryIcon.png"; |
| | | break; |
| | | default: |
| | | imagePath = "FunctionIcon/AC/HeatingIcon.png"; |
| | | break; |
| | | } |
| | | return 20; |
| | | } |
| | | set |
| | | else |
| | | { |
| | | switch (curMode) |
| | | switch (modeValue) |
| | | { |
| | | case "day": |
| | | if (!modeTemp.ContainsKey("day")) |
| | | { |
| | | modeTemp.Add("day", (byte)value); |
| | | } |
| | | else |
| | | { |
| | | modeTemp["day"] = (byte)value; |
| | | } |
| | | return; |
| | | imagePath = "FunctionIcon/AC/HeatingIconGray.png"; |
| | | break; |
| | | case "night": |
| | | if (!modeTemp.ContainsKey("night")) |
| | | { |
| | | modeTemp.Add("night", (byte)value); |
| | | } |
| | | else |
| | | { |
| | | modeTemp["night"] = (byte)value; |
| | | } |
| | | imagePath = "FunctionIcon/FloorHeating/NightIconGray.png"; |
| | | 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; |
| | | } |
| | | imagePath = "FunctionIcon/FloorHeating/AwayIconGray.png"; |
| | | 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; |
| | | } |
| | | } |
| | | imagePath = "FunctionIcon/AC/AutoIconGray.png"; |
| | | break; |
| | | case "normal": |
| | | imagePath = "FunctionIcon/FloorHeating/OrdinaryIconGray.png"; |
| | | break; |
| | | } |
| | | } |
| | | return imagePath; |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 当前模式的icon路径 |
| | | /// 获取模式属性文本 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string curModeImage |
| | | /// <returns></returns> |
| | | public string GetModeAttrText(string value) |
| | | { |
| | | get |
| | | string text = ""; |
| | | switch (value) |
| | | { |
| | | 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"; |
| | | } |
| | | case "day": |
| | | text = Language.StringByID(StringId.Day); |
| | | break; |
| | | case "night": |
| | | text = Language.StringByID(StringId.Night); |
| | | break; |
| | | case "away": |
| | | text = Language.StringByID(StringId.Away); |
| | | break; |
| | | case "timer": |
| | | text = Language.StringByID(StringId.Auto); |
| | | break; |
| | | case "normal": |
| | | text = Language.StringByID(StringId.Normal); |
| | | break; |
| | | } |
| | | return text; |
| | | } |
| | | |
| | | } |
| | | } |