From 427a6e93b8946b9d91727166a352b2ee2ef75d19 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期五, 05 二月 2021 10:10:08 +0800
Subject: [PATCH] Delete .DS_Store

---
 HDL_ON/DAL/DriverLayer/Control.cs |  134 ++++++++++++++++++++++++++++++++++----------
 1 files changed, 103 insertions(+), 31 deletions(-)

diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
old mode 100644
new mode 100755
index d6da0f6..089f706
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -1,4 +1,4 @@
-using System;
+锘縰sing System;
 using System.Collections.Generic;
 using System.Text;
 using HDL_ON.Entity;
@@ -82,11 +82,27 @@
             {
                 if (_gatewayOnline != value)
                 {
-                    _gatewayOnline = value;
-                    //淇敼涓婚〉杩炴帴鐘舵��
-                    UI.HomePage.LoadEvent_CheckLinkStatus();
-                    if (value)
+                    if(value)
                     {
+                        if (IsRemote)//濡傛灉鏄繙绋�
+                        {
+                            if(DB_ResidenceData.Instance.HomeGateway == null)
+                            {
+                                return;
+                            }
+                            if (!DB_ResidenceData.Instance.HomeGateway.gatewayStatus)//杩滅▼鎯呭喌涓嬶紝缃戝叧鏈摼鎺ユ湇鍔″櫒涓嶈兘淇敼涓婚〉缃戝叧鐘舵��
+                            {
+                                new System.Threading.Thread(() => {
+                                    System.Threading.Thread.Sleep(3000);
+                                    var pm = new DAL.Server.HttpServerRequest();
+                                    pm.GetGatewayInfo();
+                                }) { IsBackground = true }.Start();
+                                return;
+                            }
+                        }
+                        _gatewayOnline = value;
+                        //淇敼涓婚〉杩炴帴鐘舵��
+                        HomePage.LoadEvent_CheckLinkStatus();
                         MainPage.Log($"缃戝叧鍦ㄧ嚎锛屽埛鏂拌澶囩姸鎬�");
                         new System.Threading.Thread(() =>
                         {
@@ -94,6 +110,12 @@
                             FunctionList.List.ReadAllFunctionStatus();
                         })
                         { IsBackground = true, Priority = System.Threading.ThreadPriority.AboveNormal }.Start();
+                    }
+                    else
+                    {
+                        _gatewayOnline = value;
+                        //淇敼涓婚〉杩炴帴鐘舵��
+                        HomePage.LoadEvent_CheckLinkStatus();
                     }
                 }
             }
@@ -103,23 +125,10 @@
         /// </summary>
         public string GatewayId = "";
 
-        bool _isRemote = false;
         /// <summary>
         /// 鏄惁涓鸿繙绋嬭繛鎺�
         /// </summary>
-        public bool IsRemote
-        {
-            get
-            {
-                return _isRemote;
-            }
-            set
-            {
-                _isRemote = value;
-                //淇敼涓婚〉杩炴帴鐘舵��
-                HomePage.LoadEvent_CheckLinkStatus();
-            }
-        }
+        public bool IsRemote = false;
         /// <summary>
         /// 閫氳鍦板潃IP
         /// </summary>
@@ -183,7 +192,14 @@
         /// </summary>
         public void SearchLoaclGateway()
         {
-            MainPage.Log($"鎼滅储鏈湴缃戝叧鍒楄〃锛岀綉鍏崇被鍨�:{DB_ResidenceData.Instance.GatewayType}");
+            //2021-01-15 : 浣忓畢娌℃湁缁戝畾缃戝叧鐨勬椂鍊欎笉鐢ㄦ悳绱紝骞朵笖涓嶈兘閾炬帴mqtt
+            if(DB_ResidenceData.Instance.HomeGateway == null)
+            {
+                return;
+            }
+            var ggg = DB_ResidenceData.Instance.GatewayType == 0 ? "涓�绔彛" : "A缃戝叧";
+            var ggg1 = MainPage.InternetStatus == 1 ? "4G" : "wifi";
+            MainPage.Log($"鎼滅储缃戝叧鍒楄〃锛岀綉鍏崇被鍨�:{ggg};缃戠粶绫诲瀷:{ggg1}");
             if (MainPage.InternetStatus == 0)
             {
                 Ins.GatewayOnline = false;
@@ -241,7 +257,11 @@
         {
             if (Ins.IsRemote || DB_ResidenceData.Instance.GatewayType == 1)
             {
-                ControlAProtocolScene(scene);
+                new System.Threading.Thread(() =>
+                {
+                    ControlAProtocolScene(scene);
+                })
+                { IsBackground = true }.Start();
             }
             else
             {
@@ -259,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;
@@ -287,8 +308,10 @@
                 }
             }
 
+            MainPage.Log($"鍙戦�佹暟鎹�:{Newtonsoft.Json.JsonConvert.SerializeObject(commandDictionary)}");
+
             //杩滅▼閫氳
-            if (Ins.IsRemote)
+            if (Ins.IsRemote || useRemote == true)
             {
                 DAL.Server.HttpServerRequest httpServer = new DAL.Server.HttpServerRequest();
                 //ALink鎺у埗銆丅us鎺у埗浣跨敤鍚屼竴涓帴鍙f帶鍒讹紝鐢变簯绔礋璐hВ鏋�
@@ -296,7 +319,6 @@
                 var actionObjs = new List<ApiAlinkControlActionObj>();
                 actionObjs.Add(apiControlData);
                 var pack = httpServer.ControlDevice(actionObjs);
-                //MainPage.Log($"{pack.Code}:{pack.Data}");
             }
             //鏈湴閫氳
             else
@@ -323,6 +345,35 @@
                     MainPage.Log($"鍙戦�丠DL-Link鏁版嵁:{functionControlDataJson}");
                 }
             }
+        }
+        /// <summary>
+        /// 鍏ㄥ紑鍏ㄥ叧鍔熻兘
+        /// </summary>
+        public void SwtichFunctions(bool open,List<Function> functions)
+        {
+            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)
+            {
+                logString += temp.spk + ":" + temp.sid + "\r\n";
+                var apiControlData = temp.GetApiControlData(d);
+                actionObjs.Add(apiControlData);
+                count++;
+                if (count > 9)
+                {
+                    var result = pm.ControlDevice(actionObjs);
+                    actionObjs = new List<ApiAlinkControlActionObj>();
+                    count = 0;
+                    MainPage.Log(logString);
+                    logString = "";
+                }
+            }
+            var pack = pm.ControlDevice(actionObjs);
+            MainPage.Log(logString);
         }
 
         public void SendApiReadCommand(List<string> functionIds)
@@ -401,8 +452,16 @@
         {
             if (Ins.IsRemote)
             {
-                var pm = new HDL_ON.DAL.Server.HttpServerRequest();
-                pm.ExecuteScene(scene.userSceneId);
+                //浜戠鍋氬鐞嗗彂閫佷竴绔彛鍦烘櫙
+                //if (DB_ResidenceData.Instance.GatewayType == 0)
+                //{
+                //    new Control_Udp().ControlBusScenes(scene);
+                //}
+                //else
+                {
+                    var pm = new DAL.Server.HttpServerRequest();
+                    var result = pm.ExecuteScene(scene.userSceneId);
+                }
             }
             else
             {
@@ -495,7 +554,7 @@
                     var device = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceModule>(bodyJObj.objects.ToString());
                     if (device.device_mac == DB_ResidenceData.Instance.residenceGatewayMAC)
                     {
-                        //鏈湴鎼滅储缃戝叧鎴愬姛
+                        MainPage.Log("鏈湴鎼滅储缃戝叧鎴愬姛");
                         Control.Ins.IsSearchLocalGatewaySuccessful = true;
                         Ins.GatewayOnline = true;
                         if (!string.IsNullOrEmpty(device.gatewayId))
@@ -817,14 +876,27 @@
                                     }
                                     break;
                                 case SPK.ElectricTV:
+                                    break;
+                                case SPK.ElectricTuyaAirCleaner:
+                                case SPK.ElectricTuyaFan:
+                                case SPK.ElectricTuyaWeepRobot:
+                                    //璁惧鐘舵�佹帹閫�
+                                    var myDevice = Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(updateTemp);
+                                    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