From 171bf03f3664226eeff2b20ee9bd2e914b63a17d Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期五, 13 三月 2020 09:18:50 +0800
Subject: [PATCH] 20200313

---
 HDL_ON/Entity/Function/Light/Light.cs |   45 ++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/HDL_ON/Entity/Function/Light/Light.cs b/HDL_ON/Entity/Function/Light/Light.cs
index 5455156..b3d064f 100644
--- a/HDL_ON/Entity/Function/Light/Light.cs
+++ b/HDL_ON/Entity/Function/Light/Light.cs
@@ -6,9 +6,35 @@
 {
     public class Light : Function
     {
+        /*
+        鐏厜绫伙細trait: [switch,brightness,color,cct,delay,fadeTime]
+        灞炴��	鎻忚堪
+        switch	on/off;
+        brightness	0-100;
+        color	int (red (0-255) green (0-255) blue (0-255))
+        cct	int (warm light(0-255) cold light (0-255) )
+        delay	0-3600s
+        fadetime	0-3600s
+        */
         public Light()
         {
-            bus_DeviceType = "Relay";
+        }
+        /// <summary>
+        /// 鑾峰彇鍔熻兘绫诲瀷
+        /// </summary>
+        /// <returns></returns>
+        protected override string GetFunctionType()
+        {
+            string type = "Relay";
+            if (PropertyArray.Contains("brightness"))
+            {
+                type = "Dimmer";
+                if (PropertyArray.Contains("color"))
+                {
+                    type = "RGB";
+                }
+            }
+            return type;
         }
 
         /// <summary>
@@ -18,7 +44,6 @@
         /// </summary>
         public int state = 0;
 
-        public List<string> PropertyArray = new List<string>();
 
         /// <summary>
         /// 鎷兼帴銆佽幏鍙朅鍗忚鎿嶄綔鏁版嵁
@@ -30,13 +55,23 @@
             {
 
                 sendJob = new JObject { { "Namespace", a_Protocol_Namespace }, { "Command", command }, { "Type", "device" } };
-                var data = new JObject { { "Switch", state }, { "sid", sid } };
+                JObject data = null;
+                switch (functionType)
+                {
+                    case "Relay"://缁х數鍣ㄦ帶鍒�
+                        data = new JObject { { "switch", state }, { "sid", sid } };
+                        break;
+                    case "Dimmer":
+                        data = new JObject { { "switch", state }, { "brightness", dicPropert["brightness"] }, { "sid", sid } };
+                        break;
+                }
                 sendJob.Add("objects", data);
-                return sendJob;
             }
             else if(command == "read")
             {
-
+                sendJob = new JObject { { "Namespace", a_Protocol_Namespace }, { "Command", command }, { "Type", "device" } };
+                var data = new JObject {{ "sid", sid } };
+                sendJob.Add("objects", data);
             }
             return sendJob;
         }

--
Gitblit v1.8.0