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 | 233 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 202 insertions(+), 31 deletions(-) diff --git a/HDL_ON/DriverLayer/CommonPage.cs b/HDL_ON/DriverLayer/CommonPage.cs index c7f1c2e..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] + "%"; @@ -211,38 +269,45 @@ case Command.ReadCurtainStutasACK: foreach (var curtain in DB_ResidenceData.residenceData.functionList.curtains) { - if (curtain.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0]) + if (curtain.bus_Data.SubnetID == subnetID && curtain.bus_Data.DeviceID == deviceID) { - switch(receiveBytes[1]) + if (receiveBytes[0] == 17) { - case 0: - curtain.on_off = "stop"; - break; - case 1: + if (receiveBytes[1] > 1) + { curtain.on_off = "on"; - curtain.lastState = Language.StringByID(StringId.Open); - break; - case 2: + } + else + { curtain.on_off = "off"; - curtain.lastState = Language.StringByID(StringId.Close); - break; - default: - if (receiveBytes[1] > 1) - { + } + curtain.openLevel = receiveBytes[1]; + curtain.lastState = Language.StringByID(StringId.Open) + curtain.openLevel + "%"; + } + else + { + if (curtain.bus_Data.LoopID != receiveBytes[0]) + continue; + switch (receiveBytes[1]) + { + case 0: + curtain.on_off = "stop"; + break; + case 1: curtain.on_off = "on"; - } - else - { + curtain.lastState = Language.StringByID(StringId.Open); + break; + case 2: curtain.on_off = "off"; - } - curtain.openLevel = receiveBytes[1]; - curtain.lastState = Language.StringByID(StringId.Open) + curtain.openLevel + "%"; - break; + curtain.lastState = Language.StringByID(StringId.Close); + break; + } } RoomPage.UpdataStates(curtain); FunctionPage.UpdataStates(curtain); HomePage.UpdataFunctionStates(curtain); ClassificationPage.UpdataInfo(curtain); + RollingShutterPage.UpdataState(curtain); switch (curtain.functionType) { case FunctionType.Curtain: @@ -314,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 { @@ -363,9 +428,10 @@ break; case "timer": fh.lastState = Language.StringByID(StringId.Auto); - if(receiveBytes[8]==0) + if (receiveBytes[8] == 0) { - }else + } + else { } break; @@ -427,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]); @@ -441,9 +507,114 @@ sensor.values = Math.Round(BitConverter.ToSingle(tempBytes, 0), 1); break; } + switch (receiveBytes[4]) + { + case 2: + if (receiveBytes[1] == 5)//TVOC闇�姹傞櫎浠�100000 + sensor.values /= 100000; + break; + } EnvironmentalSciencePage.LoadEvent_UpdataStatus(sensor); } } + } + 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; } @@ -477,7 +648,7 @@ string tempFileName = nameValueCollection["Command"].Replace("Get", ""); if ("AllFiles" == tempFileName) { - byte[] bytes = Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(FileUtils.ReadFiles())); + byte[] bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(FileUtils.ReadFiles())); outputStream.Write(bytes, 0, bytes.Length); outputStream.Flush(); } -- Gitblit v1.8.0