From c44b10e4447e84dbdfa9105edf460ef364a8f2b3 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期一, 30 十一月 2020 19:53:35 +0800
Subject: [PATCH] Merge branch 'master' into WJC

---
 HDL_ON/Entity/Function/Function.cs |  136 +++++++++++++++++++++++++++++++--------------
 1 files changed, 93 insertions(+), 43 deletions(-)

diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs
index 053e45b..be61b11 100644
--- a/HDL_ON/Entity/Function/Function.cs
+++ b/HDL_ON/Entity/Function/Function.cs
@@ -1,5 +1,6 @@
 锘縰sing System;
 using System.Collections.Generic;
+using HDL_ON.DriverLayer;
 using Shared;
 
 namespace HDL_ON.Entity
@@ -54,7 +55,7 @@
         /// 濡傦細鏄疉C鍔熻兘锛氱壒鎬э細on_off,mode,fan,temperature
         /// attri
         /// </summary>
-        public List<Trait> function = new List<Trait>();
+        public List<FunctionAttributes> function = new List<FunctionAttributes>();
 
         /// <summary>
         /// 鎴块棿ID鍒楄〃
@@ -145,27 +146,27 @@
         [Newtonsoft.Json.JsonIgnore]
         public string lastState = "";
 
-        Trait _trait_on_off;
+        FunctionAttributes _trait_on_off;
         [Newtonsoft.Json.JsonIgnore]
-        public Trait trait_on_off
+        public FunctionAttributes trait_on_off
         {
             get
             {
                 if (_trait_on_off == null)
                 {
-                    _trait_on_off = function.Find((obj) => obj.name == "on_off");
+                    _trait_on_off = function.Find((obj) => obj.key == "on_off");
                     //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂��
                     if (_trait_on_off == null)
                     {
-                        _trait_on_off = new Trait()
+                        _trait_on_off = new FunctionAttributes()
                         {
-                            name = "on_off",
-                            value_key = new List<string> { "on", "off" },
+                            key = "on_off",
+                            value = new List<string> { "on", "off" },
                             max = 1,
                             min = 0,
                         };
                     }
-                    _trait_on_off.value = "on";
+                    _trait_on_off.curValue = "on";
                 }
                 return _trait_on_off;
             }
@@ -219,8 +220,10 @@
             {
                 var findRoom = DB_ResidenceData.rooms.Find(obj => obj.sid == roomId);
                 if (findRoom == null)
+                {
                     continue;
-                if(roomNameList != "")
+                }
+                if (roomNameList != "")
                 {
                     roomNameList += ",";
                 }
@@ -246,34 +249,78 @@
         /// 鏇存柊鏃堕棿
         /// </summary>
         public DateTime refreshTime = DateTime.MinValue;
+
+        /// <summary>
+        /// 鑾峰彇鎺у埗鍙戦�佹暟鎹�
+        /// </summary>
+        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();
+
+
+            var acd = new AprotocolControlData();
+            acd.sid = sid;
+#if DEBUG
+            acd.sid = "0001016FB925AB02020100010101";
+#endif
+            var aca = new AprotocolControlAttribute();
+            foreach(var dic in commandDictionary)
+            {
+                aca.key = dic.Key;
+                aca.value = dic.Value;
+                acd.status.Add(aca);
+            }
+
+            sendDataObj.objects.Add(acd);
+
+            return sendDataObj;
+        }
+    }
+
+    /// <summary>
+    /// A鍗忚鎺у埗鏁版嵁鐨勫璞�
+    /// </summary>
+    public class AprotocolControlObj
+    {
+        public List<AprotocolControlData> objects = new List<AprotocolControlData>();
+
+        public string time_stamp = "";
+        public string id = "";
+    }
+    /// <summary>
+    /// A鍗忚鎺у埗鏁版嵁
+    /// </summary>
+    public class AprotocolControlData
+    {
+        
+        public string sid = "";
+        public List<AprotocolControlAttribute> status = new List<AprotocolControlAttribute>();
+    }
+    /// <summary>
+    /// A鍗忚鎺у埗灞炴�у璞�
+    /// </summary>
+    public class AprotocolControlAttribute
+    {
+        public string key;
+        public string value;
     }
 
     /// <summary>
     /// 鍔熻兘灞炴��
     /// 灞炴�у瓧娈佃В鏋愶細attri :灞炴�у唴瀹癸紝value 灞炴�х殑鍊硷紝max 鏈�澶у�� min 鏈�灏忓��
     /// </summary>
-    public class Trait
+    public class FunctionAttributes
     {
         /// <summary>
-        /// 灞炴�у悕绉�
+        /// 灞炴�ч敭鍚�
         /// </summary>
-        public string name;
-        List<string> _value_key;
+        public string key;
         /// <summary>
         /// 灞炴�х殑鍊煎垪琛�
         /// </summary>
-        [Newtonsoft.Json.JsonIgnore]
-        public List<string> value_key
-        {
-            get
-            {
-                return _value_key;
-            }
-            set
-            {
-                _value_key = value;
-            }
-        }
+        public List<string> value = new List<string>();
         /// <summary>
         /// 鏈�澶у��
         /// </summary>
@@ -291,7 +338,7 @@
         /// <summary>
         /// 褰撳墠鍊�
         /// </summary>
-        public object value = new object();
+        public object curValue = new object();
 
 
         //----app鑷畾涔�
@@ -309,9 +356,10 @@
                     return _uintString;
                 }
                 var us = "";
-                switch (name)
+                switch (key)
                 {
                     case "temperature":
+                    case "set_temperature":
                         us = "掳C";
                         break;
                     case "percent":
@@ -333,7 +381,7 @@
             get
             {
                 string text = "";
-                switch (name)
+                switch (key)
                 {
                     case "on_off":
                         text = Language.StringByID(StringId.OnOff);
@@ -351,6 +399,7 @@
                         text = Language.StringByID(StringId.FanSpeed);
                         break;
                     case "temperature":
+                case "set_temperature":
                         text = Language.StringByID(StringId.Temp);
                         break;
                     case "delay":
@@ -366,7 +415,7 @@
                         //case "lock":
                         //case "ico":
                         //case "swing":
-                        //case "set_ point":
+                        //case "set_point":
                         //case "pm25":
                         //case "volume":
                         //case "vol_step":
@@ -396,7 +445,7 @@
         /// </summary>
         public string GetCurValueText()
         {
-            return GetValueText(value.ToString());
+            return GetValueText(curValue.ToString());
         }
 
         /// <summary>
@@ -407,17 +456,18 @@
         {
             string text = "";
             value = value.Replace("{}", "");
-            switch (name)
+            switch (key)
             {
                 case "on_off":
                     text = value == "on" ? Language.StringByID(StringId.On) : Language.StringByID(StringId.OFF);
                     break;
                 case "temperature":
+                case "set_temperature":
                 case "brightness":
                 case "percent":
                     if (value == "")
                     {
-                        this.value = this.min;
+                        this.curValue = this.min;
                         text = this.min.ToString();
                     }
                     else
@@ -462,21 +512,21 @@
                             text = Language.StringByID(StringId.Timer);
                             break;
                         default:
-                            if (this.value_key.Contains("cool"))
+                            if (this.value.Contains("cool"))
                             {
-                                this.value = "cool";
+                                this.curValue = "cool";
                                 text = Language.StringByID(StringId.Cool);
                             }
-                            else if (this.value_key.Contains("day"))
+                            else if (this.value.Contains("day"))
                             {
-                                this.value = "day";
+                                this.curValue = "day";
                                 text = Language.StringByID(StringId.Day);
                             }
                             else
                             {
-                                foreach (var v in this.value_key)
+                                foreach (var v in this.value)
                                 {
-                                    this.value = v;
+                                    this.curValue = v;
                                     text = GetCurValueText();
                                 }
                             }
@@ -499,16 +549,16 @@
                             text = Language.StringByID(StringId.Auto);
                             break;
                         default:
-                            if (this.value_key.Contains("low"))
+                            if (this.value.Contains("low"))
                             {
-                                this.value = "low";
+                                this.curValue = "low";
                                 text = Language.StringByID(StringId.LowWindSpeed);
                             }
                             else
                             {
-                                foreach (var v in this.value_key)
+                                foreach (var v in this.value)
                                 {
-                                    this.value = v;
+                                    this.curValue = v;
                                     text = GetCurValueText();
                                 }
                             }
@@ -521,7 +571,7 @@
                 //case "lock":
                 //case "ico":
                 //case "swing":
-                //case "set_ point":
+                //case "set_point":
                 //case "pm25":
                 //case "volume":
                 //case "vol_step":

--
Gitblit v1.8.0