From 6a9ad7ec93218913a2ce3b898bb036f18f8f0da4 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期四, 13 八月 2020 17:06:36 +0800 Subject: [PATCH] 20200813 --- HDL_ON/DriverLayer/CommonPage.cs | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 166 insertions(+), 9 deletions(-) diff --git a/HDL_ON/DriverLayer/CommonPage.cs b/HDL_ON/DriverLayer/CommonPage.cs index 07fa7ec..53c7dff 100644 --- a/HDL_ON/DriverLayer/CommonPage.cs +++ b/HDL_ON/DriverLayer/CommonPage.cs @@ -115,16 +115,16 @@ { } + Control.controlLostCount = 0; switch (command) { - case Command.ReadLightSingleLoopBrightnessACK: case Command.SetSingleLightACK: foreach (var light in DB_ResidenceData.residenceData.functionList.lights) { if (light.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0]) { - if ( light.functionType != FunctionType.RGB) + if (light.functionType != FunctionType.RGB) { light.on_off = receiveBytes[2] == 0 ? "off" : "on"; if (light.on_off == "on") @@ -180,6 +180,64 @@ } break; + case Command.ReadLightAllLoopBrightnessACK: + for (int i = 0; i < receiveBytes[0]; i++) + { + var light = DB_ResidenceData.residenceData.functionList.lights.Find((obj) => obj.bus_Data.SubnetID == subnetID && obj.bus_Data.DeviceID == deviceID && obj.bus_Data.LoopID == i); + if (light != null) + { + if (light.functionType != FunctionType.RGB) + { + light.on_off = receiveBytes[2] == 0 ? "off" : "on"; + if (light.on_off == "on") + { + light.brightness = receiveBytes[2]; + light.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%"; + } + HomePage.UpdataFunctionStates(light); + RoomPage.UpdataStates(light); + FunctionPage.UpdataStates(light); + ClassificationPage.UpdataInfo(light); + switch (light.functionType) + { + case FunctionType.Relay: + RelayPage.UpdataState(light); + break; + case FunctionType.Dimmer: + DimmerPage.UpdataStates(light); + break; + } + } + } + else + { + var e = DB_ResidenceData.residenceData.functionList.electricals.Find((obj) => obj.bus_Data.SubnetID == subnetID && obj.bus_Data.DeviceID == deviceID && obj.bus_Data.LoopID == i); + if (e != null) + { + var fan = e as Fan; + fan.on_off = receiveBytes[2] == 0 ? "off" : "on"; + if (fan.on_off == "on") + { + fan.openLevel = receiveBytes[2]; + fan.lastState = Language.StringByID(StringId.Level) + " : " + receiveBytes[2]; + } + HomePage.UpdataFunctionStates(fan); + RoomPage.UpdataStates(fan); + FunctionPage.UpdataStates(fan); + ClassificationPage.UpdataInfo(fan); + switch (fan.functionType) + { + case FunctionType.Fan: + FanPage.UpdataState(fan); + break; + case FunctionType.Socket: + + break; + } + } + } + } + break; case Command.SetLogicLoopColorACK: case Command.ReadLogicLoopColorACK: foreach (var rgb in DB_ResidenceData.residenceData.functionList.lights) @@ -189,7 +247,7 @@ if (rgb.functionType == FunctionType.RGB) { rgb.on_off = receiveBytes[1] > 0 ? "on" : "off"; - if (receiveBytes[1] >0) + if (receiveBytes[1] > 0) { rgb.brightness = receiveBytes[1]; rgb.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[1] + "%"; @@ -321,11 +379,11 @@ if (fh.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0]) { fh.curTempType = receiveBytes[2]; - fh.on_off = receiveBytes[1] % 2 ==0?"off":"on"; + fh.on_off = receiveBytes[1] % 2 == 0 ? "off" : "on"; fh.curModeIndex = receiveBytes[3]; if (fh.modeTemp.ContainsKey("ordinary")) { - fh.modeTemp["ordinary"]= receiveBytes[4]; + fh.modeTemp["ordinary"] = receiveBytes[4]; } else { @@ -370,9 +428,10 @@ break; case "timer": fh.lastState = Language.StringByID(StringId.Auto); - if(receiveBytes[8]==0) + if (receiveBytes[8] == 0) { - }else + } + else { } break; @@ -434,11 +493,11 @@ if ((int)sensor.functionType % 256 == receiveBytes[1] && sensor.bus_Data.SubnetID == subnetID && sensor.bus_Data.DeviceID == deviceID && sensor.bus_Data.LoopID == receiveBytes[2]) { - //0淇濈暀 1鏃犵鍙�4Byte鏁村舰 2鏈夌鍙�4Byte鏁村舰 3Float褰紙浠B憋級 + //0淇濈暀 1鏃犵鍙�4Byte鏁村舰 2鏈夌鍙�4Byte鏁村舰 3Float褰紙浠B憋級 switch (receiveBytes[3]) { case 1: - sensor.values = (receiveBytes[5]*256 * 256 * 256)+ (receiveBytes[6] * 256 * 256)+ (receiveBytes[7] * 256)+ receiveBytes[8]; + sensor.values = (receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8]; break; case 2: sensor.values = -1 * ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8]); @@ -460,6 +519,104 @@ } } break; + case Command.InstructionPanelKeyACK: + case Command.ReadInstructionPanelKeyACK: + byte reACPanel = 0; + if (receiveBytes.Length == 2) + { + reACPanel = 1; + } + else if (receiveBytes.Length == 3) + { + reACPanel = receiveBytes[2]; + } + else + { + break; + } + foreach (var ac in DB_ResidenceData.residenceData.functionList.aCs) + { + if (ac.GetBusId() == subnetID + "_" + deviceID + "_" + reACPanel) + { + switch (receiveBytes[0]) + { + case 3:// + ac.on_off = receiveBytes[1] == 1 ? "on" : "off"; + break; + case 4: + case 7: + case 8: + case 19: + ac.curTemp = receiveBytes[1]; + break; + case 5: + ac.curFanIndex = receiveBytes[1]; + break; + case 6: + ac.curModeIndex = receiveBytes[1]; + break; + + } + ac.lastState = ""; + ac.lastState += " " + ac.curTemp + ac.curTempTypeString; + RoomPage.UpdataStates(ac); + FunctionPage.UpdataStates(ac); + HomePage.UpdataFunctionStates(ac); + ClassificationPage.UpdataInfo(ac); + ACPage.UpdataStates(ac); + //else if (common.Type == DeviceType.FoolHeatPanel) + { + //switch (receiveBytes[0]) + //{ + // case 20:// + // fh.Status = receiveBytes[1]; + // break; + // case 21: + // fh.TemperatureType = receiveBytes[1]; + // if (receiveBytes[1] == 5) + // { + // if (fh.Timer == 0)//鏃堕棿妯″紡鐨勬椂闂存鏍囧織 (0锛氱櫧澶╋紝1锛氬鏅�) (1byte) //20110112鍔犳椂闂存鏍囧織 + // Control.ControlBytesSend(Command.ReadInstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte[] { 26, 2, fh.LoopID }, SendCount.Zero); + // else + // Control.ControlBytesSend(Command.ReadInstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte[] { 27, 3, fh.LoopID }, SendCount.Zero); + // } + // else + // Control.ControlBytesSend(Command.ReadInstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte[] { (byte)(receiveBytes[1] + 24), fh.LoopID }, SendCount.Zero); + // break; + // case 25: + // fh.NormalTemperature = receiveBytes[1]; + // break; + // case 26: + // fh.DayTemperature = receiveBytes[1]; + // break; + // case 27: + // fh.NightTemperature = receiveBytes[1]; + // break; + // case 28: + // fh.AwayTemperature = receiveBytes[1]; + // break; + //} + } + } + } + break; + case Command.ReadPanleTempACK://1944 + case Command.PanleBroadcastTemp: + foreach (var ac in DB_ResidenceData.residenceData.functionList.aCs) + { + if (ac.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0]) + { + ac.indoorTemp = receiveBytes[1]; + FunctionPage.UpdataStates(ac); + } + //else if (common.Type == DeviceType.FoolHeatPanel) + // { + // var tempFH22 = common as FoolHeatPanel; + // tempFH22.IndoorTemperature = receiveBytes[1]; + // UserFHPage.UpdateIndoorTemp(tempFH22.CommonLoopID, receiveBytes[1]); + // } + } + break; } } catch (Exception ex) -- Gitblit v1.8.0