From bd428f23e1eb103c19ebbf1f0165f9e2e7b0a9d0 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 09 五月 2023 09:11:18 +0800 Subject: [PATCH] Merge branch 'Dev-Wxr' into Dev-Branch --- HDL_ON/DAL/DriverLayer/Control.cs | 138 ++++++++++++++++++++++++++++++++------------- 1 files changed, 97 insertions(+), 41 deletions(-) diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs index bd951d5..7e94fb4 100644 --- a/HDL_ON/DAL/DriverLayer/Control.cs +++ b/HDL_ON/DAL/DriverLayer/Control.cs @@ -138,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}"); } } } @@ -457,7 +463,6 @@ UpdataFunctionStatus(revString, null, true); return true; } - //MainPage.Log($"鍙戦�佹暟鎹�:{Newtonsoft.Json.JsonConvert.SerializeObject(commandDictionary)}"); @@ -1082,7 +1087,8 @@ } } 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)) { @@ -1175,11 +1181,62 @@ } + /// <summary> /// 鏇存柊璁惧鐘舵�� /// A鍗忚鏁版嵁 /// </summary> - /// <param name="updateBytes"></param> + 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 浜戠杩炴帴鎴愬姛鏃讹紝涓嶉�傜敤鏈湴鏁版嵁鏇存柊 @@ -1231,21 +1288,20 @@ } } - if (SPK.MusicSpkList().Contains(localFunction.spk)) - { - MainPage.Log($"闊充箰鏀跺埌鏁版嵁:{revString}"); - - } + //if (SPK.MusicSpkList().Contains(localFunction.spk)) + //{ + // if (updateTemp.status.Count < 3) + // { + // ///鏄煶涔愬姛鑳界殑 + // ///涓婃姤灞炴�у皯3鏉′笉鍋氬鐞� + // return; + // } + //} + MainPage.Log($"鏀跺埌鏁版嵁:{revString}"); foreach (var attr in updateTemp.status) { localFunction.time_stamp = temp.time_stamp; localFunction.SetAttrState(attr.key, attr.value); - if (SPK.MusicSpkList().Contains(localFunction.spk)) - { - Console.WriteLine("闊充箰鎾斁鍣ㄦ坊鍔犵紦瀛樻暟鎹�=======" + revString); - - } - } -- Gitblit v1.8.0