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