From ba275a7b58e56c61820ffccc86571447b2997e52 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期四, 05 八月 2021 16:18:00 +0800
Subject: [PATCH] 2021-08-05 1.更新

---
 HDL_ON/DAL/DriverLayer/Control.cs |   73 +++++++++++++++++++++++++++++-------
 1 files changed, 58 insertions(+), 15 deletions(-)

diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
index 913c52a..7cbe4d6 100644
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -434,6 +434,25 @@
                 //杩滅▼閫氳
                 else
                 {
+                    //Bug淇锛氫竴绔彛杩滅▼鎺у埗璋冨厜璁惧鐨勮皟鍏夊睘鎬ф椂锛屾棤娉曟帶鍒跺埌0锛屽弽澶嶆í璺炽��
+                    //鍥犱负On + 杩滅▼鎺у埗鍙戦�佺粰浜戠浣跨敤鐨勬槸link鍗忚鏁版嵁锛屾潹娑涗腑杞粰楂樿儨澶勭悊鏃跺�欓�昏緫涓婃湁鍐茬獊锛屽鑷存棤娉曞崟鐙帶鍒朵寒搴﹀�硷紝闇�瑕佸悓鏃跺彂閫佸紑鍏冲�间笌浜害鍊笺��
+                    if (DB_ResidenceData.Instance.GatewayType == 0)
+                    {
+                        if (commandDictionary.Count == 1)
+                        {
+                            if (commandDictionary.ContainsKey(FunctionAttributeKey.Brightness))
+                            {
+                                commandDictionary.Add(FunctionAttributeKey.OnOff, commandDictionary[FunctionAttributeKey.Brightness] == "0" ? "off" : "on");
+                            }
+                        }
+                        if(function.spk == SPK.LightCCT)
+                        {
+                            if (!commandDictionary.ContainsKey(FunctionAttributeKey.CCT))
+                            {
+                                commandDictionary.Add(FunctionAttributeKey.CCT, function.GetAttrState(FunctionAttributeKey.CCT));
+                            }
+                        }
+                    }
                     DAL.Server.HttpServerRequest httpServer = new DAL.Server.HttpServerRequest();
                     //ALink鎺у埗銆丅us鎺у埗浣跨敤鍚屼竴涓帴鍙f帶鍒讹紝鐢变簯绔礋璐hВ鏋�
                     var apiControlData = function.GetApiControlData(commandDictionary);
@@ -467,28 +486,41 @@
             }
 
             var count = 0;
-            var logString = open ? "鎵撳紑\r\n" : "鍏抽棴\r\n";
             List<ApiAlinkControlActionObj> actionObjs = new List<ApiAlinkControlActionObj>();
             Dictionary<string, string> d = new Dictionary<string, string>();
             d.Add(FunctionAttributeKey.OnOff, open ? "on" : "off");
             var pm = new DAL.Server.HttpServerRequest();
-            foreach (var temp in functions)
+            //涓�绔彛鍏ㄥ紑鍏ㄥ叧闇�瑕佸欢鏃跺彂閫�
+            if (DB_ResidenceData.Instance.GatewayType == 0)
             {
-                logString += temp.spk + ":" + temp.sid + "\r\n";
-                var apiControlData = temp.GetApiControlData(d);
-                actionObjs.Add(apiControlData);
-                count++;
-                if (count > 9)
+                new System.Threading.Thread(() =>
                 {
-                    var result = pm.ControlDevice(actionObjs);
-                    actionObjs = new List<ApiAlinkControlActionObj>();
-                    count = 0;
-                    MainPage.Log(logString);
-                    logString = "";
-                }
+                    foreach (var temp in functions)
+                    {
+                        var apiControlData = temp.GetApiControlData(d);
+                        var result = pm.ControlDevice(new List<ApiAlinkControlActionObj>() { apiControlData });
+                        System.Threading.Thread.Sleep(100);
+                    }
+                })
+                { IsBackground = true }.Start();
             }
-            var pack = pm.ControlDevice(actionObjs);
-            MainPage.Log(logString);
+            else
+            {
+                foreach (var temp in functions)
+                {
+                    var apiControlData = temp.GetApiControlData(d);
+                    actionObjs.Add(apiControlData);
+                    count++;
+                    if (count > 9)
+                    {
+                        var result = pm.ControlDevice(actionObjs);
+                        actionObjs = new List<ApiAlinkControlActionObj>();
+                        count = 0;
+                        System.Threading.Thread.Sleep(100);
+                    }
+                }
+                var pack = pm.ControlDevice(actionObjs);
+            }
         }
 
         public void SendApiReadCommand(List<string> functionIds)
@@ -889,6 +921,17 @@
                                 }
                                 EnvironmentalPage.LoadEvent_UpdataStatus(localFunction);
                                 break;
+                            case SPK.SensorEnvironment:
+                                if (localFunction.GetAttributes().Contains(FunctionAttributeKey.Temperature))
+                                {
+                                    HomePage.LoadEvent_RefreshEnvirIndoorTemp();
+                                }
+                                if (localFunction.GetAttributes().Contains(FunctionAttributeKey.Humidity))
+                                {
+                                    HomePage.LoadEvent_RefreshEnvirIndoorHumi();
+                                }
+                                EnvironmentalPage.LoadEvent_UpdataStatus(localFunction);
+                                break;
                             case SPK.ElectricSocket:
                                 SocketPage.UpdataState(localFunction);
                                 break;

--
Gitblit v1.8.0