wei
2021-07-05 992cc7d4433f8f9e9b0a930ec095973e056abe1c
HDL_ON/DAL/DriverLayer/Packet.cs
@@ -97,7 +97,8 @@
                {
                    ddd += bb + ",";
                }
                MainPage.Log(ddd);
                MainPage.Log($"bus命令:" + ((int)command).ToString("X").PadLeft(4, '0') + " : 数据:" + ddd);
                //MainPage.Log($"bus命令:"+ ((int)command) + " : 数据:" + ddd);
#endif
                //处理是否要重发数据
                ManagerReceive(subnetID, deviceID, command, usefulBytes);
@@ -227,25 +228,40 @@
                        break;
                    case Command.SetLogicLoopColorACK:
                    case Command.ReadLogicLoopColorACK:
                        foreach (var rgb in FunctionList.List.GetLightList())
                        foreach (var lightTeme in FunctionList.List.GetLightList())
                        {
                            if (rgb.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
                            if (lightTeme.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
                            {
                                if (rgb.spk == SPK.LightRGB)
                                if (lightTeme.spk == SPK.LightRGB)
                                {
                                    rgb.trait_on_off.curValue = receiveBytes[1] > 0 ? "on" : "off";
                                    lightTeme.trait_on_off.curValue = receiveBytes[1] > 0 ? "on" : "off";
                                    if (receiveBytes[1] > 0)
                                    {
                                        rgb.SetAttrState(FunctionAttributeKey.Brightness, receiveBytes[1].ToString());
                                        rgb.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[1] + "%";
                                        lightTeme.SetAttrState(FunctionAttributeKey.Brightness, receiveBytes[1].ToString());
                                        lightTeme.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[1] + "%";
                                    }
                                    new Light().SetRGBcolor(new byte[] { receiveBytes[6], receiveBytes[7], receiveBytes[8] }, rgb);
                                    new Light().SetRGBcolor(new byte[] { receiveBytes[6], receiveBytes[7], receiveBytes[8] }, lightTeme);
                                    HomePage.UpdataFunctionStates(rgb);
                                    RoomPage.UpdataStates(rgb);
                                    FunctionPage.UpdataStates(rgb);
                                    ClassificationPage.UpdataInfo(rgb);
                                    RGBPage.UpdataStates(rgb);
                                    HomePage.UpdataFunctionStates(lightTeme);
                                    RoomPage.UpdataStates(lightTeme);
                                    FunctionPage.UpdataStates(lightTeme);
                                    ClassificationPage.UpdataInfo(lightTeme);
                                    RGBPage.UpdataStates(lightTeme);
                                }else if(lightTeme.spk == SPK.LightCCT)
                                {
                                    lightTeme.trait_on_off.curValue = receiveBytes[1] > 0 ? "on" : "off";
                                    if (receiveBytes[1] > 0)
                                    {
                                        lightTeme.SetAttrState(FunctionAttributeKey.Brightness, receiveBytes[1].ToString());
                                        lightTeme.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[1] + "%";
                                    }
                                    new Light().SetCCT(new byte[] { receiveBytes[6], receiveBytes[7] }, lightTeme);
                                    HomePage.UpdataFunctionStates(lightTeme);
                                    RoomPage.UpdataStates(lightTeme);
                                    FunctionPage.UpdataStates(lightTeme);
                                    ClassificationPage.UpdataInfo(lightTeme);
                                    ColorTureLampPage.UpdataStatus(lightTeme);
                                }
                            }
                        }
@@ -405,38 +421,44 @@
                                {
                                    function.Fh_Mode_Temp.Add("away", receiveBytes[7]);
                                }
                                switch (function.GetAttrState(FunctionAttributeKey.Mode))
                                if (function.GetAttribute(FunctionAttributeKey.Mode) == null)
                                {
                                    case "normal":
                                        function.lastState = Language.StringByID(StringId.Normal);
                                        function.SetAttrState(FunctionAttributeKey.SetTemp,receiveBytes[4].ToString());
                                        break;
                                    case "day":
                                        function.lastState = Language.StringByID(StringId.Day);
                                        function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[5].ToString());
                                        break;
                                    case "night":
                                        function.lastState = Language.StringByID(StringId.Night);
                                        function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[6].ToString());
                                        break;
                                    case "timer":
                                        function.lastState = Language.StringByID(StringId.Auto);
                                        if (receiveBytes[8] == 0)
                                        {
                                            function.SetAttrState(FunctionAttributeKey.TimeFlag, 0);
                                    function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[4].ToString());
                                }
                                else
                                {
                                    switch (function.GetAttrState(FunctionAttributeKey.Mode))
                                    {
                                        case "normal":
                                            function.lastState = Language.StringByID(StringId.Normal);
                                            function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[4].ToString());
                                            break;
                                        case "day":
                                            function.lastState = Language.StringByID(StringId.Day);
                                            function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[5].ToString());
                                        }
                                        else
                                        {
                                            function.SetAttrState(FunctionAttributeKey.TimeFlag, 1);
                                            break;
                                        case "night":
                                            function.lastState = Language.StringByID(StringId.Night);
                                            function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[6].ToString());
                                        }
                                        break;
                                    case "away":
                                        function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[7].ToString());
                                        function.lastState = Language.StringByID(StringId.Away);
                                        break;
                                            break;
                                        case "timer":
                                            function.lastState = Language.StringByID(StringId.Auto);
                                            if (receiveBytes[8] == 0)
                                            {
                                                function.SetAttrState(FunctionAttributeKey.TimeFlag, 0);
                                                function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[5].ToString());
                                            }
                                            else
                                            {
                                                function.SetAttrState(FunctionAttributeKey.TimeFlag, 1);
                                                function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[6].ToString());
                                            }
                                            break;
                                        case "away":
                                            function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[7].ToString());
                                            function.lastState = Language.StringByID(StringId.Away);
                                            break;
                                    }
                                }
                                var indoorTemp = 0;
                                if (receiveBytes[9] > 128)
@@ -448,7 +470,14 @@
                                }
                                function.SetAttrState(FunctionAttributeKey.RoomTemp, indoorTemp);
                                function.lastState += " " + function.GetAttrState(FunctionAttributeKey.Mode) + new FloorHeating().GetTempUnitString(function);
                                if (function.GetAttribute(FunctionAttributeKey.Mode) == null)
                                {
                                    function.lastState = "";
                                }
                                else
                                {
                                    function.lastState += " " + function.GetAttrState(FunctionAttributeKey.Mode) + new FloorHeating().GetTempUnitString(function);
                                }
                                RoomPage.UpdataStates(function);
                                FunctionPage.UpdataStates(function);
                                HomePage.UpdataFunctionStates(function);
@@ -653,8 +682,8 @@
                            /// 10   过滤网剩余   %
                            /// 11   过滤网使用超时   1 超时 0 无 true/false
                            airFresh.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[2] == 0 ? "off" : "on");
                            airFresh.SetAttrState(FunctionAttributeKey.Mode, receiveBytes[3] == 1 ? "humidification" : "fan");
                            airFresh.SetAttrState(FunctionAttributeKey.Energy, receiveBytes[4] == 1 ? "true" : "false");
                            airFresh.SetAttrState(FunctionAttributeKey.Mode, receiveBytes[3] == 1 ? "fan" : "humidification");
                            airFresh.SetAttrState(FunctionAttributeKey.Energy, receiveBytes[4] == 1 ? "false" : "true");
                            switch (receiveBytes[5])
                            {
                                case 0:
@@ -675,6 +704,8 @@
                            airFresh.SetAttrState(FunctionAttributeKey.IndoorHumidity, receiveBytes[8].ToString());
                            airFresh.SetAttrState(FunctionAttributeKey.FilterRemain, receiveBytes[9].ToString());
                            airFresh.SetAttrState(FunctionAttributeKey.FilterTimeout, receiveBytes[10] == 1 ? "true" : "false");
                            //设备状态推送
                            Stan.HdlFormLogic.Current.DeviceStatuPush(airFresh, true);
                        }
                        break;
                }