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/Entity/Function/Light.cs | 66 +++++++++++++++++++++++++++----- 1 files changed, 55 insertions(+), 11 deletions(-) diff --git a/HDL_ON/Entity/Function/Light.cs b/HDL_ON/Entity/Function/Light.cs index de3fcc2..ac77986 100644 --- a/HDL_ON/Entity/Function/Light.cs +++ b/HDL_ON/Entity/Function/Light.cs @@ -32,7 +32,7 @@ { if (trait_brightness == null) { - trait_brightness = propertList.Find((obj) => obj.attri == "brightness"); + trait_brightness = function.Find((obj) => obj.attri == "brightness"); //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂�� if (trait_brightness == null) { @@ -54,7 +54,7 @@ { if (trait_brightness == null) { - trait_brightness = propertList.Find((obj) => obj.attri == "brightness"); + trait_brightness = function.Find((obj) => obj.attri == "brightness"); //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂�� if (trait_brightness == null) { @@ -91,7 +91,7 @@ { if (trait_color == null) { - trait_color = propertList.Find((obj) => obj.attri == "color"); + trait_color = function.Find((obj) => obj.attri == "color"); //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂�� if (trait_color == null) { @@ -211,30 +211,74 @@ var sendJob = new JObject(); if (command == CommandType_A.write) { - - sendJob = new JObject { { "vendor_code", vendor_code }, { "Command", command.ToString() }, { "Type", "device" } }; - JObject data = null; + sendJob = new JObject { { "vendor_code", vendor_code }, { "command", command.ToString() }, { "type", "device" } }; + JObject data = new JObject { { "sid", sid } }; + sendJob.Add("objects", data); + List<ControlData> controlData = new List<ControlData>(); switch (functionType) { case FunctionType.Relay: - data = new JObject { { "sid", sid }, { "switch", on_off } }; + controlData.Add(new ControlData() + { + name = "on_off", + data_type = "Bool", + value = on_off + }); break; case FunctionType.Dimmer: - data = new JObject { { "sid", sid }, { "brightness", brightness } }; + controlData.Add(new ControlData() + { + name = "on_off", + data_type = "Bool", + value = on_off + }); + controlData.Add(new ControlData() + { + name = "brightness", + data_type = "int", + value = brightness.ToString(), + }); break; case FunctionType.RGB: - data = new JObject { { "sid", sid }, { "brightness", brightness }, { "color", color } }; + controlData.Add(new ControlData() + { + name = "on_off", + data_type = "Bool", + value = on_off + }); + controlData.Add(new ControlData() + { + name = "brightness", + data_type = "int", + value = brightness.ToString(), + }); + controlData.Add(new ControlData() + { + name = "color", + data_type = "int", + value = color.ToString(), + }); break; } - sendJob.Add("objects", data); + + AProtocolEntity ape = new AProtocolEntity() + { + command = command.ToString(), + vendor_code = vendor_code, + type = "device_sid", + }; + ape.ControlFunction(sid, controlData); + sendJob = JObject.FromObject(ape); + } else if (command == CommandType_A.read) { - sendJob = new JObject { { "vendor_code", vendor_code }, { "Command", command.ToString() }, { "Type", "device" } }; + sendJob = new JObject { { "vendor_code", vendor_code }, { "command", command.ToString() }, { "type", "device" } }; var data = new JObject {{ "sid", sid } }; sendJob.Add("objects", data); } return sendJob; } } + } -- Gitblit v1.8.0