From 37c315988c2dc11e4f477233f7a9f87d57bb61aa Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期一, 08 三月 2021 09:17:15 +0800 Subject: [PATCH] 数据结构优化修改 --- HDL_ON/Entity/Function/FloorHeating.cs | 372 +++++++++++++++++++--------------------------------- 1 files changed, 138 insertions(+), 234 deletions(-) diff --git a/HDL_ON/Entity/Function/FloorHeating.cs b/HDL_ON/Entity/Function/FloorHeating.cs index aefe030..02aaffd 100644 --- a/HDL_ON/Entity/Function/FloorHeating.cs +++ b/HDL_ON/Entity/Function/FloorHeating.cs @@ -3,155 +3,144 @@ namespace HDL_ON.Entity { - public class FloorHeating : Function + public class FloorHeating { - /* - *鍦扮儹锛歵rait: [switch, mode, set_temp, lock] - *灞炴�� 鎻忚堪 - *switch on/off - *mode day, night,away, vacation, timer - *set_temp value - *lock boolean(Lock閿佸畾鎺у埗) - *set_ point up,down,value - */ - 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 tempUnitString + public int GetWorkModeIndex(Function function) { - get - { - if (curTempType == 0) - { - return "掳C"; - } - else - { - return "掳F"; - } - } - } - FunctionAttributes _trait_mode; - /// <summary> - /// 妯″紡灞炴�� - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public FunctionAttributes trait_mode - { - get - { - if (_trait_mode == null) - { - _trait_mode = attributes.Find((obj) => obj.key == "mode"); - //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂�� - if (_trait_mode == null) - { - _trait_mode = new FunctionAttributes() - { - key = "mode", - value = new List<string> { "day", "night", "away", "normal", "timer" }, - max = 4, - min = 0, - }; - } - if(_trait_mode.curValue.ToString() == "{}") - { - _trait_mode.curValue = "day"; - } - } - return _trait_mode; - } + var attr = function.GetAttrState(FunctionAttributeKey.WorkMode); + if (attr == "cool") + return 1; + return 0; } /// <summary> - /// 宸ヤ綔妯″紡瀵瑰簲鐨勫伐浣滄俯搴� + /// 璁剧疆bus鍗忚宸ヤ綔妯″紡index + /// 0:鍦扮儹妯″紡锛�1:鍦板喎妯″紡锛� + /// 2:鍦扮儹鍔熺巼妯″紡锛�3:鍦板喎鍔熺巼妯″紡锛� /// </summary> - [Newtonsoft.Json.JsonIgnore] - public Dictionary<string, byte> modeTemp = new Dictionary<string, byte>(); + public void SetWorkModeIndex(Function function, int index) + { + if (index == 1) + function.SetAttrState(FunctionAttributeKey.WorkMode, "cool"); + else + function.SetAttrState(FunctionAttributeKey.WorkMode, "heat"); + } /// <summary> - /// 褰撳墠妯″紡绱㈠紩 - /// bus鎺у埗鍛戒护浣跨敤 + /// 鑾峰彇娓╁害妯″紡瀛楃 /// </summary> - [Newtonsoft.Json.JsonIgnore] - public byte curModeIndex + public string GetTempUnitString(Function function) { - get + var tt = function.GetAttrState(FunctionAttributeKey.TempType); + if (tt == "0") { - try - { - byte index = 0; - switch (trait_mode.curValue.ToString()) - { - 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; - } - catch (Exception ex) - { - MainPage.Log($"get curModeIndex error : {ex.Message}"); - return 0; - } + return "掳C"; } - set + else { - switch (value) - { - case 5: - trait_mode.curValue = "timer"; - break; - case 1: - trait_mode.curValue = "normal"; - break; - case 2: - trait_mode.curValue = "day"; - break; - case 3: - trait_mode.curValue = "night"; - break; - case 4: - trait_mode.curValue = "away"; - break; - default: - trait_mode.curValue = "cool"; - break; + return tt; + } + } - } + + + /// <summary> + /// 鑾峰彇bus鍗忚妯″紡绱㈠紩 + /// </summary> + public byte GetModeIndex(Function function) + { + byte index = 0; + var mode = function.GetAttrState(FunctionAttributeKey.Mode); + switch (mode) + { + 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> @@ -160,120 +149,35 @@ /// </summary> public byte timeFlag = 0; - FunctionAttributes _trait_IndoorTemp; /// <summary> - /// 瀹ゅ唴娓╁害 + /// 鑾峰彇妯″紡鐨刬con璺緞 /// </summary> - [Newtonsoft.Json.JsonIgnore] - public FunctionAttributes trait_IndoorTemp + public string GetModeImage(Function function) { - get + var imagePath = "FunctionIcon/AC/HeatingIcon.png"; + var key = function.GetAttrState(FunctionAttributeKey.Mode); + switch (key) { - if (_trait_IndoorTemp == null) - { - _trait_IndoorTemp = attributes.Find((obj) => obj.key == FunctionAttributeKey.IndoorTemp); - //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂�� - if (_trait_IndoorTemp == null) - { - _trait_IndoorTemp = new FunctionAttributes() - { - key = FunctionAttributeKey.IndoorTemp, - value = new List<string> { }, - max = 30, - min = 0, - }; - - } - } - if (_trait_IndoorTemp.curValue.ToString() == "{}") - { - _trait_IndoorTemp.curValue = "0"; - } - var vv = Convert.ToDouble(_trait_IndoorTemp.curValue); - _trait_IndoorTemp.curValue = Convert.ToInt32(vv).ToString(); - return _trait_IndoorTemp; + 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 "normal": + imagePath = "FunctionIcon/FloorHeating/OrdinaryIcon.png"; + break; + default: + imagePath = "FunctionIcon/AC/HeatingIcon.png"; + break; } + return imagePath; } - - - FunctionAttributes _trait_temp; - /// <summary> - /// 褰撳墠娓╁害 - /// </summary>/// <summary> - /// 褰撳墠绌鸿皟娓╁害 - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public FunctionAttributes trait_temp - { - get - { - if (_trait_temp == null) - { - _trait_temp = attributes.Find((obj) => obj.key == "set_temp"); - //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂�� - if (_trait_temp == null) - { - _trait_temp = new FunctionAttributes() - { - key = "set_temp", - value = new List<string> { }, - max = 30, - min = 5, - }; - } - if(_trait_temp.curValue.ToString() == "{}") - _trait_temp.curValue = "16"; - } - //if (_trait_temp.curValue.ToString().Length > 3) - { - double vv = 0; - Double.TryParse(_trait_temp.curValue.ToString(),out vv); - _trait_temp.curValue = Convert.ToInt32(vv).ToString(); - } - return _trait_temp; - } - } - /// <summary> - /// 褰撳墠妯″紡鐨刬con璺緞 - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public string curModeImage - { - get - { - try - { - var imagePath = "FunctionIcon/AC/HeatingIcon.png"; - switch (trait_mode.curValue) - { - 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 "normal": - 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"; - } - } - } - } } -- Gitblit v1.8.0