From ed3bfb7462d44747230437717e8673a5192f833f Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期一, 30 十一月 2020 20:34:51 +0800 Subject: [PATCH] 2020-11-30-2 --- HDL_ON/Entity/Function/Function.cs | 92 +++++++++++++++++++++++---------------------- 1 files changed, 47 insertions(+), 45 deletions(-) diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs index be61b11..b988436 100644 --- a/HDL_ON/Entity/Function/Function.cs +++ b/HDL_ON/Entity/Function/Function.cs @@ -1,6 +1,5 @@ 锘縰sing System; using System.Collections.Generic; -using HDL_ON.DriverLayer; using Shared; namespace HDL_ON.Entity @@ -55,7 +54,7 @@ /// 濡傦細鏄疉C鍔熻兘锛氱壒鎬э細on_off,mode,fan,temperature /// attri /// </summary> - public List<FunctionAttributes> function = new List<FunctionAttributes>(); + public List<Trait> function = new List<Trait>(); /// <summary> /// 鎴块棿ID鍒楄〃 @@ -146,27 +145,27 @@ [Newtonsoft.Json.JsonIgnore] public string lastState = ""; - FunctionAttributes _trait_on_off; + Trait _trait_on_off; [Newtonsoft.Json.JsonIgnore] - public FunctionAttributes trait_on_off + public Trait trait_on_off { get { if (_trait_on_off == null) { - _trait_on_off = function.Find((obj) => obj.key == "on_off"); + _trait_on_off = function.Find((obj) => obj.name == "on_off"); //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂�� if (_trait_on_off == null) { - _trait_on_off = new FunctionAttributes() + _trait_on_off = new Trait() { - key = "on_off", - value = new List<string> { "on", "off" }, + name = "on_off", + value_key = new List<string> { "on", "off" }, max = 1, min = 0, }; } - _trait_on_off.curValue = "on"; + _trait_on_off.value = "on"; } return _trait_on_off; } @@ -256,24 +255,24 @@ public AprotocolControlObj GetControlSendData(Dictionary<string, string> commandDictionary) { var sendDataObj = new AprotocolControlObj(); - sendDataObj.id = Control.Ins.msg_id.ToString(); - sendDataObj.time_stamp = Control.Ins.Get_TimeStamp(); + sendDataObj.from_oid = ""; + sendDataObj.to_oid = ""; + sendDataObj.time_stamp = ""; + sendDataObj.type = "device_sid"; + sendDataObj.command = "write"; - - var acd = new AprotocolControlData(); - acd.sid = sid; -#if DEBUG - acd.sid = "0001016FB925AB02020100010101"; -#endif - var aca = new AprotocolControlAttribute(); + var acoList = new AprotocolControlData(); + acoList.sid = sid; + var aco = new AprotocolControlAttribute(); foreach(var dic in commandDictionary) { - aca.key = dic.Key; - aca.value = dic.Value; - acd.status.Add(aca); + aco.name = dic.Key; + aco.value = dic.Value; + acoList.function.Add(aco); } - sendDataObj.objects.Add(acd); + sendDataObj.objects.Add(acoList); + return sendDataObj; } @@ -286,8 +285,11 @@ { public List<AprotocolControlData> objects = new List<AprotocolControlData>(); + public string from_oid = ""; + public string to_oid = ""; public string time_stamp = ""; - public string id = ""; + public string type = ""; + public string command = ""; } /// <summary> /// A鍗忚鎺у埗鏁版嵁 @@ -296,14 +298,14 @@ { public string sid = ""; - public List<AprotocolControlAttribute> status = new List<AprotocolControlAttribute>(); + public List<AprotocolControlAttribute> function = new List<AprotocolControlAttribute>(); } /// <summary> /// A鍗忚鎺у埗灞炴�у璞� /// </summary> public class AprotocolControlAttribute { - public string key; + public string name; public string value; } @@ -311,16 +313,16 @@ /// 鍔熻兘灞炴�� /// 灞炴�у瓧娈佃В鏋愶細attri :灞炴�у唴瀹癸紝value 灞炴�х殑鍊硷紝max 鏈�澶у�� min 鏈�灏忓�� /// </summary> - public class FunctionAttributes + public class Trait { /// <summary> - /// 灞炴�ч敭鍚� + /// 灞炴�у悕绉� /// </summary> - public string key; + public string name; /// <summary> /// 灞炴�х殑鍊煎垪琛� /// </summary> - public List<string> value = new List<string>(); + public List<string> value_key = new List<string>(); /// <summary> /// 鏈�澶у�� /// </summary> @@ -338,7 +340,7 @@ /// <summary> /// 褰撳墠鍊� /// </summary> - public object curValue = new object(); + public object value = new object(); //----app鑷畾涔� @@ -356,7 +358,7 @@ return _uintString; } var us = ""; - switch (key) + switch (name) { case "temperature": case "set_temperature": @@ -381,7 +383,7 @@ get { string text = ""; - switch (key) + switch (name) { case "on_off": text = Language.StringByID(StringId.OnOff); @@ -445,7 +447,7 @@ /// </summary> public string GetCurValueText() { - return GetValueText(curValue.ToString()); + return GetValueText(value.ToString()); } /// <summary> @@ -456,7 +458,7 @@ { string text = ""; value = value.Replace("{}", ""); - switch (key) + switch (name) { case "on_off": text = value == "on" ? Language.StringByID(StringId.On) : Language.StringByID(StringId.OFF); @@ -467,7 +469,7 @@ case "percent": if (value == "") { - this.curValue = this.min; + this.value = this.min; text = this.min.ToString(); } else @@ -512,21 +514,21 @@ text = Language.StringByID(StringId.Timer); break; default: - if (this.value.Contains("cool")) + if (this.value_key.Contains("cool")) { - this.curValue = "cool"; + this.value = "cool"; text = Language.StringByID(StringId.Cool); } - else if (this.value.Contains("day")) + else if (this.value_key.Contains("day")) { - this.curValue = "day"; + this.value = "day"; text = Language.StringByID(StringId.Day); } else { - foreach (var v in this.value) + foreach (var v in this.value_key) { - this.curValue = v; + this.value = v; text = GetCurValueText(); } } @@ -549,16 +551,16 @@ text = Language.StringByID(StringId.Auto); break; default: - if (this.value.Contains("low")) + if (this.value_key.Contains("low")) { - this.curValue = "low"; + this.value = "low"; text = Language.StringByID(StringId.LowWindSpeed); } else { - foreach (var v in this.value) + foreach (var v in this.value_key) { - this.curValue = v; + this.value = v; text = GetCurValueText(); } } -- Gitblit v1.8.0