From 270b3d8539f6b4a991a9ebf3b3a9eceb436d61d5 Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期四, 28 十月 2021 17:08:02 +0800 Subject: [PATCH] 自动化地址问题修复 --- HDL_ON/DAL/DriverLayer/Control_Udp.cs | 56 +++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 41 insertions(+), 15 deletions(-) diff --git a/HDL_ON/DAL/DriverLayer/Control_Udp.cs b/HDL_ON/DAL/DriverLayer/Control_Udp.cs index 2179b3d..5f929c0 100644 --- a/HDL_ON/DAL/DriverLayer/Control_Udp.cs +++ b/HDL_ON/DAL/DriverLayer/Control_Udp.cs @@ -198,6 +198,7 @@ } break; case SPK.AcStandard: + case SPK.HvacAC: AC acTemp = new AC(); byte onoff = 0; byte mode = 0; @@ -552,6 +553,7 @@ } break; case SPK.AcStandard: + case SPK.HvacAC: var ac = new AC(); foreach (var dic in commandDictionary) { @@ -742,6 +744,11 @@ } } //7 婀垮害璁惧畾 % + byte hum = 0; + if (commandDictionary.ContainsKey(FunctionAttributeKey.Humidity) == true) + { + hum = Convert.ToByte(commandDictionary[FunctionAttributeKey.Humidity]); + } //8 瀹ゅ唴娓╁害鍊� 鈩� byte indoorTemp_airFrsh = 0; if (commandDictionary.ContainsKey(FunctionAttributeKey.IndoorTemp) == true) @@ -760,7 +767,7 @@ function.bus.LoopId,0, switchValue , airFreshMode,airFreshEnergy, airFreshFan, - Convert.ToByte(function.GetAttrState(FunctionAttributeKey.Humidity)), + hum, indoorTemp_airFrsh, indoorHumidity_airFrsh, //Convert.ToByte( function.GetAttrState(FunctionAttributeKey.FilterRemain)), @@ -812,6 +819,7 @@ ControlBytesSend(Command.ReadCurtainStatus, subnetId, deviceId, new byte[] { function.bus.LoopId }); break; case SPK.AcStandard: + case SPK.HvacAC: ControlBytesSend(Command.ReadACMode, subnetId, deviceId, new byte[] { function.bus.LoopId }); break; case SPK.HvacFloorHeat:case SPK.FloorHeatStandard: @@ -970,7 +978,7 @@ UdpSocket._BusSocket.AsyncBeginSend(packet); controlLostCount++; } - System.Threading.Thread.Sleep(300); + System.Threading.Thread.Sleep(1000); } } catch (Exception ex) @@ -1070,7 +1078,7 @@ /// <summary> /// 璇诲彇缃戝叧IP /// </summary> - public void SearchLocalGateway() + public void SearchLocalGateway(bool broadcast = false) { try { @@ -1078,23 +1086,21 @@ var bodyString = JsonConvert.SerializeObject(sendJob); var sendBytes = Control.Ins.ConvertSendBodyData(CommunicationTopic.SearchLoaclGateway, bodyString, false); - //缁勬挱鍙戦�� - packet = new Packet(sendBytes, new System.Net.IPEndPoint(System.Net.IPAddress.Parse("239.0.168.188"), 8585)); + if (broadcast) + { + //骞挎挱 + packet = new Packet(sendBytes, new System.Net.IPEndPoint(System.Net.IPAddress.Parse("255.255.255.255"), 8585)); + } + else + { + //缁勬挱鍙戦�� + packet = new Packet(sendBytes, new System.Net.IPEndPoint(System.Net.IPAddress.Parse("239.0.168.188"), 8585)); + } packet.HaveSendCount = 4; System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(managerSendCount)); thread.IsBackground = true; thread.Start(packet); //wait();涓嶉渶瑕佺瓑寰� - - - - - //hjSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - //hjSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); - //EndPoint ipep = new IPEndPoint(IPAddress.Parse(CsConst.myLocalIP), HDLUDP.UDPPort); - //hjSocket.Bind(ipep); - - } catch (Exception ex) @@ -1103,6 +1109,26 @@ } } + /// <summary> + /// 璇诲彇缃戝叧IP + /// </summary> + public void SendLinkCommand(string topic,string bodyString) + { + try + { + var sendBytes = Control.Ins.ConvertSendBodyData(topic, bodyString, false); + //缁勬挱鍙戦�� + packet = new Packet(sendBytes, new System.Net.IPEndPoint(System.Net.IPAddress.Parse("239.0.168.188"), 8585)); + packet.HaveSendCount = 4; + System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(managerSendCount)); + thread.IsBackground = true; + thread.Start(packet); + } + catch (Exception ex) + { + MainPage.Log($"Send bus data error {ex.Message}"); + } + } /// <summary> /// 鍙戦�乽dp A鍗忚鏁版嵁 -- Gitblit v1.8.0