From 7167334c0e89dd84827d59e726123d14776e3a09 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期二, 16 六月 2020 11:14:13 +0800 Subject: [PATCH] 2020-06-16-1 --- HDL_ON/DriverLayer/Control.cs | 87 ++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 80 insertions(+), 7 deletions(-) diff --git a/HDL_ON/DriverLayer/Control.cs b/HDL_ON/DriverLayer/Control.cs index cb7006d..05f0e0e 100644 --- a/HDL_ON/DriverLayer/Control.cs +++ b/HDL_ON/DriverLayer/Control.cs @@ -23,6 +23,8 @@ /// <returns></returns> public static void Send(CommandType_A commandType, Function function) { + function.usageCount++; + function.refreshTime = DateTime.Now; if (function.bus_Data!=null) { try @@ -129,8 +131,8 @@ var bytes = new byte[] { function.bus_Data.LoopID, b, 254, 0,0,3, - light.redColor,light.greenColor, - light.blueColor, + (byte)light.redColor,(byte)light.greenColor, + (byte)light.blueColor, 0,0}; MainPage.Log($"rgb level1 : {light.brightness}"); ControlBytesSend(Command.SetLogicLoopColor, subnetId, deviceId, bytes,1); @@ -185,9 +187,54 @@ break; } break; - case FunctionCategory.AC: - var aC = function as AC; - ControlBytesSend(Command.SetACMode, subnetId, deviceId, new byte[] { aC.bus_Data.LoopID, (byte)aC.curTempType, 32, 32, 32, 32, 32, 0, aC.on_off == "on" ? (byte)1 : (byte)0, aC.curModeIndex, aC.curFanIndex, (byte)aC.curTemp, 0 }); + case FunctionCategory.Thermostat: + switch (function.functionType) + { + case FunctionType.AC: + var aC = function as AC; + ControlBytesSend(Command.SetACMode, subnetId, deviceId, new byte[] { aC.bus_Data.LoopID, (byte)aC.curTempType, 32, 32, 32, 32, 32, 0, aC.on_off == "on" ? (byte)1 : (byte)0, aC.curModeIndex, aC.curFanIndex, (byte)aC.curTemp, 0 }); + break; + case FunctionType.FloorHeating: + var fh = function as FloorHeating; + if (fh.modeTemp.Count == 4) + { + byte b1 = fh.on_off == "on" ? (byte)1 : (byte)0; + if (fh.workMode > 0) + { + b1 += (byte)(16 + fh.workMode); + } + ControlBytesSend(Command.SetFloorHeat, subnetId, deviceId, new byte[] { fh.bus_Data.LoopID, b1,(byte)fh.curTempType,fh.curModeIndex, fh.modeTemp["ordinary"], fh.modeTemp["day"], fh.modeTemp["night"], fh.modeTemp["away"], 0, 0 }); + } + //else + //{ + // ControlBytesSend(Command.ReadFloorHeat, subnetId,deviceId,new byte[] { fh.bus_Data.LoopID}); + //} + break; + } + break; + case FunctionCategory.Electrical: + switch (function.functionType) + { + case FunctionType.Fan: + var fan = function as Fan; + if(fan.on_off == "on") + { + ControlBytesSend(Command.SetSingleLight, subnetId, deviceId, new byte[] { fan.bus_Data.LoopID, (byte)fan.openLevel }); + } + { + ControlBytesSend(Command.SetSingleLight, subnetId, deviceId, new byte[] { fan.bus_Data.LoopID, 0 }); + } + break; + } + break; + case FunctionCategory.SwitchDevice: + switch(function.functionType) + { + case FunctionType.Socket: + var s = function as SwitchSocket; + ControlBytesSend(Command.SetSingleLight, subnetId, deviceId, new byte[] { s.bus_Data.LoopID, s.on_off == "on" ? (byte)100 : (byte)0 }); + break; + } break; } break; @@ -216,8 +263,34 @@ break; } break; - case FunctionCategory.AC: - ControlBytesSend(Command.ReadACMode, subnetId, deviceId, new byte[] {function.bus_Data.LoopID }); + case FunctionCategory.Thermostat: + switch (function.functionType) + { + case FunctionType.AC: + ControlBytesSend(Command.ReadACMode, subnetId, deviceId, new byte[] { function.bus_Data.LoopID }); + break; + case FunctionType.FloorHeating: + ControlBytesSend(Command.ReadFloorHeat, subnetId, deviceId, new byte[] { function.bus_Data.LoopID }); + break; + } + break; + case FunctionCategory.Electrical: + switch (function.functionType) + { + case FunctionType.Fan: + var fan = function as Fan; + ControlBytesSend(Command.SetSingleLightACK, subnetId, deviceId, new byte[] { fan.bus_Data.LoopID }); + break; + } + break; + case FunctionCategory.SwitchDevice: + switch (function.functionType) + { + case FunctionType.Socket: + var s = function as SwitchSocket; + ControlBytesSend(Command.SetSingleLightACK, subnetId, deviceId, new byte[] { s.bus_Data.LoopID }); + break; + } break; } break; -- Gitblit v1.8.0