From b69d7735274b8d0f741da8a6bb8b8e1347477a5a Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 19 三月 2020 17:14:16 +0800
Subject: [PATCH] 20200319

---
 HDL_ON/Entity/Function/Curtain/Curtain.cs |   64 +++++++++++++++++++++++++++++++
 1 files changed, 63 insertions(+), 1 deletions(-)

diff --git a/HDL_ON/Entity/Function/Curtain/Curtain.cs b/HDL_ON/Entity/Function/Curtain/Curtain.cs
index a247279..c0adeff 100644
--- a/HDL_ON/Entity/Function/Curtain/Curtain.cs
+++ b/HDL_ON/Entity/Function/Curtain/Curtain.cs
@@ -1,16 +1,78 @@
 锘縰sing System;
+using Newtonsoft.Json.Linq;
+
 namespace HDL_ON.Entity
 {
     public class Curtain : Function
     {
+        /*
+        绐楀笜灞炴�у垪琛細trait: [switch,openLevel,lock]
+        灞炴��	鎻忚堪
+        switch	on/off/stop;
+        openLevel	0-100;
+        lock	boolean (Lock閿佸畾鎺у埗)
+        */
         public Curtain()
         {
-            //functionType = "CurtainModule";
         }
         /// <summary>
         /// 绐楀笜鐘舵��
         /// 0鍋滐紱1寮�锛�2鍏�
         /// </summary>
         public byte state = 0;
+
+
+        /// <summary>
+        /// 鑾峰彇鍔熻兘绫诲瀷
+        /// </summary>
+        /// <returns></returns>
+        protected override string GetFunctionType()
+        {
+            string type = "Curtain";
+            if (PropertyArray.Contains("curtaintype"))
+            {
+                type = "MotorCurtain";
+                if (PropertyArray.Contains("rollingshutter"))
+                {
+                    type = "RollingShutter";
+                }
+            }
+            return type;
+        }
+
+
+        /// <summary>
+        /// 鎷兼帴銆佽幏鍙朅鍗忚鎿嶄綔鏁版嵁
+        /// </summary>
+        public override JObject GetSendJObject(string command)
+        {
+            var sendJob = new JObject();
+            if (command == "write")
+            {
+
+                sendJob = new JObject { { "vendor_code", a_Protocol_Namespace }, { "Command", command }, { "Type", "device" } };
+                JObject data = null;
+                switch (functionType)
+                {
+                    case "Curtain"://绐楀笜妯″潡鎺у埗
+                        data = new JObject { { "switch", state }, { "sid", sid } };
+                        break;
+                    case "MotorCurtain":
+                    case "RollingShutter":
+                        data = new JObject { { "openLevel", dicPropert["openLevel"] }, { "sid", sid } };
+                        break;
+                }
+                sendJob.Add("objects", data);
+            }
+            else if (command == "read")
+            {
+                sendJob = new JObject { { "vendor_code", a_Protocol_Namespace }, { "Command", command }, { "Type", "device" } };
+                var data = new JObject { { "sid", sid } };
+                sendJob.Add("objects", data);
+            }
+            return sendJob;
+        }
+
+
     }
 }

--
Gitblit v1.8.0