From abf4a98837e43e542701c60b7ec6a088cd5236da Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期一, 22 二月 2021 09:10:35 +0800
Subject: [PATCH] 20210222

---
 HDL_ON/DAL/DriverLayer/Control.cs |   74 ++++++++++++++++++++++++++++++++-----
 1 files changed, 64 insertions(+), 10 deletions(-)

diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
index 84a426e..20d2fa3 100644
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -207,9 +207,9 @@
             }
             else if (MainPage.InternetStatus == 1)
             {
-                if (!Ins.IsRemote)
+                //if (!Ins.IsRemote)
                 {
-                    Ins.IsRemote = true;
+                    //Ins.IsRemote = true;
                     DAL.Mqtt.MqttClient.InitState();
                 }
             }
@@ -279,8 +279,9 @@
         /// </summary>
         /// <param name="commandString"></param>
         /// <param name="function"></param>
+        /// <param name="useRemote">鏄惁鐩存帴浣跨敤杩滅▼鍙戦��</param>
         /// <returns></returns>
-        public void SendWriteCommand(Function function, Dictionary<string, string> commandDictionary)
+        public void SendWriteCommand(Function function, Dictionary<string, string> commandDictionary, bool useRemote = false)
         {
             function.controlCounter++;
             function.refreshTime = DateTime.Now;
@@ -309,8 +310,19 @@
 
             MainPage.Log($"鍙戦�佹暟鎹�:{Newtonsoft.Json.JsonConvert.SerializeObject(commandDictionary)}");
 
+            ///绗笁鏂规秱楦﹁澶囩粺涓�浣跨敤杩滅▼鎺у埗
+            switch(function.spk)
+            {
+                case SPK.ElectricTuyaAirCleaner:
+                case SPK.ElectricTuyaFan:
+                case SPK.ElectricTuyaWaterValve:
+                case SPK.ElectricTuyaWeepRobot:
+                    useRemote = true;
+                    break;
+            }
+
             //杩滅▼閫氳
-            if (Ins.IsRemote)
+            if (Ins.IsRemote || useRemote == true)
             {
                 DAL.Server.HttpServerRequest httpServer = new DAL.Server.HttpServerRequest();
                 //ALink鎺у埗銆丅us鎺у埗浣跨敤鍚屼竴涓帴鍙f帶鍒讹紝鐢变簯绔礋璐hВ鏋�
@@ -341,7 +353,7 @@
                     var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(functionControlDataObj);
                     var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlFunctionTopic, functionControlDataJson);
                     new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id);
-                    MainPage.Log($"鍙戦�丠DL-Link鏁版嵁:{functionControlDataJson}");
+                    MainPage.Log($"鏈湴閫氳 鍙戦�丠DL-Link鏁版嵁:{functionControlDataJson}");
                 }
             }
         }
@@ -379,6 +391,34 @@
         {
             var pm = new DAL.Server.HttpServerRequest();
             var pack = pm.RefreshDeviceStatus(functionIds);
+        }
+        /// <summary>
+        /// 璇诲彇鍔熻兘璇︾粏鏁版嵁
+        /// </summary>
+        /// <param name="functionIds"></param>
+        public void ReadFunctionsInfo(List<string> functionIds)
+        {
+            var pm = new DAL.Server.HttpServerRequest();
+            var pack = pm.GetDeviceInfoList(functionIds);
+            if(pack!= null&& pack.Data!=null)
+            {
+                var ddd = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Function>>(pack.Data.ToString());
+                if(ddd!= null)
+                {
+                    foreach(var function in ddd)
+                    {
+                        var temp = FunctionList.List.GetDeviceFunctionList().Find((obj) => obj.deviceId == function.deviceId);
+                        if(temp!= null)
+                        {
+                            temp = function;
+                            if (SPK.Get3tySpk(SPK.BrandType.Tuya).Contains(temp.spk))
+                            {
+                                Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(temp.sid, temp.status);
+                            }
+                        }
+                    }
+                }
+            }
         }
 
         /// <summary>
@@ -422,7 +462,7 @@
                     };
                     var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(readDataObj);
                     var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ReadStatus, functionControlDataJson);
-                    MainPage.Log($"鍙戦�丠DL-Link鏁版嵁:{functionControlDataJson}");
+                    MainPage.Log($"鏈湴閫氳 鍙戦�丠DL-Link鏁版嵁:{functionControlDataJson}");
                     new Control_Udp().SendLocalHdlLinkData(sendBytes, readDataObj.id);
                 }
             }
@@ -875,14 +915,28 @@
                                     }
                                     break;
                                 case SPK.ElectricTV:
+                                    break;
+                                case SPK.ElectricTuyaAirCleaner:
+                                case SPK.ElectricTuyaFan:
+                                case SPK.ElectricTuyaWeepRobot:
+                                case SPK.ElectricTuyaWaterValve:
+                                    //璁惧鐘舵�佹帹閫�
+                                    var myDevice = Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(updateTemp.sid,updateTemp.status);
+                                    if (myDevice != null)
+                                    {
+                                        localObj = myDevice;
+                                    }
                                     break;
                                 default:
                                     break;
                             }
-                            HomePage.UpdataFunctionStates(localObj);
-                            RoomPage.UpdataStates(localObj);
-                            FunctionPage.UpdataStates(localObj);
-                            ClassificationPage.UpdataInfo(localObj);
+                            if (localObj != null)
+                            {
+                                HomePage.UpdataFunctionStates(localObj);
+                                RoomPage.UpdataStates(localObj);
+                                FunctionPage.UpdataStates(localObj);
+                                ClassificationPage.UpdataInfo(localObj);
+                            }
                         }
                     }
                     catch (Exception ex)

--
Gitblit v1.8.0