| | |
| | | /// 如:是AC功能:特性:on_off,mode,fan,temperature |
| | | /// attri |
| | | /// </summary> |
| | | public List<Trait> function = new List<Trait>(); |
| | | public List<FunctionAttributes> function = new List<FunctionAttributes>(); |
| | | |
| | | /// <summary> |
| | | /// 房间ID列表 |
| | |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string lastState = ""; |
| | | |
| | | Trait _trait_on_off; |
| | | FunctionAttributes _trait_on_off; |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public Trait trait_on_off |
| | | public FunctionAttributes trait_on_off |
| | | { |
| | | get |
| | | { |
| | | if (_trait_on_off == null) |
| | | { |
| | | _trait_on_off = function.Find((obj) => obj.name == "on_off"); |
| | | _trait_on_off = function.Find((obj) => obj.key == "on_off"); |
| | | //找不到属性需要声明一个,防止报错闪退 |
| | | if (_trait_on_off == null) |
| | | { |
| | | _trait_on_off = new Trait() |
| | | _trait_on_off = new FunctionAttributes() |
| | | { |
| | | name = "on_off", |
| | | value_key = new List<string> { "on", "off" }, |
| | | key = "on_off", |
| | | value = new List<string> { "on", "off" }, |
| | | max = 1, |
| | | min = 0, |
| | | }; |
| | | } |
| | | _trait_on_off.value = "on"; |
| | | _trait_on_off.curValue = "on"; |
| | | } |
| | | return _trait_on_off; |
| | | } |
| | |
| | | { |
| | | var findRoom = DB_ResidenceData.rooms.Find(obj => obj.sid == roomId); |
| | | if (findRoom == null) |
| | | { |
| | | continue; |
| | | if(roomNameList != "") |
| | | } |
| | | if (roomNameList != "") |
| | | { |
| | | roomNameList += ","; |
| | | } |
| | |
| | | /// 更新时间 |
| | | /// </summary> |
| | | public DateTime refreshTime = DateTime.MinValue; |
| | | |
| | | /// <summary> |
| | | /// 获取控制发送数据 |
| | | /// </summary> |
| | | public AprotocolControlObj GetControlSendData(Dictionary<string, string> commandDictionary) |
| | | { |
| | | var sendDataObj = new AprotocolControlObj(); |
| | | sendDataObj.from_oid = ""; |
| | | sendDataObj.to_oid = ""; |
| | | sendDataObj.time_stamp = ""; |
| | | sendDataObj.type = "device_sid"; |
| | | sendDataObj.command = "write"; |
| | | |
| | | var acoList = new AprotocolControlData(); |
| | | acoList.sid = sid; |
| | | var aco = new AprotocolControlAttribute(); |
| | | foreach(var dic in commandDictionary) |
| | | { |
| | | aco.name = dic.Key; |
| | | aco.value = dic.Value; |
| | | acoList.function.Add(aco); |
| | | } |
| | | |
| | | sendDataObj.objects.Add(acoList); |
| | | |
| | | |
| | | return sendDataObj; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// A协议控制数据的对象 |
| | | /// </summary> |
| | | public class AprotocolControlObj |
| | | { |
| | | public List<AprotocolControlData> objects = new List<AprotocolControlData>(); |
| | | |
| | | public string from_oid = ""; |
| | | public string to_oid = ""; |
| | | public string time_stamp = ""; |
| | | public string type = ""; |
| | | public string command = ""; |
| | | } |
| | | /// <summary> |
| | | /// A协议控制数据 |
| | | /// </summary> |
| | | public class AprotocolControlData |
| | | { |
| | | |
| | | public string sid = ""; |
| | | public List<AprotocolControlAttribute> function = new List<AprotocolControlAttribute>(); |
| | | } |
| | | /// <summary> |
| | | /// A协议控制属性对象 |
| | | /// </summary> |
| | | public class AprotocolControlAttribute |
| | | { |
| | | public string name; |
| | | public string value; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 功能属性 |
| | | /// 属性字段解析:attri :属性内容,value 属性的值,max 最大值 min 最小值 |
| | | /// </summary> |
| | | public class Trait |
| | | public class FunctionAttributes |
| | | { |
| | | /// <summary> |
| | | /// 属性名称 |
| | | /// 属性键名 |
| | | /// </summary> |
| | | public string name; |
| | | List<string> _value_key; |
| | | public string key; |
| | | /// <summary> |
| | | /// 属性的值列表 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public List<string> value_key |
| | | { |
| | | get |
| | | { |
| | | return _value_key; |
| | | } |
| | | set |
| | | { |
| | | _value_key = value; |
| | | } |
| | | } |
| | | public List<string> value = new List<string>(); |
| | | /// <summary> |
| | | /// 最大值 |
| | | /// </summary> |
| | |
| | | /// <summary> |
| | | /// 当前值 |
| | | /// </summary> |
| | | public object value = new object(); |
| | | public object curValue = new object(); |
| | | |
| | | |
| | | //----app自定义 |
| | |
| | | return _uintString; |
| | | } |
| | | var us = ""; |
| | | switch (name) |
| | | switch (key) |
| | | { |
| | | case "temperature": |
| | | case "set_temperature": |
| | | us = "°C"; |
| | | break; |
| | | case "percent": |
| | |
| | | get |
| | | { |
| | | string text = ""; |
| | | switch (name) |
| | | switch (key) |
| | | { |
| | | case "on_off": |
| | | text = Language.StringByID(StringId.OnOff); |
| | |
| | | text = Language.StringByID(StringId.FanSpeed); |
| | | break; |
| | | case "temperature": |
| | | case "set_temperature": |
| | | text = Language.StringByID(StringId.Temp); |
| | | break; |
| | | case "delay": |
| | |
| | | //case "lock": |
| | | //case "ico": |
| | | //case "swing": |
| | | //case "set_ point": |
| | | //case "set_point": |
| | | //case "pm25": |
| | | //case "volume": |
| | | //case "vol_step": |
| | |
| | | /// </summary> |
| | | public string GetCurValueText() |
| | | { |
| | | return GetValueText(value.ToString()); |
| | | return GetValueText(curValue.ToString()); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | string text = ""; |
| | | value = value.Replace("{}", ""); |
| | | switch (name) |
| | | switch (key) |
| | | { |
| | | case "on_off": |
| | | text = value == "on" ? Language.StringByID(StringId.On) : Language.StringByID(StringId.OFF); |
| | | break; |
| | | case "temperature": |
| | | case "set_temperature": |
| | | case "brightness": |
| | | case "percent": |
| | | if (value == "") |
| | | { |
| | | this.value = this.min; |
| | | this.curValue = this.min; |
| | | text = this.min.ToString(); |
| | | } |
| | | else |
| | |
| | | text = Language.StringByID(StringId.Timer); |
| | | break; |
| | | default: |
| | | if (this.value_key.Contains("cool")) |
| | | if (this.value.Contains("cool")) |
| | | { |
| | | this.value = "cool"; |
| | | this.curValue = "cool"; |
| | | text = Language.StringByID(StringId.Cool); |
| | | } |
| | | else if (this.value_key.Contains("day")) |
| | | else if (this.value.Contains("day")) |
| | | { |
| | | this.value = "day"; |
| | | this.curValue = "day"; |
| | | text = Language.StringByID(StringId.Day); |
| | | } |
| | | else |
| | | { |
| | | foreach (var v in this.value_key) |
| | | foreach (var v in this.value) |
| | | { |
| | | this.value = v; |
| | | this.curValue = v; |
| | | text = GetCurValueText(); |
| | | } |
| | | } |
| | |
| | | text = Language.StringByID(StringId.Auto); |
| | | break; |
| | | default: |
| | | if (this.value_key.Contains("low")) |
| | | if (this.value.Contains("low")) |
| | | { |
| | | this.value = "low"; |
| | | this.curValue = "low"; |
| | | text = Language.StringByID(StringId.LowWindSpeed); |
| | | } |
| | | else |
| | | { |
| | | foreach (var v in this.value_key) |
| | | foreach (var v in this.value) |
| | | { |
| | | this.value = v; |
| | | this.curValue = v; |
| | | text = GetCurValueText(); |
| | | } |
| | | } |
| | |
| | | //case "lock": |
| | | //case "ico": |
| | | //case "swing": |
| | | //case "set_ point": |
| | | //case "set_point": |
| | | //case "pm25": |
| | | //case "volume": |
| | | //case "vol_step": |