| | |
| | | { |
| | | 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> |
| | |
| | | /// </summary> |
| | | public int state = 0; |
| | | |
| | | public List<string> PropertyArray = new List<string>(); |
| | | |
| | | /// <summary> |
| | | /// 拼接、获取A协议操作数据 |
| | |
| | | { |
| | | |
| | | 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; |
| | | } |