From b71dfb3ca100340005d56e1298292807da82322d Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期一, 08 六月 2020 15:04:21 +0800 Subject: [PATCH] 20200608 --- HDL_ON/Entity/Function/Light.cs | 83 ++++++++++++++++++++++++++++++++++++----- 1 files changed, 73 insertions(+), 10 deletions(-) diff --git a/HDL_ON/Entity/Function/Light.cs b/HDL_ON/Entity/Function/Light.cs index de3fcc2..071ccf7 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) { @@ -212,29 +212,92 @@ if (command == CommandType_A.write) { - sendJob = new JObject { { "vendor_code", vendor_code }, { "Command", command.ToString() }, { "Type", "device" } }; - JObject data = null; +#if DEBUG + switch(sid) + { + case "00010114051D0A300C92C902020200010001": + sid = "00010114041710193123D402020200010001"; + break; + case "00010114051D0A300C92C902020200020001": + sid = "00010114041710193123D402020200020001"; + break; + case "00010114051D0A300C92C902020200030001": + sid = "00010114041710193123D402020200030001"; + break; + case "00010114051D0A300C92C902020200040001": + sid = "00010114041710193123D402020200040001"; + break; + } +#endif + + 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 = "brightness", + 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