From 4f2dbd1f6a1ec2d9c3c39b4a37b0b7c9ddece4aa Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期四, 23 九月 2021 15:24:01 +0800 Subject: [PATCH] 主页刷新优化 --- HDL_ON/DAL/DriverLayer/Packet.cs | 41 +++++++++++++++++++++++++++-------------- 1 files changed, 27 insertions(+), 14 deletions(-) diff --git a/HDL_ON/DAL/DriverLayer/Packet.cs b/HDL_ON/DAL/DriverLayer/Packet.cs index 2d28447..173d521 100644 --- a/HDL_ON/DAL/DriverLayer/Packet.cs +++ b/HDL_ON/DAL/DriverLayer/Packet.cs @@ -133,7 +133,7 @@ { if (updataObj.spk != SPK.LightRGB) { - updataObj.trait_on_off.curValue = receiveBytes[2] > 0 ? "on" : "off"; + updataObj.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[2] > 0 ? "on" : "off"); if (updataObj.trait_on_off.curValue.ToString() == "on") { switch (updataObj.spk) @@ -177,10 +177,10 @@ { if (light.spk != SPK.LightRGB) { - light.trait_on_off.curValue = receiveBytes[light.bus.LoopId] == 0 ? "off" : "on"; + light.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[light.bus.LoopId] == 0 ? "off" : "on"); if (light.trait_on_off.curValue.ToString() == "on") { - light.SetAttrState(FunctionAttributeKey.Brightness, receiveBytes[2].ToString()); + light.SetAttrState(FunctionAttributeKey.Brightness, receiveBytes[i+1].ToString()); light.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%"; } HomePage.UpdataFunctionStates(light); @@ -234,7 +234,7 @@ { if (lightTeme.spk == SPK.LightRGB) { - lightTeme.trait_on_off.curValue = receiveBytes[1] > 0 ? "on" : "off"; + lightTeme.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[1] > 0 ? "on" : "off"); if (receiveBytes[1] > 0) { lightTeme.SetAttrState(FunctionAttributeKey.Brightness, receiveBytes[1].ToString()); @@ -249,7 +249,7 @@ RGBPage.UpdataStates(lightTeme); }else if(lightTeme.spk == SPK.LightCCT) { - lightTeme.trait_on_off.curValue = receiveBytes[1] > 0 ? "on" : "off"; + lightTeme.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[1] > 0 ? "on" : "off"); if (receiveBytes[1] > 0) { lightTeme.SetAttrState(FunctionAttributeKey.Brightness, receiveBytes[1].ToString()); @@ -276,11 +276,11 @@ { if (receiveBytes[1] > 1) { - curtain.trait_on_off.curValue = "on"; + curtain.SetAttrState(FunctionAttributeKey.OnOff, "on"); } else { - curtain.trait_on_off.curValue = "off"; + curtain.SetAttrState(FunctionAttributeKey.OnOff, "off"); } curtain.SetAttrState(FunctionAttributeKey.Percent, receiveBytes[1].ToString()); curtain.lastState = Language.StringByID(StringId.Open) + curtain.GetAttrState(FunctionAttributeKey.Percent) + "%"; @@ -292,14 +292,15 @@ switch (receiveBytes[1]) { case 0: - curtain.trait_on_off.curValue = "stop"; - break; + curtain.SetAttrState(FunctionAttributeKey.OnOff, "stop"); + return; case 1: - curtain.trait_on_off.curValue = "on"; + curtain.SetAttrState(FunctionAttributeKey.OnOff, "on"); + //curtain. curtain.lastState = Language.StringByID(StringId.Open); break; case 2: - curtain.trait_on_off.curValue = "off"; + curtain.SetAttrState(FunctionAttributeKey.OnOff, "off"); curtain.lastState = Language.StringByID(StringId.Close); break; } @@ -332,7 +333,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.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[8] == 1 ? "on" : "off"); acFunction.SetMode(receiveBytes[9],function); acFunction.SetFan(receiveBytes[10],function); function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[11].ToString()); @@ -386,7 +387,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.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[1] % 2 == 0 ? "off" : "on"); new FloorHeating().SetModeIndex(receiveBytes[3],function); if (function.Fh_Mode_Temp.ContainsKey("normal")) @@ -519,21 +520,27 @@ case SPK.SensorTemperature: byte[] tempBytes = new byte[] { receiveBytes[24], receiveBytes[25], receiveBytes[26], receiveBytes[27] }; sensor.SetAttrState(FunctionAttributeKey.Value,Math.Round(BitConverter.ToSingle(tempBytes, 0), 1).ToString()); + sensor.SetAttrState(sensor.spk,Math.Round(BitConverter.ToSingle(tempBytes, 0), 1).ToString()); break; case SPK.SensorHumidity: sensor.SetAttrState(FunctionAttributeKey.Value, (Convert.ToDouble(receiveBytes[24] * 256 + receiveBytes[25]) / 10).ToString()); + sensor.SetAttrState(sensor.spk, (Convert.ToDouble(receiveBytes[24] * 256 + receiveBytes[25]) / 10).ToString()); break; case SPK.SensorTVOC: sensor.SetAttrState(FunctionAttributeKey.Value, (Convert.ToDouble(receiveBytes[24] * 256 + receiveBytes[25]) / 100).ToString()); + sensor.SetAttrState(sensor.spk, (Convert.ToDouble(receiveBytes[24] * 256 + receiveBytes[25]) / 100).ToString()); break; case SPK.SensorPm25: sensor.SetAttrState(FunctionAttributeKey.Value,Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString()); + sensor.SetAttrState(sensor.spk,Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString()); break; case SPK.SensorCO2: sensor.SetAttrState(FunctionAttributeKey.Value, Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString()); + sensor.SetAttrState(sensor.spk, Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString()); break; } EnvironmentalPage.LoadEvent_UpdataStatus(sensor); + //A_EnvironmentalDataCenter.LoadEvent_UpdataStatus(sensor); } } } @@ -571,13 +578,16 @@ { case 1: sensor.SetAttrState(FunctionAttributeKey.Value,( (receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8]).ToString()); + sensor.SetAttrState(sensor.spk,( (receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8]).ToString()); break; case 2: sensor.SetAttrState(FunctionAttributeKey.Value,( -1 * ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8])).ToString()); + sensor.SetAttrState(sensor.spk,( -1 * ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8])).ToString()); break; case 3: byte[] tempBytes = new byte[] { receiveBytes[5], receiveBytes[6], receiveBytes[7], receiveBytes[8] }; sensor.SetAttrState(FunctionAttributeKey.Value,( Math.Round(BitConverter.ToSingle(tempBytes, 0), 1)).ToString()); + sensor.SetAttrState(sensor.spk,( Math.Round(BitConverter.ToSingle(tempBytes, 0), 1)).ToString()); break; } switch (receiveBytes[4]) @@ -587,9 +597,12 @@ { var value = Convert.ToInt32(sensor.GetAttrState(FunctionAttributeKey.Value)); sensor.SetAttrState(FunctionAttributeKey.Value, (value /= 100000).ToString()); + sensor.SetAttrState(sensor.spk, (value /= 100000).ToString()); } break; } + + //A_EnvironmentalDataCenter.LoadEvent_UpdataStatus(sensor); EnvironmentalPage.LoadEvent_UpdataStatus(sensor); } } @@ -618,7 +631,7 @@ switch (receiveBytes[0]) { case 3:// - function.trait_on_off.curValue = receiveBytes[1] == 1 ? "on" : "off"; + function.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[1] == 1 ? "on" : "off"); break; case 4: case 7: -- Gitblit v1.8.0