1
wei
2021-06-09 cda2410f9c29f2fadc16e9de38ccae95b75a89dd
HDL_ON/DAL/DriverLayer/Control_Udp.cs
@@ -699,46 +699,60 @@
                            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 (function.GetAttrState(FunctionAttributeKey.Mode) == "fan")
                                if (commandDictionary.ContainsKey(FunctionAttributeKey.Mode) == true
                                    && commandDictionary[FunctionAttributeKey.Mode] == "humidification")
                                {
                                    airFreshMode = 2;
                                }
                                //5   节能舒适选择  1 - 舒适,2 - 节能
                                byte airFreshEnergy = 1;
                                 if(   function.GetAttrState(FunctionAttributeKey.Energy)=="true")
                                if (commandDictionary.ContainsKey(FunctionAttributeKey.Energy) == true
                                   && commandDictionary[FunctionAttributeKey.Energy] == "true")
                                {
                                    airFreshEnergy = 2;
                                }
                                //6   风速档位    0 - 自动,1 - 1档,2 - 2档,3 - 3档
                                byte airFreshFan = 0;
                                switch(function.GetAttrState(FunctionAttributeKey.FanSpeed))
                                if (commandDictionary.ContainsKey(FunctionAttributeKey.FanSpeed) == true)
                                {
                                    case "auto":
                                        airFreshFan = 0;
                                        break;
                                    case "level_1":
                                        airFreshFan = 1;
                                        break;
                                    case "level_2":
                                        airFreshFan = 2;
                                        break;
                                    case "level_3":
                                        airFreshFan = 3;
                                        break;
                                    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, function.trait_on_off.curValue.ToString() == "on" ? (byte)1 : (byte)0 ,
                                    function.bus.LoopId,0, switchValue ,
                                    airFreshMode,airFreshEnergy,
                                    airFreshFan,
                                    Convert.ToByte( function.GetAttrState(FunctionAttributeKey.Humidity)),
                                    Convert.ToByte(function.GetAttrState(FunctionAttributeKey.Humidity)),
                                    0,0,0,0
                                    //Convert.ToByte( function.GetAttrState(FunctionAttributeKey.IndoorTemp)),
                                    //Convert.ToByte( function.GetAttrState(FunctionAttributeKey.IndoorHumidity)),
@@ -970,7 +984,7 @@
            try
            {
                //MainPage.Log("发送数据:" + SendFlag);
                MainPage.Log("发送数据:" + SendFlag);
                UdpSocket._BusSocket.AsyncBeginSend(packet);
                packet.HaveSendCount--;
@@ -1093,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)
            {