wxr
2022-07-19 bb4bcd1b320502b36d19aacec52ed886a975249a
HDL_ON/DAL/DriverLayer/Control_Udp.cs
@@ -262,12 +262,17 @@
                                                break;
                                        }
                                        break;
                                    case FunctionAttributeKey.SetTemp:
                                        ControlBytesSend(Command.InstructionPanelKey, f.localFunction.bus.SubnetID, f.localFunction.bus.DeviceID, new byte[] {
                                                modeKey, Convert.ToByte(attr.value), f.localFunction.bus.LoopId });
                                        break;
                                }
                                ControlBytesSend(Command.InstructionPanelKey, f.localFunction.bus.SubnetID, f.localFunction.bus.DeviceID, new byte[] { 3, onoff, f.localFunction.bus.LoopId });
                                ControlBytesSend(Command.InstructionPanelKey, f.localFunction.bus.SubnetID, f.localFunction.bus.DeviceID, new byte[] { 6, mode, f.localFunction.bus.LoopId });
                                ControlBytesSend(Command.InstructionPanelKey, f.localFunction.bus.SubnetID, f.localFunction.bus.DeviceID, new byte[] { 5, fan, f.localFunction.bus.LoopId });
                                ControlBytesSend(Command.InstructionPanelKey, f.localFunction.bus.SubnetID, f.localFunction.bus.DeviceID, new byte[] { modeKey, modeKey, f.localFunction.bus.LoopId });
                            }
                    }
                            break;
                        case SPK.LightSwitch:
                        case SPK.LightDimming:
@@ -554,47 +559,129 @@
                    case SPK.AcStandard:
                    case SPK.HvacAC:
                        var ac = new AC();
                        byte onoff = 0;
                        onoff = function.trait_on_off.curValue.ToString() == "on" ? (byte)1 : (byte)0;
                        byte mode = 0;
                        mode = ac.GetModeIndex(function);
                        byte fan = 0;
                        fan = ac.GetFanIndex(function);
                        byte sanfan = 0;
                        byte temp = 16;
                        temp = Convert.ToByte(function.GetAttrState(FunctionAttributeKey.SetTemp));
                        foreach (var dic in commandDictionary)
                        {
                            switch (dic.Key)
                            {
                                case FunctionAttributeKey.OnOff:
                                    ControlBytesSend(Command.InstructionPanelKey, function.bus.SubnetID, function.bus.DeviceID, new byte[] { 3, function.trait_on_off.curValue.ToString() == "on" ? (byte)1 : (byte)0, function.bus.LoopId });
                                    onoff = dic.Value == "on" ? (byte)1 : (byte)0;
                                    //ControlBytesSend(Command.InstructionPanelKey, function.bus.SubnetID, function.bus.DeviceID,
                                    //    new byte[] { 3, onoff, function.bus.LoopId });
                                    break;
                                case "mode":
                                    ControlBytesSend(Command.InstructionPanelKey, function.bus.SubnetID, function.bus.DeviceID, new byte[] { 6, ac.GetModeIndex(function), function.bus.LoopId });
                                    break;
                                case "fan":
                                    ControlBytesSend(Command.InstructionPanelKey, function.bus.SubnetID, function.bus.DeviceID, new byte[] { 5, ac.GetFanIndex(function), function.bus.LoopId });
                                    break;
                                case FunctionAttributeKey.SetTemp:
                                    byte modeKey = 4;
                                    switch (ac.GetModeIndex(function))
                                    switch (dic.Value)
                                    {
                                        case 3:
                                            modeKey = 8;
                                        case "auto":
                                            mode = 3;
                                            break;
                                        case 0:
                                            modeKey = 4;
                                        case "cool":
                                            mode = 0;
                                            break;
                                        case 1:
                                            modeKey = 7;
                                        case "heat":
                                            mode = 1;
                                            break;
                                        case 4:
                                            modeKey = 19;
                                        case "dry":
                                            mode = 4;
                                            break;
                                        case 2:
                                            modeKey = 2;
                                        case "fan":
                                            mode = 2;
                                            break;
                                        default:
                                            mode = 0;
                                            break;
                                    }
                                    ControlBytesSend(Command.InstructionPanelKey, function.bus.SubnetID, function.bus.DeviceID, new byte[] {
                                                modeKey, Convert.ToByte(function.GetAttrState(FunctionAttributeKey.SetTemp)), function.bus.LoopId });
                                    //ControlBytesSend(Command.InstructionPanelKey, function.bus.SubnetID, function.bus.DeviceID,
                                    //    new byte[] { 6, mode, function.bus.LoopId });
                                    break;
                                case "fan":
                                    switch (dic.Value)
                                    {
                                        case "high":
                                            fan = 1;
                                            break;
                                        case "medium":
                                            fan = 2;
                                            break;
                                        case "low":
                                            fan = 3;
                                            break;
                                        case "auto":
                                            fan = 0;
                                            break;
                                        default:
                                            fan = 0;
                                            break;
                                    }
                                    //ControlBytesSend(Command.InstructionPanelKey, function.bus.SubnetID, function.bus.DeviceID,
                                    //    new byte[] { 5, fan, function.bus.LoopId });
                                    break;
                                case FunctionAttributeKey.SetTemp:
                                    try
                                    {
                                        temp = Convert.ToByte(dic.Value);
                                    }
                                    catch
                                    {
                                        temp = 16;
                                    }
                                    //byte modeKey = 4;
                                    //switch (ac.GetModeIndex(function))
                                    //{
                                    //    case 3:
                                    //        modeKey = 8;
                                    //        break;
                                    //    case 0:
                                    //        modeKey = 4;
                                    //        break;
                                    //    case 1:
                                    //        modeKey = 7;
                                    //        break;
                                    //    case 4:
                                    //        modeKey = 19;
                                    //        break;
                                    //    case 2:
                                    //        modeKey = 2;
                                    //        break;
                                    //}
                                    //ControlBytesSend(Command.InstructionPanelKey, function.bus.SubnetID, function.bus.DeviceID, new byte[] {
                                    //            modeKey, temp, function.bus.LoopId });
                                    break;
                                case FunctionAttributeKey.Swing:
                                    //sanfan
                                    break;
                                default:
                                    MainPage.Log($"功能未支持 : {dic.Key}");
                                    break;
                            }
                        }
                        /// 设置空调模块命令
                        /// 1空调号(1-128)
                        ///2温度模式(摄氏Celsius:0,华氏Fahrenheit:1)
                        ///3环境温度 (摄氏0-40,华氏32-99)
                        ///4制冷控制温度(摄氏0-30,华氏32-86)
                        ///5制热控制温度(摄氏0-30,华氏32-86)
                        ///6自动控制温度(摄氏0-30,华氏32-86)
                        ///7除湿控制温度(摄氏0-30,华氏32-86)
                        ///8椒缢偈导使ぷ髯此?  高4bit模式(0 制冷,1制热,2通风)  低4bit风速(0 自动,1高风?风,3低风)
                        ///9空调开关                 (1开0关)
                        ///10设置模式               0 制冷1制热,2通风,3自动,4除湿
                        ///11设置风速                0 自动,1高风2中风,3低风
                        ///12工作模控制温肚掮摄氏0-30,华氏32-86)
                        ///13扫风模式:高4bit(实际扫风状态:0不扫风,1扫风),低4bit(设置扫风模式:0不扫风,1扫风)
                        ControlBytesSend(Command.SetACMode, function.bus.SubnetID, function.bus.DeviceID, new byte[] { function.bus.LoopId,
                        0,0,0,0,0,0,0,onoff,mode,fan,temp,sanfan});
                        break;
                    case SPK.HvacFloorHeat:case SPK.FloorHeatStandard:
                        var fhTemp = new FloorHeating();
@@ -656,8 +743,8 @@
                                    var dicTempString = "";
                                    commandDictionary.TryGetValue("set_temp", out dicTempString);
                                    var dicTemp = Convert.ToByte(dicTempString);
                                    var mode = function.GetAttrState(FunctionAttributeKey.Mode);
                                    switch (mode)
                                    var mode22 = function.GetAttrState(FunctionAttributeKey.Mode);
                                    switch (mode22)
                                    {
                                        case "day":
                                            function.Fh_Mode_Temp["day"] = dicTemp;