From 0a11352dffeb8d5f31dd40b9728fe1abf4537f04 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期五, 01 九月 2023 18:06:45 +0800 Subject: [PATCH] 2023年09月01日18:06:42 --- HDL_ON/DAL/DriverLayer/Control.cs | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 50 insertions(+), 9 deletions(-) diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs index ce113f2..85737d2 100644 --- a/HDL_ON/DAL/DriverLayer/Control.cs +++ b/HDL_ON/DAL/DriverLayer/Control.cs @@ -1,6 +1,7 @@ 锘縰sing System; using System.Collections.Generic; using System.Text; +using HDL_ON.DAL.Mqtt; using HDL_ON.DAL.Server; using HDL_ON.Entity; using HDL_ON.UI; @@ -124,6 +125,10 @@ HomePage.LoadEvent_CheckLinkStatus(); } } + else + { + MainPage.Log($"鐘舵�佷竴鑷达紝涓嶆洿鏂版暟鎹�(鏈湴)"); + } } } bool _GatewayOnline_Cloud = false; @@ -169,7 +174,16 @@ MainPage.Log($"缃戝叧浜戠鍦ㄧ嚎锛屽埛鏂拌澶囩姸鎬�"); new System.Threading.Thread(() => { - System.Threading.Thread.Sleep(1000); + int count = 20; + while (true) + { + System.Threading.Thread.Sleep(500); + if (MqttClient.isSubscribeSuccess || count<1) + { + break; + } + count--; + } FunctionList.List.ReadAllFunctionStatus(); }) { IsBackground = true, Priority = System.Threading.ThreadPriority.AboveNormal }.Start(); @@ -179,6 +193,10 @@ //淇敼涓婚〉杩炴帴鐘舵�� HomePage.LoadEvent_CheckLinkStatus(); } + } + else + { + MainPage.Log($"鐘舵�佷竴鑷达紝涓嶆洿鏂版暟鎹�(浜戠)"); } }catch(Exception ex) { @@ -243,6 +261,7 @@ /// </summary> public void OpenTcpClent() { + return; if (myTcpClient == null) { myTcpClient = new Control_TcpClient(reportIp); @@ -277,6 +296,7 @@ } else if (MainPage.InternetStatus == 2) { + DAL.Mqtt.MqttClient.InitState(); OpenUdp(DB_ResidenceData.Instance.GatewayType == 0 ? 6000 : 8585); //閲嶇疆鎼滅储缃戝叧鏍囧織 IsSearchLocalGatewaySuccessful = false; @@ -303,7 +323,6 @@ System.Threading.Thread.Sleep(500); } - DAL.Mqtt.MqttClient.InitState(); }) { IsBackground = true }.Start(); } @@ -317,6 +336,7 @@ /// </summary> public void LoginGateway() { + return;//tcp鎺у埗瀛樺湪闂锛屼絾鏄厛涓嶇敤tcp鎺у埗浜嗭紝瑕佺粡杩囨祴璇曞厛 2023-07-29 10:14:32 if (loginGatewayThread == null) { loginGatewayThread = new System.Threading.Thread(() => @@ -516,6 +536,7 @@ var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlFunctionTopic, functionControlDataJson); new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id, resend); MainPage.Log($"鏈湴閫氳 鍙戦�丠DL-Link鏁版嵁:{functionControlDataJson}"); + //Ins.myTcpClient.SendMessage(sendBytes); } } //杩滅▼閫氳 @@ -605,6 +626,10 @@ { foreach (var temp in functions) { + if((temp.trait_on_off.state.ToString() == "on" && open)|| temp.trait_on_off.state.ToString() == "off"&& !open) + { + continue; + } var apiControlData = temp.GetApiControlData(d); actionObjs.Add(apiControlData); count++; @@ -616,7 +641,10 @@ System.Threading.Thread.Sleep(100); } } - var pack = pm.ControlDevice(actionObjs); + if (actionObjs.Count > 0) + { + var pack = pm.ControlDevice(actionObjs); + } } } @@ -842,7 +870,7 @@ }, time_stamp = Utlis.GetTimestamp() }; - var aLinkJson = Newtonsoft.Json.JsonConvert.SerializeObject(aLinkData); + var aLinkJson = JsonConvert.SerializeObject(aLinkData); var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlScene, aLinkJson); new Control_Udp().SendLocalHdlLinkData(sendBytes, aLinkData.id, 0); } @@ -940,6 +968,10 @@ /// <returns></returns> public void ConvertReceiveData(byte[] receiveBytes, string ip) { + if (!UserInfo.Current.IsLogin) + { + return; + } var reString = Encoding.UTF8.GetString(receiveBytes); AnalysisReceiveData(reString, receiveBytes, ip); } @@ -951,6 +983,7 @@ /// <returns></returns> public LocalCommunicationData AnalysisReceiveData(string receiveString, byte[] originalReceiveBytes, string sIp = null) { + LocalCommunicationData receiveObj = new LocalCommunicationData(); @@ -986,7 +1019,7 @@ if (receiveObj.Topic == CommunicationTopic.ct.HeartBeat + "_reply") { - Ins.myTcpClient.ClearHeartBeatLog(); + //Ins.myTcpClient.ClearHeartBeatLog(); MainPage.Log("tcp蹇冭烦鍥炲"); return null; } @@ -1082,7 +1115,7 @@ Ins.IsLocalEncrypt = device.isLocalEncrypt; //MainPage.Log("缃戝叧鏈湴鍔犲瘑鐘舵�侊細" + device.local_encrypt.ToString()); //鐧诲綍缃戝叧Tcp - OpenTcpClent(); + //OpenTcpClent(); } @@ -1184,7 +1217,7 @@ /// <summary> - /// 鏇存柊璁惧鐘舵�� + /// 鏇存柊缇ゆ帶璁惧鐘舵�� /// A鍗忚鏁版嵁 /// </summary> public void UpdataGroupControlStatus(string revString, byte[] usefulBytes, bool isCloudData = false) @@ -1246,7 +1279,7 @@ // return; //} - var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<AlinkFunctionStatusObj>(revString); + var temp = JsonConvert.DeserializeObject<AlinkFunctionStatusObj>(revString); if (temp != null) { Control_Udp.ReceiveRepeatManager(temp.id, usefulBytes); @@ -1303,7 +1336,11 @@ { localFunction.time_stamp = temp.time_stamp; localFunction.SetAttrState(attr.key, attr.value); - + + } + if(localFunction.spk == SPK.AirSwitchP3) + { + localFunction.online = updateTemp.online; } //鏇存柊鐣岄潰鐘舵�� @@ -1323,6 +1360,10 @@ EnergyMainPage.UpdataStatus(localFunction); } break; + case SPK.AirSwitchP3: + AirSwitchP3Page.UpdataState(localFunction); + AirSwitchP3SubloopEnergyPage.UpdataStatus(localFunction); + break; case SPK.ElectricEnergy: EnergyMainPage.UpdataStatus(localFunction); break; -- Gitblit v1.8.0