From 068c68295cad1967f7aafb4e5e951260ef03d4ce Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期五, 09 七月 2021 09:16:43 +0800
Subject: [PATCH] 状态属性更改,不要轻易合并

---
 HDL_ON/DAL/DriverLayer/Packet.cs |   68 +++++++++++++++++++++-------------
 1 files changed, 42 insertions(+), 26 deletions(-)

diff --git a/HDL_ON/DAL/DriverLayer/Packet.cs b/HDL_ON/DAL/DriverLayer/Packet.cs
index a5b60c5..0ccf533 100644
--- a/HDL_ON/DAL/DriverLayer/Packet.cs
+++ b/HDL_ON/DAL/DriverLayer/Packet.cs
@@ -97,7 +97,8 @@
                 {
                     ddd += bb + ",";
                 }
-                MainPage.Log($"bus鍛戒护:"+ ((int)command) + " : 鏁版嵁:" + ddd);
+                MainPage.Log($"bus鍛戒护:" + ((int)command).ToString("X").PadLeft(4, '0') + " : 鏁版嵁:" + ddd);
+                //MainPage.Log($"bus鍛戒护:"+ ((int)command) + " : 鏁版嵁:" + ddd);
 #endif
                 //澶勭悊鏄惁瑕侀噸鍙戞暟鎹�
                 ManagerReceive(subnetID, deviceID, command, usefulBytes);
@@ -132,8 +133,8 @@
                             {
                                 if (updataObj.spk != SPK.LightRGB)
                                 {
-                                    updataObj.trait_on_off.curValue = receiveBytes[2] > 0 ? "on" : "off";
-                                    if (updataObj.trait_on_off.curValue.ToString() == "on")
+                                    updataObj.trait_on_off.state = receiveBytes[2] > 0 ? "on" : "off";
+                                    if (updataObj.trait_on_off.state.ToString() == "on")
                                     {
                                         switch (updataObj.spk)
                                         {
@@ -176,8 +177,8 @@
                             {
                                 if (light.spk != SPK.LightRGB)
                                 {
-                                    light.trait_on_off.curValue = receiveBytes[light.bus.LoopId] == 0 ? "off" : "on";
-                                    if (light.trait_on_off.curValue.ToString() == "on")
+                                    light.trait_on_off.state = receiveBytes[light.bus.LoopId] == 0 ? "off" : "on";
+                                    if (light.trait_on_off.state.ToString() == "on")
                                     {
                                         light.SetAttrState(FunctionAttributeKey.Brightness, receiveBytes[2].ToString());
                                         light.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%";
@@ -203,7 +204,7 @@
                                 if (function != null)
                                 {
                                     function.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[2] == 0 ? "off" : "on");
-                                    if (function.trait_on_off.curValue.ToString() == "on")
+                                    if (function.trait_on_off.state.ToString() == "on")
                                     {
                                         function.SetAttrState(FunctionAttributeKey.OpenLevel, receiveBytes[2].ToString());
                                         function.lastState = Language.StringByID(StringId.Level) + " : " + receiveBytes[2];
@@ -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.state = 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.state = 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);
                                 }
                             }
                         }
@@ -260,11 +276,11 @@
                                 {
                                     if (receiveBytes[1] > 1)
                                     {
-                                        curtain.trait_on_off.curValue = "on";
+                                        curtain.trait_on_off.state = "on";
                                     }
                                     else
                                     {
-                                        curtain.trait_on_off.curValue = "off";
+                                        curtain.trait_on_off.state = "off";
                                     }
                                     curtain.SetAttrState(FunctionAttributeKey.Percent, receiveBytes[1].ToString());
                                     curtain.lastState = Language.StringByID(StringId.Open) + curtain.GetAttrState(FunctionAttributeKey.Percent) + "%";
@@ -276,14 +292,14 @@
                                     switch (receiveBytes[1])
                                     {
                                         case 0:
-                                            curtain.trait_on_off.curValue = "stop";
+                                            curtain.trait_on_off.state = "stop";
                                             break;
                                         case 1:
-                                            curtain.trait_on_off.curValue = "on";
+                                            curtain.trait_on_off.state = "on";
                                             curtain.lastState = Language.StringByID(StringId.Open);
                                             break;
                                         case 2:
-                                            curtain.trait_on_off.curValue = "off";
+                                            curtain.trait_on_off.state = "off";
                                             curtain.lastState = Language.StringByID(StringId.Close);
                                             break;
                                     }
@@ -316,7 +332,7 @@
                             {
                                 function.SetAttrState(FunctionAttributeKey.TempType, receiveBytes[1].ToString());
                                 function.SetAttrState(FunctionAttributeKey.RoomTemp, receiveBytes[2].ToString());
-                                function.trait_on_off.curValue = receiveBytes[8] == 1 ? "on" : "off";
+                                function.trait_on_off.state = receiveBytes[8] == 1 ? "on" : "off";
                                 acFunction.SetMode(receiveBytes[9],function);
                                 acFunction.SetFan(receiveBytes[10],function);
                                 function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[11].ToString());
@@ -370,7 +386,7 @@
                             if (function.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
                             {
                                 function.SetAttrState(FunctionAttributeKey.TempType, receiveBytes[2]);
-                                function.trait_on_off.curValue = receiveBytes[1] % 2 == 0 ? "off" : "on";
+                                function.trait_on_off.state = receiveBytes[1] % 2 == 0 ? "off" : "on";
                                 new FloorHeating().SetModeIndex(receiveBytes[3],function);
 
                                 if (function.Fh_Mode_Temp.ContainsKey("normal"))
@@ -602,7 +618,7 @@
                                 switch (receiveBytes[0])
                                 {
                                     case 3://
-                                        function.trait_on_off.curValue = receiveBytes[1] == 1 ? "on" : "off";
+                                        function.trait_on_off.state = receiveBytes[1] == 1 ? "on" : "off";
                                         break;
                                     case 4:
                                     case 7:

--
Gitblit v1.8.0