| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using Newtonsoft.Json.Linq; |
| | | using Shared; |
| | | |
| | | namespace HDL_ON.Entity |
| | | { |
| | |
| | | /// <summary> |
| | | /// 当前温度模式字符 |
| | | /// </summary> |
| | | public string curTempTypeString |
| | | public string tempUnitString |
| | | { |
| | | get |
| | | { |
| | |
| | | try |
| | | { |
| | | byte index = 0; |
| | | switch (trait_mode.curValues.ToString()) |
| | | switch (trait_mode.value.ToString()) |
| | | { |
| | | case "auto": |
| | | index = 3; |
| | |
| | | switch (value) |
| | | { |
| | | case 0: |
| | | trait_mode.curValues = "cool"; |
| | | trait_mode.value = "cool"; |
| | | break; |
| | | case 1: |
| | | trait_mode.curValues = "heat"; |
| | | trait_mode.value = "heat"; |
| | | break; |
| | | case 2: |
| | | trait_mode.curValues = "fan"; |
| | | trait_mode.value = "fan"; |
| | | break; |
| | | case 3: |
| | | trait_mode.curValues = "auto"; |
| | | trait_mode.value = "auto"; |
| | | break; |
| | | case 4: |
| | | trait_mode.curValues = "dry"; |
| | | trait_mode.value = "dry"; |
| | | break; |
| | | default: |
| | | trait_mode.curValues = "cool"; |
| | | trait_mode.value = "cool"; |
| | | break; |
| | | |
| | | } |
| | |
| | | try |
| | | { |
| | | byte index = 0; |
| | | switch (trait_fan.curValues.ToString()) |
| | | switch (trait_fan.value.ToString()) |
| | | { |
| | | case "high": |
| | | index = 1; |
| | |
| | | switch (value) |
| | | { |
| | | case 0: |
| | | trait_fan.curValues = "auto"; |
| | | trait_fan.value = "auto"; |
| | | break; |
| | | case 1: |
| | | trait_fan.curValues = "high"; |
| | | trait_fan.value = "high"; |
| | | break; |
| | | case 2: |
| | | trait_fan.curValues = "medium"; |
| | | trait_fan.value = "medium"; |
| | | break; |
| | | case 3: |
| | | trait_fan.curValues = "low"; |
| | | trait_fan.value = "low"; |
| | | break; |
| | | default: |
| | | trait_fan.curValues = "high"; |
| | | trait_fan.value = "high"; |
| | | break; |
| | | } |
| | | } |
| | |
| | | { |
| | | if (_trait_mode == null) |
| | | { |
| | | _trait_mode = function.Find((obj) => obj.attri == "mode"); |
| | | _trait_mode = function.Find((obj) => obj.name == "mode"); |
| | | //找不到属性需要声明一个,防止报错闪退 |
| | | if (_trait_mode == null) |
| | | { |
| | | _trait_mode = new Trait() |
| | | { |
| | | attri = "mode", |
| | | value = new List<string> { "auto", "cool", "heat", "dry", "fan" }, |
| | | name = "mode", |
| | | value_key = new List<string> { "auto", "cool", "heat", "dry", "fan" }, |
| | | max = 4, |
| | | min = 0, |
| | | }; |
| | | } |
| | | _trait_mode.curValues = _trait_mode.value.Count > 0 ? _trait_mode.value[0] : ""; |
| | | _trait_mode.value = _trait_mode.value_key.Count > 0 ? _trait_mode.value_key[0] : ""; |
| | | } |
| | | return _trait_mode; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 空调模式 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public List<string> modeList |
| | | { |
| | | get |
| | | { |
| | | try |
| | | { |
| | | return trait_mode.value; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"ac get mode error : {ex.Message}"); |
| | | return new List<string> { "auto", "cool", "heat", "dry", "fan" }; |
| | | } |
| | | } |
| | | } |
| | | |
| | | Trait _trait_fan; |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public Trait trait_fan { |
| | | public Trait trait_fan |
| | | { |
| | | get |
| | | { |
| | | if (_trait_fan == null) |
| | | { |
| | | _trait_fan = function.Find((obj) => obj.attri == "fan"); |
| | | _trait_fan = function.Find((obj) => obj.name == "fan"); |
| | | //找不到属性需要声明一个,防止报错闪退 |
| | | if (_trait_fan == null) |
| | | { |
| | | _trait_fan = new Trait() |
| | | { |
| | | attri = "fan", |
| | | value = new List<string> { "high", "medium", "low", "auto" }, |
| | | name = "fan", |
| | | value_key = new List<string> { "high", "medium", "low", "auto" }, |
| | | max = 3, |
| | | min = 0, |
| | | }; |
| | | } |
| | | _trait_fan.curValues = _trait_fan.value.Count > 0 ? _trait_fan.value[0] : ""; |
| | | _trait_fan.value = _trait_fan.value_key.Count > 0 ? _trait_fan.value_key[0] : ""; |
| | | } |
| | | return _trait_fan; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 空调风速模式 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public List<string> fan_List |
| | | { |
| | | get |
| | | { |
| | | try |
| | | { |
| | | return trait_fan.value; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"ac get fan error : {ex.Message}"); |
| | | return new List<string> { "high", "medium", "low", "auto" }; |
| | | } |
| | | } |
| | | } |
| | | |
| | | Trait _trait_temp; |
| | | /// <summary> |
| | | /// 当前空调温度 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public int curTemp = 20; |
| | | // temperature up, down, value |
| | | // swing up/down/left/right |
| | | public Trait trait_temp |
| | | { |
| | | get |
| | | { |
| | | if (_trait_temp == null) |
| | | { |
| | | _trait_temp = function.Find((obj) => obj.name == "temperature"); |
| | | //找不到属性需要声明一个,防止报错闪退 |
| | | if (_trait_temp == null) |
| | | { |
| | | _trait_temp = new Trait() |
| | | { |
| | | name = "temperature", |
| | | value_key = new List<string> { }, |
| | | max = 32, |
| | | min = 16, |
| | | }; |
| | | } |
| | | _trait_temp.value = 16; |
| | | } |
| | | return _trait_temp; |
| | | } |
| | | } |
| | | |
| | | |
| | | Trait _trait_swting; |
| | | [Newtonsoft.Json.JsonIgnore] |
| | |
| | | { |
| | | if (_trait_swting == null) |
| | | { |
| | | _trait_swting = function.Find((obj) => obj.attri == "swting"); |
| | | _trait_swting = function.Find((obj) => obj.name == "swting"); |
| | | //找不到属性需要声明一个,防止报错闪退 |
| | | if (_trait_swting == null) |
| | | { |
| | | _trait_swting = new Trait() |
| | | { |
| | | attri = "swting", |
| | | value = new List<string> { "up", "down", "left", "right" }, |
| | | name = "swting", |
| | | value_key = new List<string> { "up", "down", "left", "right" }, |
| | | max = 3, |
| | | min = 0, |
| | | }; |
| | | } |
| | | _trait_swting.curValues = _trait_swting.value.Count > 0 ? _trait_swting.value[trait_mode.min] : ""; |
| | | _trait_swting.value = _trait_swting.value_key.Count > 0 ? _trait_swting.value_key[trait_mode.min] : ""; |
| | | } |
| | | return _trait_swting; |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | return trait_swting.value; |
| | | return trait_swting.value_key; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | try |
| | | { |
| | | var imagePath = "FunctionIcon/AC/CoolIcon.png"; |
| | | switch (trait_mode.curValues.ToString()) |
| | | switch (trait_mode.value.ToString()) |
| | | { |
| | | case "auto": |
| | | imagePath = "FunctionIcon/AC/AutoIcon.png"; |
| | |
| | | try |
| | | { |
| | | var imagePath = "FunctionIcon/AC/WindHighIcon.png"; |
| | | switch (trait_fan.curValues.ToString()) |
| | | switch (trait_fan.value.ToString()) |
| | | { |
| | | case "high": |
| | | imagePath = "FunctionIcon/AC/WindHighIcon.png"; |
| | |
| | | { |
| | | name = "on_off", |
| | | data_type = "Bool", |
| | | value = on_off |
| | | value = trait_on_off.value.ToString() |
| | | }); |
| | | |
| | | |