| | |
| | | SubnetID = subnetID, |
| | | DeviceID = deviceID, |
| | | AddData = gatewayBytes, |
| | | }, 3, true); |
| | | //}, sendCount, reSend); |
| | | //}, 3, true); |
| | | }, sendCount, reSend); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | break; |
| | | } |
| | | ControlBytesSend(Command.SetCurtainModelStutas, f.localFunction.bus.SubnetID, f.localFunction.bus.DeviceID, |
| | | new byte[] { f.localFunction.bus.LoopId, curtainState }); |
| | | new byte[] { f.localFunction.bus.LoopId, curtainState },0); |
| | | break; |
| | | } |
| | | } |
| | | break; |
| | | case SPK.AcStandard: |
| | | case SPK.HvacAC: |
| | | AC acTemp = new AC(); |
| | | byte onoff = 0; |
| | | byte mode = 0; |
| | |
| | | } |
| | | break; |
| | | case SPK.AcStandard: |
| | | case SPK.HvacAC: |
| | | var ac = new AC(); |
| | | foreach (var dic in commandDictionary) |
| | | { |
| | |
| | | } |
| | | } |
| | | //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) |
| | |
| | | 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)), |
| | |
| | | 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: |
| | |
| | | UdpSocket._BusSocket.AsyncBeginSend(packet); |
| | | controlLostCount++; |
| | | } |
| | | System.Threading.Thread.Sleep(300); |
| | | System.Threading.Thread.Sleep(1000); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | /// <summary> |
| | | /// 读取网关IP |
| | | /// </summary> |
| | | public void SearchLocalGateway() |
| | | public void SearchLocalGateway(bool broadcast = false) |
| | | { |
| | | try |
| | | { |
| | |
| | | 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) |
| | |
| | | } |
| | | } |
| | | |
| | | /// <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> |
| | | /// 发送udp A协议数据 |
| | | /// </summary> |
| | | public void SendLocalHdlLinkData(byte[] sendBytes,string id, bool isWait=false) |
| | | public void SendLocalHdlLinkData(byte[] sendBytes,string id, int resend = 3) |
| | | { |
| | | packet = new Packet(sendBytes, new System.Net.IPEndPoint(System.Net.IPAddress.Parse(Control.Ins.reportIp), 8585)); |
| | | packet.HaveSendCount = 3 - resend;//重发次数 |
| | | sendFlag = id; |
| | | System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(managerSendCount)); |
| | | thread.IsBackground = true; |
| | | thread.Start(packet); |
| | | if (isWait) |
| | | { |
| | | wait(); |
| | | } |
| | | //if (isWait) |
| | | //{ |
| | | // wait(); |
| | | //} |
| | | MainPage.Log($"发送Hdl-Link数据,IP:{Control.Ins.reportIp}:8585"); |
| | | } |
| | | } |