From e322d91c7325019710bfdb046c5fea673031455a Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期三, 29 七月 2020 11:53:01 +0800
Subject: [PATCH] 20200729
---
HDL_ON/DriverLayer/Control.cs | 60 ++++++++++++++++++++++++++++++++++++------------------------
1 files changed, 36 insertions(+), 24 deletions(-)
diff --git a/HDL_ON/DriverLayer/Control.cs b/HDL_ON/DriverLayer/Control.cs
index 05f0e0e..5f6ad52 100644
--- a/HDL_ON/DriverLayer/Control.cs
+++ b/HDL_ON/DriverLayer/Control.cs
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
+using HDL_ON.DAL;
+using HDL_ON.DAL.Net;
using HDL_ON.Entity;
using Newtonsoft.Json.Linq;
using Shared;
@@ -38,20 +40,10 @@
}
else
{
-
- //var jObject = new JObject {
- //{ "DeviceAddr", 11},
- //{ "Epoint", 22},
- // { "Cluster_ID", 8 },
- // { "Command", 33},
- // { "SendMode", 2 }
- //};
- //var data = new JObject {
- // { "Level", 1 },
- // { "TransitionTime", 0 }
- //};
- //jObject.Add("Data", data);
- //return revBytes;
+ var commandObj = function.GetSendJObject(commandType);
+ var commandString = Newtonsoft.Json.JsonConvert.SerializeObject(commandObj);
+ var commandBytes = CommonPage.MyEncodingUTF8.GetBytes(commandString);
+ MqttCommon.MqttRemoteSend(commandBytes);
}
}
@@ -66,7 +58,7 @@
{
if(busSceneData.Key == function.sid)
{
- switch(function.functionType)
+ switch (function.functionType)
{
case FunctionType.Curtain:
ControlBytesSend(Command.SetCurtainModelStutas, function.bus_Data.SubnetID, function.bus_Data.DeviceID, busSceneData.Value);
@@ -81,6 +73,22 @@
case FunctionType.RGB:
ControlBytesSend(Command.SetLogicLoopColor, function.bus_Data.SubnetID, function.bus_Data.DeviceID, busSceneData.Value);
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, function.bus_Data.SubnetID, function.bus_Data.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 });
+ }
+ break;
+ case FunctionType.Socket:
+ var s = function as SwitchSocket;
+ ControlBytesSend(Command.SetSingleLight, function.bus_Data.SubnetID, function.bus_Data.DeviceID, new byte[] { s.bus_Data.LoopID, s.on_off == "on" ? (byte)100 : (byte)0 });
+ break;
}
}
}
@@ -94,20 +102,12 @@
/// <returns></returns>
static void ControlBusData(Function function, CommandType_A command)
{
- //鍙嶉:
- //{
- //"Namespace": "HDL", "Command": "writeRespone",
- //鈥淭ype鈥�:鈥漝evice鈥�, "objects": [{
- //"sid": "0001002019101209000025670100010001鈥�, "statue": "success鈥�
- //}] }
try
{
var subnetId = function.bus_Data.SubnetID;
var deviceId = function.bus_Data.DeviceID;
var loopId = function.bus_Data.LoopID;
- //var jobj = JObject.FromObject(commandString.GetValue("objects"));
- //var functionType = jobj.GetValue("sid").ToString().Substring(22, 2);//鎴彇24锛�25瀛楃鑾峰彇鎺у埗鐨勮澶囩殑绫诲瀷
switch (command)
{
case CommandType_A.write:
@@ -183,7 +183,14 @@
{
ControlBytesSend(Command.SetCurtainModelStutas, subnetId, deviceId, new byte[] { curtain.bus_Data.LoopID, 0 });
}
- ControlBytesSend(Command.SetCurtainModelStutas, subnetId, deviceId, new byte[] { 17, (byte)curtain.openLevel });
+ else if (curtain.on_off == "on")
+ {
+ ControlBytesSend(Command.SetCurtainModelStutas, subnetId, deviceId, new byte[] { 17, 100 });
+ }
+ else if (curtain.on_off == "off")
+ {
+ ControlBytesSend(Command.SetCurtainModelStutas, subnetId, deviceId, new byte[] { 17, 0 });
+ }
break;
}
break;
@@ -292,6 +299,11 @@
break;
}
break;
+ case FunctionCategory.Sensor:
+ var sensor = function as Sensor;
+ ControlBytesSend(Command.ReadDeviceLoopInfo, subnetId, deviceId, new byte[] { (byte)5,
+ (byte)((int)sensor.functionType % 256), sensor.bus_Data.LoopID });
+ break;
}
break;
}
--
Gitblit v1.8.0