| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using Newtonsoft.Json.Linq; |
| | | using Shared; |
| | | |
| | | namespace HDL_ON.Entity |
| | | { |
| | | public class AC : Function |
| | | { |
| | | /* |
| | | * 空调:trait: [switch, mode, fan, temperature, swing, lock]
|
| | | * 空调:trait: [switch, mode, fan, set_temperature, swing, lock]
|
| | | * 属性 描述
|
| | | * on_off on/off
|
| | | * mode mode: auto, cool, heat, dry, fan
|
| | | * fan high, medium, low, auto
|
| | | * temperature up,down,value
|
| | | * set_temperature up,down,value
|
| | | * swing up/down/left/right
|
| | | * lock boolean (Lock锁定控制) |
| | | */ |
| | |
| | | { |
| | | if (_trait_temp == null) |
| | | { |
| | | _trait_temp = function.Find((obj) => obj.name == "temperature"); |
| | | _trait_temp = function.Find((obj) => obj.name == "set_temperature"); |
| | | //找不到属性需要声明一个,防止报错闪退 |
| | | if (_trait_temp == null) |
| | | { |
| | | _trait_temp = new Trait() |
| | | { |
| | | name = "temperature", |
| | | name = "set_temperature", |
| | | value_key = new List<string> { }, |
| | | max = 32, |
| | | min = 16, |
| | |
| | | return _trait_temp; |
| | | } |
| | | } |
| | | |
| | | |
| | | Trait _trait_swting; |
| | | [Newtonsoft.Json.JsonIgnore] |
| | |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 拼接、获取A协议操作数据 |
| | | /// </summary> |
| | | public override JObject GetSendJObject(CommandType_A command) |
| | | { |
| | | var sendJob = new JObject(); |
| | | if (command == CommandType_A.write) |
| | | { |
| | | sendJob = new JObject { { "Namespace", vendor_code }, { "Command", command.ToString() }, { "Type", "device" } }; |
| | | JObject data = new JObject { { "sid", sid } }; |
| | | sendJob.Add("objects", data); |
| | | List<ControlData> controlData = new List<ControlData>(); |
| | | controlData.Add(new ControlData() |
| | | { |
| | | name = "on_off", |
| | | data_type = "Bool", |
| | | value = trait_on_off.value.ToString() |
| | | }); |
| | | |
| | | |
| | | } |
| | | else if (command == CommandType_A.read) |
| | | { |
| | | sendJob = new JObject { { "Namespace", vendor_code }, { "Command", command.ToString() }, { "Type", "device" } }; |
| | | var data = new JObject { { "sid", sid } }; |
| | | sendJob.Add("objects", data); |
| | | } |
| | | return sendJob; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |