From 014abc547ffd1a9f23c58fd7a471dffc5933fdd3 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期四, 17 十二月 2020 14:27:56 +0800 Subject: [PATCH] Merge branch 'master' into NewFilePath --- HDL_ON/DAL/DriverLayer/Control.cs | 53 +++++++++++++++++++++++------------------------------ 1 files changed, 23 insertions(+), 30 deletions(-) diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs index 4c86695..dcd5410 100644 --- a/HDL_ON/DAL/DriverLayer/Control.cs +++ b/HDL_ON/DAL/DriverLayer/Control.cs @@ -123,7 +123,7 @@ /// <summary> /// 鏈湴udp /// </summary> - public Control_Udp myUdp = null; + public Control_Udp myUdp1 = null; /// <summary> /// 閫氳鏂瑰紡 @@ -144,11 +144,6 @@ /// </summary> public void OpenUdp(int port) { - if (myUdp == null) - { - myUdp = new Control_Udp(); - } - UdpSocket._BusSocket.Start(port); } /// <summary> @@ -156,10 +151,6 @@ /// </summary> public void CloseUdp() { - if (myUdp != null) - { - myUdp = null; - } UdpSocket._BusSocket.Stop(); } @@ -197,11 +188,11 @@ break; if (DB_ResidenceData.Instance.GatewayType == 0) { - myUdp.ControlBytesSend(Command.ReadGateway, 255, 255, new byte[] { (byte)new Random().Next(255), (byte)new Random().Next(255) }); + new Control_Udp().ControlBytesSend(Command.ReadGateway, 255, 255, new byte[] { (byte)new Random().Next(255), (byte)new Random().Next(255) }); } else if (DB_ResidenceData.Instance.GatewayType == 1) { - myUdp.SearchLocalGateway(); + new Control_Udp().SearchLocalGateway(); } System.Threading.Thread.Sleep(500); } @@ -227,7 +218,7 @@ { if (DB_ResidenceData.Instance.GatewayType == 0) { - myUdp.ControlBusScenes(scene); + new Control_Udp().ControlBusScenes(scene); } } } @@ -244,10 +235,11 @@ { function.usageCount++; function.refreshTime = DateTime.Now; - DAL.Server.HttpServerRequest httpServer = new DAL.Server.HttpServerRequest(); + //杩滅▼閫氳 if (Ins.IsRemote) { + DAL.Server.HttpServerRequest httpServer = new DAL.Server.HttpServerRequest(); //ALink鎺у埗銆丅us鎺у埗浣跨敤鍚屼竴涓帴鍙f帶鍒讹紝鐢变簯绔礋璐hВ鏋� var apiControlData = function.GetApiControlData(commandDictionary); var actionObjs = new List<ApiAlinkControlActionObj>(); @@ -263,10 +255,7 @@ { try { - if (myUdp != null) - { - myUdp.WriteBusData(function, commandDictionary); - } + new Control_Udp().WriteBusData(function, commandDictionary); } catch (Exception ex) { @@ -276,13 +265,10 @@ //ALink鎺у埗 else { - if (myUdp != null) - { - var functionControlDataObj = function.GetGatewayAlinkControlData(commandDictionary); - var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(functionControlDataObj); - var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlFunctionTopic, functionControlDataJson); - Ins.myUdp.SendLocalHdlLinkData(sendBytes); - } + 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); } } } @@ -311,7 +297,7 @@ { try { - Ins.myUdp.ReadBusData(function); + new Control_Udp().ReadBusData(function); } catch (Exception ex) { @@ -334,7 +320,7 @@ }; var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(readDataObj); var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ReadStatus, functionControlDataJson); - Ins.myUdp.SendLocalHdlLinkData(sendBytes); + new Control_Udp().SendLocalHdlLinkData(sendBytes,readDataObj.id); } } } @@ -380,7 +366,7 @@ }; var aLinkJson = Newtonsoft.Json.JsonConvert.SerializeObject(aLinkData); var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlScene, aLinkJson); - Ins.myUdp.SendLocalHdlLinkData(sendBytes); + new Control_Udp().SendLocalHdlLinkData(sendBytes,aLinkData.id); } } /// <summary> @@ -468,7 +454,8 @@ else if(receiveObj.Topic == CommunicationTopic.ct.ReadStatus+"_reply" || receiveObj.Topic == CommunicationTopic.ct.GatewayUpStatus) { - UpdataFunctionStatus(receiveObj.BodyDataString); + //TODO 鏆傛椂涓嶄紶姝g‘鐨勬暟鎹笂鍘伙紝濡傛灉鍚庨潰瑕佷紭鍖栧墠闈㈣繖浜涗唬鐮� + UpdataFunctionStatus(receiveObj.BodyDataString,null); } } return receiveObj; @@ -479,12 +466,18 @@ /// A鍗忚鏁版嵁 /// </summary> /// <param name="updateBytes"></param> - public void UpdataFunctionStatus(string revString) + public void UpdataFunctionStatus(string revString,byte []usefulBytes) { MainPage.Log($"A鍗忚鏇存柊鐘舵��:{revString}"); + if(Control.Ins.myUdp!= null) + { + //閲嶇疆閲嶅惎udp鍒ゆ柇璋冩暣 + Ins.myUdp.controlLostCount = 0; + } var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<AlinkFunctionStatusObj>(revString); if (temp != null) { + Control_Udp.ReceiveRepeatManager(temp.id,usefulBytes); var allLocalFuntion = FunctionList.List.GetDeviceFunctionList(); foreach (var updateTemp in temp.objects) { -- Gitblit v1.8.0