From ba275a7b58e56c61820ffccc86571447b2997e52 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期四, 05 八月 2021 16:18:00 +0800 Subject: [PATCH] 2021-08-05 1.更新 --- HDL_ON/DAL/DriverLayer/Packet.cs | 172 +++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 123 insertions(+), 49 deletions(-) diff --git a/HDL_ON/DAL/DriverLayer/Packet.cs b/HDL_ON/DAL/DriverLayer/Packet.cs index 1535a92..5994565 100644 --- a/HDL_ON/DAL/DriverLayer/Packet.cs +++ b/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); @@ -179,7 +180,7 @@ light.trait_on_off.curValue = 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); @@ -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); } } } @@ -315,7 +331,7 @@ if (function.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0]) { function.SetAttrState(FunctionAttributeKey.TempType, receiveBytes[1].ToString()); - function.SetAttrState(FunctionAttributeKey.IndoorTemp, receiveBytes[2].ToString()); + function.SetAttrState(FunctionAttributeKey.RoomTemp, receiveBytes[2].ToString()); function.trait_on_off.curValue = receiveBytes[8] == 1 ? "on" : "off"; acFunction.SetMode(receiveBytes[9],function); acFunction.SetFan(receiveBytes[10],function); @@ -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) @@ -446,9 +468,16 @@ { indoorTemp = receiveBytes[9]; } - function.SetAttrState(FunctionAttributeKey.IndoorTemp, indoorTemp); + 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); @@ -504,7 +533,7 @@ sensor.SetAttrState(FunctionAttributeKey.Value, Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString()); break; } - EnvironmentalSciencePage.LoadEvent_UpdataStatus(sensor); + EnvironmentalPage.LoadEvent_UpdataStatus(sensor); } } } @@ -561,7 +590,7 @@ } break; } - EnvironmentalSciencePage.LoadEvent_UpdataStatus(sensor); + EnvironmentalPage.LoadEvent_UpdataStatus(sensor); } } } @@ -621,7 +650,7 @@ { if (ac.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0]) { - ac.SetAttrState(FunctionAttributeKey.IndoorTemp, receiveBytes[1].ToString()); + ac.SetAttrState(FunctionAttributeKey.RoomTemp, receiveBytes[1].ToString()); FunctionPage.UpdataStates(ac); } } @@ -636,6 +665,47 @@ Control.Ins.IsSearchLocalGatewaySuccessful = true; Control.Ins.GatewayOnline_Local = true; DAL.Mqtt.MqttClient.DisConnectRemote();//鏂紑mqtt + } + break; + case Command.FreshAirControlACK_JinMao: + case Command.FreshAirReadACK_JinMao: + var airFresh = FunctionList.List.GetAirFreshList().Find((obj) => obj.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0]); + if (airFresh != null) + { + /// 3 寮�鍏� 0-鍏虫満锛�1-寮�鏈� + /// 4 杩愯妯″紡 1-閫氶锛�2-鍔犳箍 humidification/fan + /// 5 鑺傝兘鑸掗�傞�夋嫨 1-鑸掗�傦紝2-鑺傝兘 true/false + /// 6 椋庨�熸。浣� 0-鑷姩锛�1-1妗o紝2-2妗o紝3-3妗� level_1/level_2/level_3/auto + /// 7 婀垮害璁惧畾 % + /// 8 瀹ゅ唴娓╁害鍊� 鈩� + /// 9 瀹ゅ唴婀垮害鍊� 鈩� + /// 10 杩囨护缃戝墿浣� % + /// 11 杩囨护缃戜娇鐢ㄨ秴鏃� 1 瓒呮椂 0 鏃� true/false + airFresh.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[2] == 0 ? "off" : "on"); + airFresh.SetAttrState(FunctionAttributeKey.Mode, receiveBytes[3] == 1 ? "fan" : "humidification"); + airFresh.SetAttrState(FunctionAttributeKey.Energy, receiveBytes[4] == 1 ? "false" : "true"); + switch (receiveBytes[5]) + { + case 0: + airFresh.SetAttrState(FunctionAttributeKey.FanSpeed, "auto"); + break; + case 1: + airFresh.SetAttrState(FunctionAttributeKey.FanSpeed, "level_1"); + break; + case 2: + airFresh.SetAttrState(FunctionAttributeKey.FanSpeed, "level_2"); + break; + case 3: + airFresh.SetAttrState(FunctionAttributeKey.FanSpeed, "level_3"); + break; + } + airFresh.SetAttrState(FunctionAttributeKey.Humidity, receiveBytes[6].ToString()); + airFresh.SetAttrState(FunctionAttributeKey.IndoorTemp, receiveBytes[7].ToString()); + 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; } @@ -672,6 +742,10 @@ switch (command) { case Command.SetSingleLightACK: + case Command.FreshAirReadACK: + case Command.FreshAirControlACK: + case Command.FreshAirReadACK_JinMao: + case Command.FreshAirControlACK_JinMao: receiveFlag += string.Format("{0}", usefulBytes[0]); break; case Command.SetLogicLoopColorACK: -- Gitblit v1.8.0