wei
2021-06-02 e13a9980ce617db1394a76944186c5d5bd595d5d
HDL_ON/DAL/DriverLayer/Control_Udp.cs
@@ -694,7 +694,73 @@
                        }
                        break;
                    case FunctionCategory.AirFresh:
                        switch(function.spk)
                        {
                            case SPK.AirFreshJinmao:
                                //1   新风编号    1~200
                                //2   类型 第三方类型  0:金茂新风
                                //3   开关  0 - 关机,1 - 开机
                                byte switchValue = 0;
                                if (commandDictionary.ContainsKey(FunctionAttributeKey.OnOff) == true
                                    && commandDictionary[FunctionAttributeKey.OnOff] == "on")
                                {
                                    switchValue = 1;
                                }
                                //4   运行模式    1 - 通风,2 - 加湿
                                byte airFreshMode = 1;
                                if (commandDictionary.ContainsKey(FunctionAttributeKey.Mode) == true
                                    && commandDictionary[FunctionAttributeKey.Mode] == "humidification")
                                {
                                    airFreshMode = 2;
                                }
                                //5   节能舒适选择  1 - 舒适,2 - 节能
                                byte airFreshEnergy = 1;
                                if (commandDictionary.ContainsKey(FunctionAttributeKey.Energy) == true
                                   && commandDictionary[FunctionAttributeKey.Energy] == "true")
                                {
                                    airFreshEnergy = 2;
                                }
                                //6   风速档位    0 - 自动,1 - 1档,2 - 2档,3 - 3档
                                byte airFreshFan = 0;
                                if (commandDictionary.ContainsKey(FunctionAttributeKey.FanSpeed) == true)
                                {
                                    switch (commandDictionary[FunctionAttributeKey.FanSpeed])
                                    {
                                        case "auto":
                                            airFreshFan = 0;
                                            break;
                                        case "level_1":
                                            airFreshFan = 1;
                                            break;
                                        case "level_2":
                                            airFreshFan = 2;
                                            break;
                                        case "level_3":
                                            airFreshFan = 3;
                                            break;
                                    }
                                }
                                //7   湿度设定 %
                                //8   室内温度值   ℃
                                //9   室内湿度值   ℃
                                //10  过滤网剩余 %
                                //11  过滤网使用超时 1 超时 0 无
                                ControlBytesSend(Command.FreshAirControl_JinMao, subnetId, deviceId, new byte[] {
                                    function.bus.LoopId,0, switchValue ,
                                    airFreshMode,airFreshEnergy,
                                    airFreshFan,
                                    Convert.ToByte(function.GetAttrState(FunctionAttributeKey.Humidity)),
                                    0,0,0,0
                                    //Convert.ToByte( function.GetAttrState(FunctionAttributeKey.IndoorTemp)),
                                    //Convert.ToByte( function.GetAttrState(FunctionAttributeKey.IndoorHumidity)),
                                    //Convert.ToByte( function.GetAttrState(FunctionAttributeKey.FilterRemain)),
                                    //function.GetAttrState(FunctionAttributeKey.FilterTimeout) =="true"?1:0,
                                });
                                break;
                        }
                        break;
                }
                #region 发送命令立即更新UI
@@ -796,6 +862,14 @@
                                break;
                        }
                        ControlBytesSend(Command.ReadDeviceLoopInfo, subnetId, deviceId, new byte[] { 5, sensorType, function.bus.LoopId });
                        break;
                    case FunctionCategory.AirFresh:
                        switch(function.spk)
                        {
                            case SPK.AirFreshJinmao:
                                ControlBytesSend(Command.FreshAirRead_JinMao, subnetId, deviceId, new byte[] { function.bus.LoopId });
                                break;
                        }
                        break;
                }
            }
@@ -910,7 +984,7 @@
            try
            {
                //MainPage.Log("发送数据:" + SendFlag);
                MainPage.Log("发送数据:" + SendFlag);
                UdpSocket._BusSocket.AsyncBeginSend(packet);
                packet.HaveSendCount--;
@@ -1033,11 +1107,22 @@
                var sendBytes = Control.Ins.ConvertSendBodyData(CommunicationTopic.SearchLoaclGateway, bodyString);
                //组播发送
                packet = new Packet(sendBytes, new System.Net.IPEndPoint(System.Net.IPAddress.Parse("239.0.168.188"), 8585));
                packet.HaveSendCount = 4;//ps:没有重发,后期有时间可以增加重发判断
                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)
            {