From d07d62be7111d78b2aaa44c9cdee23a7d22b4dda Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期二, 22 十二月 2020 10:38:15 +0800 Subject: [PATCH] 20201222-1 --- HDL_ON/Entity/Function/Function.cs | 73 ++++++++++++++++++++++++++++-------- 1 files changed, 57 insertions(+), 16 deletions(-) diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs index d6d1e9b..da3c490 100644 --- a/HDL_ON/Entity/Function/Function.cs +++ b/HDL_ON/Entity/Function/Function.cs @@ -119,7 +119,7 @@ /// bus鍗忚鏁版嵁鏍煎紡 /// 浣跨敤A鍗忚鎺у埗鏃讹紝鏀瑰睘鎬т负绌� /// </summary> - public BusData bus_Data; + public BusData bus; /// <summary> /// 鏄惁鏀惰棌 /// </summary> @@ -162,7 +162,7 @@ { if (_trait_on_off == null) { - _trait_on_off = attributes.Find((obj) => obj.key == "on_off"); + _trait_on_off = attributes.Find((obj) => obj.key == FunctionAttributeKey.OnOff); //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂�� if (_trait_on_off == null) { @@ -173,8 +173,12 @@ max = 1, min = 0, }; + _trait_on_off.curValue = "off"; } - _trait_on_off.curValue = "on"; + } + if(_trait_on_off.curValue.ToString() != "on"&& _trait_on_off.curValue.ToString() != "off") + { + _trait_on_off.curValue = "off"; } return _trait_on_off; } @@ -206,9 +210,9 @@ public string GetBusId() { string busId = ""; - if (bus_Data != null) + if (bus != null) { - busId = bus_Data.SubnetID + "_" + bus_Data.DeviceID + "_" + bus_Data.loopId; + busId = bus.SubnetID + "_" + bus.DeviceID + "_" + bus.LoopId; } return busId; } @@ -231,11 +235,11 @@ { roomNameList += ","; } - roomNameList += findRoom.floorName + findRoom.roomName; + roomNameList += findRoom.floorName +"-"+ findRoom.roomName; } if (roomNameList == "" && functionType == FunctionType.Scene) { - roomNameList = Language.StringByID(StringId.WholeHouseScene); + roomNameList = Language.StringByID(StringId.WholeZone); } return roomNameList; } @@ -286,14 +290,37 @@ var sFunc = new SceneFunction(); foreach (var attr in attributes) { - if (attr.key == FunctionAttributeKey.SetTemp) + switch (attr.key) { - var vv = Convert.ToDouble(attr.value); - sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = Convert.ToInt32(vv).ToString() }); - } - else - { - sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = attr.curValue.ToString() }); + case FunctionAttributeKey.OnOff: + case FunctionAttributeKey.Brightness: + case FunctionAttributeKey.Mode: + case FunctionAttributeKey.SetTemp: + case FunctionAttributeKey.FanSpeed: + case FunctionAttributeKey.Percent: + //case FunctionAttributeKey.FadeTime: + if (attr.curValue.ToString() == "{}") + { + if (attr.key == FunctionAttributeKey.OnOff) + { + attr.curValue = "off"; + } + else + { + attr.curValue = "0"; + } + } + if (attr.key == FunctionAttributeKey.SetTemp) + { + double vv = 16; + Double.TryParse(attr.curValue.ToString(), out vv); + sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = Convert.ToInt32(vv).ToString() }); + } + else + { + sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = attr.curValue.ToString() }); + } + break; } } sFunc.sid = this.sid; @@ -317,9 +344,9 @@ var acd = new AlinkControlData(); acd.sid = sid; - var aca = new AlinkControlAttributes(); foreach (var dic in commandDictionary) { + var aca = new AlinkControlAttributes(); aca.key = dic.Key; aca.value = dic.Value; acd.status.Add(aca); @@ -338,6 +365,7 @@ ApiAlinkControlActionObj aaao = new ApiAlinkControlActionObj(); aaao.deviceId = this.deviceId; aaao.spk = this.spk; + aaao.bus = this.bus; foreach (var kv in keyValues) { aaao.attributes.Add(new AlinkControlAttributes() @@ -420,6 +448,7 @@ /// 鍔熻兘灞炴�� /// 灞炴�у瓧娈佃В鏋愶細attri :灞炴�у唴瀹癸紝value 灞炴�х殑鍊硷紝max 鏈�澶у�� min 鏈�灏忓�� /// </summary> + [System.Serializable] public class FunctionAttributes { /// <summary> @@ -497,6 +526,10 @@ /// 瀹ゅ唴娓╁害 /// </summary> public const string IndoorTemp = "room_temp"; + /// <summary> + /// value + /// </summary> + public const string Value = "value"; } /// <summary> /// 璁惧鍔熻兘oid @@ -533,7 +566,15 @@ return Convert.ToByte(addresses.Substring(2, 2), 16); } } - public byte loopId; + public byte LoopId + { + get + { + return Convert.ToByte(loopId, 16); + } + } + + public string loopId; } public static class SPK -- Gitblit v1.8.0