wxr
2020-03-19 b69d7735274b8d0f741da8a6bb8b8e1347477a5a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using 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()
        {
        }
        /// <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>
        /// 拼接、获取A协议操作数据
        /// </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;
        }
 
 
    }
}