From 002a3f2e9d2f9579c01f88af12bd8a320003569f Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 31 三月 2020 08:57:19 +0800 Subject: [PATCH] 20200331 --- HDL_ON/DAL/Net/CommonPage.cs | 172 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 139 insertions(+), 33 deletions(-) diff --git a/HDL_ON/DAL/Net/CommonPage.cs b/HDL_ON/DAL/Net/CommonPage.cs index 3ef5e1b..ce39294 100644 --- a/HDL_ON/DAL/Net/CommonPage.cs +++ b/HDL_ON/DAL/Net/CommonPage.cs @@ -106,52 +106,57 @@ { if (function.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0]) { - if (function.functionCategory == FunctionType.Light) + if (function.functionCategory == FunctionCategory.Light) { var light = function as Light; - if (receiveBytes[2] == 0 && light.on_off == 0) + //if (receiveBytes[2] == 0 && light.on_off == "off") + //{ + // break; + //} + //if (function.functionType == "Relay") + //{ + // var relay = function as Light; + // relay.on_off = receiveBytes[2] == 0 ? "off" : "on"; + // HomePage.UpdataLightView(relay); + //} + //else if (function.functionType == "Dimmer") + //{ + //var light = function as Light; + light.on_off = receiveBytes[2] == 0 ? "off" : "on"; + if (light.on_off == "on") { - break; + light.brightness = receiveBytes[2]; + light.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%"; } - if (function.functionType == "Relay") + HomePage.UpdataFunctionStates(light); + RoomPage.UpdataStates(light); + FunctionPage.UpdataStates(light); + ClassificationPage.UpdataInfo(light); + switch (light.functionType) { - var relay = function as Light; - relay.on_off = receiveBytes[2] == 0 ? 0 : 1; - HomePage.UpdataLightView(relay); + case FunctionType.Relay: + RelayPage.UpdataState(light); + break; + case FunctionType.Dimmer: + DimmerPage.UpdataStates(light); + break; } - else if (function.functionType == "Dimmer") - { - var dimmer = function as Light; - dimmer.on_off = receiveBytes[2] == 0 ? 0 : 1; - if (dimmer.on_off == 1) - { - dimmer.brightness = receiveBytes[2]; - dimmer.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%"; - } - HomePage.UpdataLightView(dimmer); - RoomPage.UpdataStates(dimmer); - FunctionPage.UpdataStates(dimmer); - DimmerPage.UpdataStates(dimmer); - } + //} } } } break; case Command.SetLogicLoopColorACK: - foreach (var function in DB_ResidenceData.residenceData.functionList.lights) + case Command.ReadLogicLoopColorACK: + foreach (var rgb in DB_ResidenceData.residenceData.functionList.lights) { - if (function.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0]) + if (rgb.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0]) { - if (function.functionType == "RGB") + if (rgb.functionType == FunctionType.RGB) { - var light = function as Light; - if (receiveBytes[2] == 0 && light.on_off == 0) - { - break; - } - var rgb = function as Light; - rgb.on_off = receiveBytes[1] == 0 ? 0 : 1; - if (rgb.on_off == 1) + rgb.on_off = receiveBytes[1] > 0 ? "on" : "off"; + MainPage.Log($"Logic ACK {receiveBytes[1]}"); + if (receiveBytes[1] >0) { rgb.brightness = receiveBytes[1]; rgb.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[1] + "%"; @@ -160,14 +165,115 @@ rgb.greenColor = receiveBytes[7]; rgb.blueColor = receiveBytes[8]; - HomePage.UpdataLightView(rgb); + HomePage.UpdataFunctionStates(rgb); RoomPage.UpdataStates(rgb); FunctionPage.UpdataStates(rgb); + ClassificationPage.UpdataInfo(rgb); RGBPage.UpdataStates(rgb); } } } break; + case Command.SetCurtainModelStutasACK: + case Command.ReadCurtainStutasACK: + foreach (var curtain in DB_ResidenceData.residenceData.functionList.curtains) + { + if (curtain.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0]) + { + switch(receiveBytes[1]) + { + case 0: + curtain.on_off = "stop"; + break; + case 1: + curtain.on_off = "on"; + curtain.lastState = Language.StringByID(StringId.Open); + break; + case 2: + curtain.on_off = "off"; + curtain.lastState = Language.StringByID(StringId.Close); + break; + default: + if (receiveBytes[1] > 1) + { + curtain.on_off = "on"; + } + else + { + curtain.on_off = "off"; + } + curtain.openLevel = receiveBytes[1]; + curtain.lastState = Language.StringByID(StringId.Open) + curtain.openLevel + "%"; + break; + } + RoomPage.UpdataStates(curtain); + FunctionPage.UpdataStates(curtain); + HomePage.UpdataFunctionStates(curtain); + ClassificationPage.UpdataInfo(curtain); + switch (curtain.functionType) + { + case FunctionType.Curtain: + CurtainModulePage.UpdataState(curtain); + break; + } + } + } + break; + case Command.SetACModeACK: + case Command.ReadACModeACK: + foreach (var ac in DB_ResidenceData.residenceData.functionList.aCs) + { + if (ac.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0]) + { + ac.curTempType = receiveBytes[1]; + ac.indoorTemp = receiveBytes[2]; + ac.on_off = receiveBytes[8] == 1 ? "on" : "off"; + ac.curModeIndex = receiveBytes[9]; + ac.curFanIndex = receiveBytes[10]; + ac.curTemp = receiveBytes[11]; + ac.lastState = ""; + switch (ac.curMode) + { + case "cool": + ac.lastState = Language.StringByID(StringId.Cool); + break; + case "heat": + ac.lastState = Language.StringByID(StringId.Heat); + break; + case "dry": + ac.lastState = Language.StringByID(StringId.Dry); + break; + case "auto": + ac.lastState = Language.StringByID(StringId.Auto); + break; + case "fan": + ac.lastState = Language.StringByID(StringId.AirSupply); + break; + } + switch (ac.curFan) + { + case "high": + ac.lastState += " " + Language.StringByID(StringId.HighWindSpeed); + break; + case "medium": + ac.lastState += " " + Language.StringByID(StringId.MiddleWindSpeed); + break; + case "low": + ac.lastState += " " + Language.StringByID(StringId.LowWindSpeed); + break; + case "auto": + ac.lastState += " " + Language.StringByID(StringId.Auto); + break; + } + ac.lastState += " " + ac.curTemp + "掳C"; + RoomPage.UpdataStates(ac); + FunctionPage.UpdataStates(ac); + HomePage.UpdataFunctionStates(ac); + ClassificationPage.UpdataInfo(ac); + ACPage.UpdataStates(ac); + } + } + break; } } catch (Exception ex) -- Gitblit v1.8.0