From 592974441a4df95fffd9167c90192da1a390b1c2 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 06 六月 2023 11:51:12 +0800
Subject: [PATCH] Merge branch 'Dev-Branch'

---
 HDL_ON/DAL/DriverLayer/Control.cs |  329 +++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 247 insertions(+), 82 deletions(-)

diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
index ab30fc6..da0a7b2 100644
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -29,11 +29,27 @@
         /// 璁板綍鎺ユ敹鍒扮殑娑堟伅锛屾柟渚縵b鐨勫伐绋嬪笀璋冭瘯浠栦滑鐨勮澶�
         /// </summary>
         public List<string> MsgInfoList = new List<string>();
+        private bool _LocalTcpClientLogin = false;
         /// <summary>
         /// 鏈湴tcp瀹㈡埛绔繛鎺ユ槸鍚︽垚鍔�
         /// 鏄惁鐧诲綍缃戝叧鎴愬姛
         /// </summary>
-        public bool LocalTcpClientLogin = false;
+        public bool LocalTcpClientLogin
+        {
+            get
+            {
+                return _LocalTcpClientLogin;
+            }
+            set
+            {
+                _LocalTcpClientLogin = value;
+                if (!value)
+                {
+                    loginGatewayThread?.Abort();
+                    loginGatewayThread = null;
+                }
+            }
+        }
 
         int _msg_id = 1;
         /// <summary>
@@ -67,8 +83,10 @@
         /// <summary>
         /// 鍒ゆ柇鏄惁鏈湴鍔犲瘑骞朵笖鍔犲瘑key涓嶄负绌�
         /// </summary>
-        public bool IsLocalEncryptAndGetAesKey {
-            get {
+        public bool IsLocalEncryptAndGetAesKey
+        {
+            get
+            {
                 return IsLocalEncrypt && (!string.IsNullOrEmpty(DB_ResidenceData.Instance.CurrentRegion.localSecret));
             }
         }
@@ -120,45 +138,51 @@
             }
             set
             {
-                if (_GatewayOnline_Cloud != value)
+                try
                 {
-                    _GatewayOnline_Cloud = value;
-                    if(GatewayOnline_Local)
+                    if (_GatewayOnline_Cloud != value)
                     {
-                        return;
-                    }
-                    if (value)
-                    {
-                        if (DB_ResidenceData.Instance.HomeGateway == null)
+                        _GatewayOnline_Cloud = value;
+                        if (GatewayOnline_Local)
                         {
                             return;
                         }
-                        if (!DB_ResidenceData.Instance.HomeGateway.gatewayStatus)//杩滅▼鎯呭喌涓嬶紝缃戝叧鏈摼鎺ユ湇鍔″櫒涓嶈兘淇敼涓婚〉缃戝叧鐘舵��
+                        if (value)
                         {
+                            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;
+                            }
+                            //淇敼涓婚〉杩炴帴鐘舵��
+                            HomePage.LoadEvent_CheckLinkStatus();
+                            MainPage.Log($"缃戝叧浜戠鍦ㄧ嚎锛屽埛鏂拌澶囩姸鎬�");
                             new System.Threading.Thread(() =>
                             {
-                                System.Threading.Thread.Sleep(3000);
-                                var pm = new DAL.Server.HttpServerRequest();
-                                pm.GetGatewayInfo();
+                                System.Threading.Thread.Sleep(1000);
+                                FunctionList.List.ReadAllFunctionStatus();
                             })
-                            { IsBackground = true }.Start();
-                            return;
+                            { IsBackground = true, Priority = System.Threading.ThreadPriority.AboveNormal }.Start();
                         }
-                        //淇敼涓婚〉杩炴帴鐘舵��
-                        HomePage.LoadEvent_CheckLinkStatus();
-                        MainPage.Log($"缃戝叧浜戠鍦ㄧ嚎锛屽埛鏂拌澶囩姸鎬�");
-                        new System.Threading.Thread(() =>
+                        else
                         {
-                            System.Threading.Thread.Sleep(1000);
-                            FunctionList.List.ReadAllFunctionStatus();
-                        })
-                        { IsBackground = true, Priority = System.Threading.ThreadPriority.AboveNormal }.Start();
+                            //淇敼涓婚〉杩炴帴鐘舵��
+                            HomePage.LoadEvent_CheckLinkStatus();
+                        }
                     }
-                    else
-                    {
-                        //淇敼涓婚〉杩炴帴鐘舵��
-                        HomePage.LoadEvent_CheckLinkStatus();
-                    }
+                }catch(Exception ex)
+                {
+                    MainPage.Log($"Set GatewayCloudOnline Error:{ex.Message}");
                 }
             }
         }
@@ -222,8 +246,9 @@
             if (myTcpClient == null)
             {
                 myTcpClient = new Control_TcpClient(reportIp);
-                myTcpClient.Connect();
             }
+            myTcpClient.Connect();
+
         }
 
         /// <summary>
@@ -232,7 +257,8 @@
         public void SearchLoaclGateway()
         {
             //2021-01-15 : 浣忓畢娌℃湁缁戝畾缃戝叧鐨勬椂鍊欎笉鐢ㄦ悳绱紝骞朵笖涓嶈兘閾炬帴mqtt
-            if(DB_ResidenceData.Instance.HomeGateway == null || string.IsNullOrEmpty(DB_ResidenceData.Instance.HomeGateway.gatewayId))
+            if (DB_ResidenceData.Instance.HomeGateway == null || string.IsNullOrEmpty(DB_ResidenceData.Instance.HomeGateway.gatewayId) ||
+                    !UserInfo.Current.IsLogin)
             {
                 return;
             }
@@ -291,12 +317,13 @@
         /// </summary>
         public void LoginGateway()
         {
-            if(loginGatewayThread== null)
+            if (loginGatewayThread == null)
             {
-                loginGatewayThread = new System.Threading.Thread(() => {
-                    while (true)
+                loginGatewayThread = new System.Threading.Thread(() =>
+                {
+                    while (!Ins.myTcpClient.isConnected)
                     {
-                        if (Ins.GatewayOnline_Local && myTcpClient.isConnected && LocalTcpClientLogin)
+                        if (Ins.GatewayOnline_Local && myTcpClient.isConnected)
                         {
                             var sendData = new { clientType = "app", version = "1.0" };
                             var sendJob = new { id = Control.Ins.msg_id.ToString(), time_stamp = Utlis.GetTimestamp(), objects = sendData };
@@ -309,9 +336,29 @@
                         }
                         System.Threading.Thread.Sleep(2000);
                     }
+                    //loginGatewayThread?.Abort();
+                    //loginGatewayThread = null;
 
                 });
+                loginGatewayThread.Start();
             }
+            else
+            {
+                try
+                {
+                    loginGatewayThread?.Abort();
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log($"閲嶅惎鐧诲綍缃戝叧绾跨▼寮傚父:{ex.Message}");
+                }
+                finally
+                {
+                    loginGatewayThread = null;
+                    LoginGateway();
+                }
+            }
+
         }
 
 
@@ -321,9 +368,9 @@
         public void ControlScene(Scene scene)
         {
             //浣撻獙妯″紡
-            if(MainPage.NoLoginMode)
+            if (MainPage.NoLoginMode)
             {
-                foreach(var sceneFunction in scene.functions)
+                foreach (var sceneFunction in scene.functions)
                 {
                     var revString = "";
                     var upDataObj = new AlinkFunctionStatusObj();
@@ -370,7 +417,7 @@
         /// <param name="function"></param>
         /// <param name="useRemote">鏄惁鐩存帴浣跨敤杩滅▼鍙戦��</param>
         /// <returns></returns>
-        public bool SendWriteCommand(Function function, Dictionary<string, string> commandDictionary, bool useRemote = false,int resend = 3)
+        public bool SendWriteCommand(Function function, Dictionary<string, string> commandDictionary, bool useRemote = false, int resend = 3)
         {
             function.controlCounter++;
             function.refreshTime = DateTime.Now;
@@ -417,7 +464,6 @@
                 UpdataFunctionStatus(revString, null, true);
                 return true;
             }
-
 
             //MainPage.Log($"鍙戦�佹暟鎹�:{Newtonsoft.Json.JsonConvert.SerializeObject(commandDictionary)}");
 
@@ -468,8 +514,9 @@
                         var functionControlDataObj = function.GetGatewayAlinkControlData(commandDictionary);
                         var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(functionControlDataObj);
                         var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlFunctionTopic, functionControlDataJson);
-                        new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id,resend);
+                        new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id, resend);
                         MainPage.Log($"鏈湴閫氳 鍙戦�丠DL-Link鏁版嵁:{functionControlDataJson}");
+                            Ins.myTcpClient.SendMessage(sendBytes);
                     }
                 }
                 //杩滅▼閫氳
@@ -486,7 +533,7 @@
                                 commandDictionary.Add(FunctionAttributeKey.OnOff, commandDictionary[FunctionAttributeKey.Brightness] == "0" ? "off" : "on");
                             }
                         }
-                        if(function.spk == SPK.LightCCT)
+                        if (function.spk == SPK.LightCCT)
                         {
                             if (!commandDictionary.ContainsKey(FunctionAttributeKey.CCT))
                             {
@@ -510,10 +557,10 @@
         /// <summary>
         /// 鍏ㄥ紑鍏ㄥ叧鍔熻兘
         /// </summary>
-        public void SwtichFunctions(bool open,List<Function> functions)
+        public void SwtichFunctions(bool open, List<Function> functions)
         {
             //dome妯″紡鎺у埗
-            if(MainPage.NoLoginMode)
+            if (MainPage.NoLoginMode)
             {
                 new System.Threading.Thread(() =>
                 {
@@ -521,7 +568,7 @@
                     {
                         Dictionary<string, string> d1 = new Dictionary<string, string>();
                         d1.Add(FunctionAttributeKey.OnOff, open ? "on" : "off");
-                         if (function.spk == SPK.PanelSocket)
+                        if (function.spk == SPK.PanelSocket)
                         {
                             if (function.attributes.Find((obj) => obj.key == "on_off_usb") != null)
                             {
@@ -587,16 +634,16 @@
         {
             var pm = new DAL.Server.HttpServerRequest();
             var pack = pm.GetDeviceInfoList(functionIds);
-            if(pack!= null&& pack.Data!=null)
+            if (pack != null && pack.Data != null)
             {
                 //寰呮祴璇�2021-03-04
                 var ddd = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AlinkStatusData>>(pack.Data.ToString());
-                if(ddd!= null)
+                if (ddd != null)
                 {
-                    foreach(var function in ddd)
+                    foreach (var function in ddd)
                     {
                         var temp = FunctionList.List.GetDeviceFunctionList().Find((obj) => obj.deviceId == function.deviceId);
-                        if(temp!= null)
+                        if (temp != null)
                         {
                             if (SPK.Get3tySpk(SPK.BrandType.Tuya).Contains(temp.spk))
                             {
@@ -612,7 +659,7 @@
         /// 鍙戦�佽鍙栧懡浠�
         /// 鑷姩鍒ゆ柇鏄惁涓篈鍗忚璁惧
         /// </summary>
-        public void SendReadCommand(Function function ,bool forceRemote = false)
+        public void SendReadCommand(Function function, bool forceRemote = false)
         {
             function.refreshTime = DateTime.Now;
             if (forceRemote)
@@ -696,7 +743,7 @@
                             {
                                 busClient.ReadBusData(function);
                             }
-                            
+
                         }
                         catch (Exception ex)
                         {
@@ -740,7 +787,7 @@
         /// <summary>
         /// 瀹夐槻鎺у埗
         /// </summary>
-        public void ControlSecurity(SecurityAlarm securityAlarm,string state)
+        public void ControlSecurity(SecurityAlarm securityAlarm, string state)
         {
             if (!Ins.GatewayOnline_Local)//缃戝叧鏈湴涓嶅湪绾�
             {
@@ -798,9 +845,36 @@
                 };
                 var aLinkJson = Newtonsoft.Json.JsonConvert.SerializeObject(aLinkData);
                 var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlScene, aLinkJson);
-                new Control_Udp().SendLocalHdlLinkData(sendBytes, aLinkData.id,0);
+                new Control_Udp().SendLocalHdlLinkData(sendBytes, aLinkData.id, 0);
             }
         }
+
+
+        /// <summary>
+        /// 鑾峰彇闊充箰鐩綍
+        /// </summary>
+        public void GetMusicDirectory(Function function)
+        {
+            if (Ins.GatewayOnline_Local)
+            {
+                var objects = new List<Dictionary<string, string>>();
+                var readKey = new Dictionary<string, string>();
+                readKey.Add("sid", function.sid);
+                objects.Add(readKey);
+                var readDataObj = new AlinkReadFunctionStatusObj()
+                {
+                    id = Ins.msg_id.ToString(),
+                    objects = objects,
+                    time_stamp = Utlis.GetTimestamp()
+                };
+                var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(readDataObj);
+                var sendBytes = Ins.ConvertSendBodyData($"/base/{DB_ResidenceData.Instance.HomeGateway.gatewayId}/thing/service/MusicPlayGroupListGet/down", functionControlDataJson);
+                MainPage.Log($"鏈湴閫氳 鍙戦�丠DL-Link鏁版嵁:{functionControlDataJson}");
+                new Control_Udp().SendLocalHdlLinkData(sendBytes, readDataObj.id);
+            }
+
+        }
+
         /// <summary>
         /// 缃戝叧杩涘叆閰嶇綉妯″紡
         /// </summary>
@@ -865,10 +939,10 @@
         /// 杞崲鎺ユ敹鍒扮殑鏁版嵁
         /// </summary>
         /// <returns></returns>
-        public void ConvertReceiveData(byte[] receiveBytes,string ip)
+        public void ConvertReceiveData(byte[] receiveBytes, string ip)
         {
             var reString = Encoding.UTF8.GetString(receiveBytes);
-            AnalysisReceiveData(reString, receiveBytes,ip);
+            AnalysisReceiveData(reString, receiveBytes, ip);
         }
         /// <summary>
         /// 杞崲鎺ユ敹鍒扮殑鏁版嵁
@@ -876,11 +950,10 @@
         /// <param name="receiveString">杞琒tring鍚庣殑鏁版嵁</param>
         /// <param name="originalReceiveBytes"鍘熷Bytes鏁版嵁</param>
         /// <returns></returns>
-        public LocalCommunicationData AnalysisReceiveData(string receiveString, byte[] originalReceiveBytes , string sIp = null)
+        public LocalCommunicationData AnalysisReceiveData(string receiveString, byte[] originalReceiveBytes, string sIp = null)
         {
             LocalCommunicationData receiveObj = new LocalCommunicationData();
 
-            MainPage.Log($"灞�鍩熺綉淇℃伅: \r\n{receiveString}");
 
             var res = receiveString.Split("\r\n\r\n");
 
@@ -912,9 +985,10 @@
                 //}
                 receiveObj.BodyDataString = res[1];
 
-                if(receiveObj.Topic == CommunicationTopic.ct.HeartBeat)
+                if (receiveObj.Topic == CommunicationTopic.ct.HeartBeat + "_reply")
                 {
-
+                    Ins.myTcpClient.ClearHeartBeatLog();
+                    MainPage.Log("tcp蹇冭烦鍥炲");
                     return null;
                 }
 
@@ -924,7 +998,6 @@
                     //鍒ゆ柇褰撳墠缃戝叧鏄惁寮�鍚簡鏈湴鍔犲瘑
                     if (IsLocalEncryptAndGetAesKey)
                     {
-                        MainPage.Log($"灞�鍩熺綉淇℃伅 寮�濮嬭В瀵�");
                         if (originalReceiveBytes != null)
                         {
                             //鎷垮埌鍘熷Bytes鏁版嵁鍘昏В瀵�
@@ -955,6 +1028,10 @@
                             //MainPage.Log($"灞�鍩熺綉淇℃伅: 瑙e瘑鍚庯細" + receiveObj.BodyDataString);
                         }
 
+                    }
+                    else
+                    {
+                        MainPage.Log($"灞�鍩熺綉淇℃伅: 鏄庢枃锛�" + receiveObj.BodyDataString);
                     }
                 }
 
@@ -1005,15 +1082,15 @@
                         //2021-09-23 鏂板鑾峰彇褰撳墠缃戝叧鏄惁鏈湴鍔犲瘑
                         Ins.IsLocalEncrypt = device.isLocalEncrypt;
                         //MainPage.Log("缃戝叧鏈湴鍔犲瘑鐘舵�侊細" + device.local_encrypt.ToString());
-
+                        //鐧诲綍缃戝叧Tcp
                         OpenTcpClent();
 
-                        LoginGateway();
 
                     }
                 }
                 else if (receiveObj.Topic == CommunicationTopic.ct.ReadStatus + "_reply" ||
-                    receiveObj.Topic == CommunicationTopic.ct.ControlFunctionTopic + "_reply" ||
+                    receiveObj.Topic == CommunicationTopic.ct.ControlFunctionTopic + "_reply" || 
+                    receiveObj.Topic == CommunicationTopic.ct.ControlGroupControlTopic + "_reply" || 
                     receiveObj.Topic == CommunicationTopic.ct.GatewayUpStatus ||
                     receiveObj.Topic.Contains(CommunicationTopic.ct.GatewayUpSortTopic))
                 {
@@ -1053,11 +1130,25 @@
                         MainPage.Log($"瀹夐槻灞�鍩熺綉寮傚父锛歿ex.Message}");
                     }
                 }
-                else if (receiveObj.Topic == $"/user/{GatewayId}/custom/gateway/login_reply") {
+                else if (receiveObj.Topic == $"/user/{GatewayId}/custom/gateway/login_reply")
+                {
                     var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(receiveObj.BodyDataString);
                     if (temp.GetValue("objects").ToString().Contains("success"))
                     {
                         LocalTcpClientLogin = true;
+                        try
+                        {
+                            loginGatewayThread?.Abort();
+                        }
+                        catch (Exception ex)
+                        {
+                            MainPage.Log($"缁堟鐧诲綍缃戝叧tcp寮傚父锛歿ex.Message}");
+                        }
+                        finally
+                        {
+                            loginGatewayThread = null;
+                        }
+                        MainPage.Log("灞�鍩熺綉tcp杩炴帴鐧诲綍缃戝叧鎴愬姛");
                     }
                 }
                 else
@@ -1083,7 +1174,7 @@
             }
             else
             {
-                if(processedDataList.Count> 50)
+                if (processedDataList.Count > 50)
                 {
                     processedDataList.RemoveAt(0);
                 }
@@ -1092,12 +1183,63 @@
 
         }
 
+
         /// <summary>
         /// 鏇存柊璁惧鐘舵��
         /// A鍗忚鏁版嵁
         /// </summary>
-        /// <param name="updateBytes"></param>
-        public void UpdataFunctionStatus(string revString, byte[] usefulBytes,bool isCloudData = false)
+        public void UpdataGroupControlStatus(string revString, byte[] usefulBytes, bool isCloudData = false)
+        {
+            var temp = JsonConvert.DeserializeObject<AlinkFunctionStatusObj>(revString);
+            if (temp != null)
+            {
+                Control_Udp.ReceiveRepeatManager(temp.id, usefulBytes);
+                var allLocalFuntion = FunctionList.List.groupControls;
+                foreach (var updateTemp in temp.objects)
+                {
+                    try
+                    {
+                        var localFunction = allLocalFuntion.Find((obj) => obj.sid == updateTemp.sid);
+                        if (localFunction == null)
+                        {
+                            continue;
+                        }
+                        MainPage.Log($"鏀跺埌鏁版嵁:{revString}");
+                        foreach (var attr in updateTemp.status)
+                        {
+                            localFunction.time_stamp = temp.time_stamp;
+                            localFunction.SetAttrState(attr.key, attr.value);
+
+                        }
+
+                        //鏇存柊鐣岄潰鐘舵��
+                        switch (localFunction.spk)
+                        {
+                            case SPK.ElectricEnergy:
+                                EnergyMainPage.UpdataStatus(localFunction);
+                                break;
+                        }
+
+                        HomePage.UpdataFunctionStates(localFunction);
+                        RoomPage.UpdataStates(localFunction);
+                        FunctionPage.UpdataStates(localFunction);
+                        ClassificationPage.UpdataInfo(localFunction);
+
+                    }
+                    catch (Exception ex)
+                    {
+                        MainPage.Log($"A鍗忚鏇存柊鐘舵�佸紓甯�:{ex.Message}");
+                    }
+                }
+            }
+        }
+
+
+        /// <summary>
+        /// 鏇存柊璁惧鐘舵��
+        /// A鍗忚鏁版嵁
+        /// </summary>
+        public void UpdataFunctionStatus(string revString, byte[] usefulBytes, bool isCloudData = false)
         {
             ////test 浜戠杩炴帴鎴愬姛鏃讹紝涓嶉�傜敤鏈湴鏁版嵁鏇存柊
             //if (Ins.GatewayOnline_Cloud && !isCloudData)
@@ -1140,7 +1282,7 @@
 
                         if (Ins.GatewayOnline_Local && isCloudData)//鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞�
                         {
-                            if (!SPK.Get3tySpk(SPK.BrandType.All3tyBrand).Contains(localFunction.spk) && !SPK.MusicSpkList().Contains( localFunction.spk))
+                            if (!SPK.Get3tySpk(SPK.BrandType.All3tyBrand).Contains(localFunction.spk) && !SPK.MusicSpkList().Contains(localFunction.spk))
                             {
                                 //MainPage.Log($"A鍗忚鏇存柊鐘舵��:鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞�........");
 
@@ -1157,21 +1299,27 @@
                         //        return;
                         //    }
                         //}
-                        //MainPage.Log($"A鍗忚鏇存柊鐘舵��:{revString}");
+                        MainPage.Log($"鏀跺埌鏁版嵁:{revString}");
                         foreach (var attr in updateTemp.status)
                         {
                             localFunction.time_stamp = temp.time_stamp;
                             localFunction.SetAttrState(attr.key, attr.value);
-                            //Console.WriteLine("闊充箰鎾斁鍣ㄦ坊鍔犵紦瀛樻暟鎹�=======" + revString);
 
                         }
 
                         //鏇存柊鐣岄潰鐘舵��
                         switch (localFunction.spk)
                         {
+                            case SPK.AcstParent:
+                                AcstParentPage.UpdateAcstParentInfo(localFunction);
+                                break;
+                            case SPK.AcstSub:
+                                AcstParentPage.UpdateAcstSubInfo(localFunction);
+                                AcstSubPage.UpdateStatus(localFunction);
+                                break;
                             case SPK.AirSwitch:
                                 AirSwitchPage.UpdataState(localFunction);
-                                if(localFunction.GetAttribute(FunctionAttributeKey.Power)!=null)//濡傛灉鏄甫鐢甸噺鐨勭┖寮�涔熻鏇存柊鑳芥簮鐣岄潰
+                                if (localFunction.GetAttribute(FunctionAttributeKey.Power) != null)//濡傛灉鏄甫鐢甸噺鐨勭┖寮�涔熻鏇存柊鑳芥簮鐣岄潰
                                 {
                                     EnergyMainPage.UpdataStatus(localFunction);
                                 }
@@ -1198,6 +1346,8 @@
                                 RGBPage.UpdataStates(localFunction);
                                 break;
                             case SPK.LightRGBW:
+                                localFunction.lastState = Language.StringByID(StringId.Brightness) + " : " + localFunction.GetAttrState(FunctionAttributeKey.Brightness) + "%";
+                                RGBWPage.UpdataStates(localFunction);
                                 break;
                             case SPK.LightCCT:
                                 localFunction.lastState = Language.StringByID(StringId.Brightness) + " : " + localFunction.GetAttrState(FunctionAttributeKey.Brightness) + "%";
@@ -1208,7 +1358,7 @@
                                 CurtainModulePage.UpdataState(localFunction);
                                 break;
                             case SPK.CurtainDream:
-                                if(localFunction.GetAttrState(FunctionAttributeKey.Percent) == "0")
+                                if (localFunction.GetAttrState(FunctionAttributeKey.Percent) == "0")
                                 {
                                     localFunction.SetAttrState(FunctionAttributeKey.OnOff, "off");
                                 }
@@ -1224,6 +1374,8 @@
                                 RollingShutterPage.UpdataState(localFunction);
                                 break;
                             case SPK.CurtainShades:
+                                localFunction.lastState = Language.StringByID(StringId.Open) + localFunction.GetAttrState(FunctionAttributeKey.Percent) + "%";
+                                VenetianBlindsPage.UpdataState(localFunction);
                                 break;
                             case SPK.AcStandard:
                             case SPK.HvacAC:
@@ -1299,7 +1451,7 @@
                             case SPK.SensorTemperature:
                             case SPK.SensorHumidity:
                             case SPK.SensorHcho:
-                                if(localFunction.spk == SPK.SensorTemperature)
+                                if (localFunction.spk == SPK.SensorTemperature)
                                 {
                                     HomePage.LoadEvent_RefreshEnvirIndoorTemp();
                                 }
@@ -1310,7 +1462,7 @@
                                 EnvironmentalPage.LoadEvent_UpdataStatus(localFunction);
                                 //A_EnvironmentalDataCenter.LoadEvent_UpdataStatus(localFunction);
                                 break;
-                            case SPK.SensorEnvironment:
+                            case SPK.SensorEnvironment:case SPK.SensorEnvironmentHailin:
                             case SPK.SensorEnvironment2:
                             case SPK.SensorEnvironment3:
                                 if (localFunction.GetAttributes().Contains(FunctionAttributeKey.Temperature))
@@ -1349,12 +1501,14 @@
                             case SPK.SensorGas:
                             case SPK.HvacCac:
                             case SPK.SensorHelp:
+                            case SPK.MechanicalArm:
                                 //璁惧鐘舵�佹帹閫�
                                 //鐘舵�佹洿鏂�
                                 Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(updateTemp.sid, updateTemp.status);
                                 break;
                             case SPK.SenesorMegahealth:
                             case SPK.SenesorMegahealth2:
+                            case SPK.SensorMmvPose:
 
                                 var tempStatus = localFunction.attributes.Find((sta) => sta.key == FunctionAttributeKey.TargetStatus);
                                 if (tempStatus != null)
@@ -1399,8 +1553,16 @@
                             case SPK.AvMusic:
                             case SPK.MusicStandard:
                                 //UI.Music.MusicMain.mMusicMain.RefreshView(updateTemp);
-                                //Console.WriteLine("闊充箰鎾斁鍣ㄦ樉绀虹姸鎬�======="+ revString);
+                                Console.WriteLine("闊充箰鎾斁鍣ㄦ樉绀虹姸鎬�=======" + revString);
                                 //wjc
+                                break;
+                            case SPK.Inverter:
+                            case SPK.InverterRst:
+                                var status = new Dictionary<string, object> { ["method"] = "status", ["data"] = temp.objects };
+                                Application.RunOnMainThread(() =>
+                                {
+                                    Inverter.Ins.H5Page.CallJS($"nativeToJs(\'{Newtonsoft.Json.JsonConvert.SerializeObject(status)}\')");
+                                });
                                 break;
                         }
 
@@ -1425,12 +1587,12 @@
         /// <summary>
         /// //涓�閿紙杩滅▼锛夊紑閿�
         /// </summary>
-        public void OneKeyUnlocking(Function doorlock,string extStr)
+        public void OneKeyUnlocking(Function doorlock, string extStr)
         {
             if (Ins.GatewayOnline_Local)
             {
                 Dictionary<string, string> dic = new Dictionary<string, string>();
-                var functionControlDataObj = doorlock.GetGatewayAlinkDoorlockData(UserInfo.Current.ID,extStr);
+                var functionControlDataObj = doorlock.GetGatewayAlinkDoorlockData(UserInfo.Current.ID, extStr);
                 var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(functionControlDataObj);
                 var sendBytes = Ins.ConvertSendBodyData($"/base/{Control.Ins.GatewayId}/thing/service/doorRemoteOpen/down", functionControlDataJson);
                 new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id, 0);
@@ -1445,7 +1607,7 @@
         /// </summary>
         /// <param name="functionId"></param>
         /// <param name="pwd"></param>
-        public void ConfirmUnlocking(string functionId,string pwd)
+        public void ConfirmUnlocking(string functionId, string pwd)
         {
             Loading loading = new Loading();
             MainPage.BaseView.AddChidren(loading);
@@ -1481,8 +1643,10 @@
                         //{
                         //    return false;
                         //}
-                        if (pack.Code != StateCode.SUCCESS) {
-                            Application.RunOnMainThread(() => {
+                        if (pack.Code != StateCode.SUCCESS)
+                        {
+                            Application.RunOnMainThread(() =>
+                            {
                                 new PublicAssmebly().TipMsg(Language.StringByID(StringId.Tip), pack.message);
                                 UserInfo.Current.doorPasswordString = "";//
                                 UserInfo.Current.LastTimeOpenDoor = DateTime.MinValue;
@@ -1491,8 +1655,9 @@
                     }
                     if (pack.Code != StateCode.SUCCESS)
                     {
-                        Application.RunOnMainThread(() => {
-                            if(string.IsNullOrEmpty(pack.message))
+                        Application.RunOnMainThread(() =>
+                        {
+                            if (string.IsNullOrEmpty(pack.message))
                             {
                                 new PublicAssmebly().TipMsg(Language.StringByID(StringId.Tip),
                                     Language.StringByID(StringId.OperationFailed));

--
Gitblit v1.8.0