黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
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
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
namespace ZigBee.Device
{
    public class DimmableLight : LightBase
    {
        public DimmableLight()
        {
            this.Type = DeviceType.DimmableLight;
        }
        /// <summary>
        ///亮度,整形,取值范围:0-254表示0%-100% 
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public int Level = 0;
 
        /// <summary>
        /// 读取亮度
        /// </summary>
        public void ReadLevel()
        {
            ReadAttri(Device.Cluster_ID.LevelControl, AttriButeId.LevelControl);
        }
 
        ///<summary >
        ///设置设备亮度(Level)
        ///<para>value:亮度值取值范围:0-254</para>
        ///<para>command 0:Move to Level Command</para>
        /// </summary>
        public void SetLevel(int value)
        {
            var jObject = new JObject {
                { "DeviceAddr", DeviceAddr},
                { "Epoint", DeviceEpoint},
                    { "Cluster_ID", 8 },
                    { "Command", 4},
                    { "SendMode", 2 }
                };
            var data = new JObject {
                    { "Level", value },
                    { "TransitionTime", 0 }
                };
            jObject.Add("Data", data);
            Gateway?.Send("DeviceControl", jObject.ToString());
         }
 
        /////<summary >
        /////调节亮度大小 
        /////<para>command  1 :Move Command; 5:Move to Level Command(with On/ Off)</para>
        /////<para>moveMode:0: Up mode , Level 变大</para>
        /////<para>moveMode 1:Down mode , Level变小</para>
        ///// </summary>
        //public void MoveLevel(int moveMode, int command = 5)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 8 }, { "Command", command }, { "SendMode", 2 } };
        //    var data = new JObject { { "MoveMode", moveMode }, { "Rate", 100 } };
        //    jobject.Add("Data", data);
        //    Gateway?.Send("DeviceControl", jobject.ToString());
        //}
 
        /////<summary >
        /////Move Level Command
        /////<para>command 2: Move Command;6:Move to Level Command(with On/ Off)</para>
        // ///<para>StepMode:0 Up mode , Level 变大</para>
        /////<para>StepMode:1 Down mode , Level变小</para>
        ///// </summary>
        //public void StepLevel(int StepMode, int command = 6)
        //{
            //var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 8 }, { "Command", command }, { "SendMode", 2 } };
            //var data = new JObject { { "StepMode", StepMode }, { "StepSize", 50 }, { "TransitionTime", 0 } };
            //jobject.Add("Data", data);
            //Gateway?.Send("DeviceControl", jobject.ToString());
        //}
 
        ///<summary >
        ///停止亮度调节
        /// </summary>
        //public void StopLevel()
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 8 }, { "Command", 3 }, { "SendMode", 2 } };
        //    Gateway?.Send("DeviceControl", jobject.ToString());
        //}
    }
}