| | |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public int curTempType = 0; |
| | | |
| | | /// <summary> |
| | | /// 当前空调模式 |
| | | /// 当前温度模式字符 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string curMode = "cool"; |
| | | public string curTempTypeString |
| | | { |
| | | get |
| | | { |
| | | if (curTempType == 0) |
| | | { |
| | | return "°C"; |
| | | } |
| | | else |
| | | { |
| | | return "°F"; |
| | | } |
| | | } |
| | | } |
| | | |
| | | ///// <summary> |
| | | ///// 当前空调模式 |
| | | ///// </summary> |
| | | //[Newtonsoft.Json.JsonIgnore] |
| | | //public string curMode = "cool"; |
| | | |
| | | /// <summary> |
| | | /// 当前模式索引 |
| | | /// bus控制命令使用 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public byte curModeIndex |
| | | { |
| | | get |
| | |
| | | try |
| | | { |
| | | byte index = 0; |
| | | switch (curMode) |
| | | switch (trait_mode.curValues.ToString()) |
| | | { |
| | | case "auto": |
| | | index = 3; |
| | |
| | | switch (value) |
| | | { |
| | | case 0: |
| | | curMode = "cool"; |
| | | trait_mode.curValues = "cool"; |
| | | break; |
| | | case 1: |
| | | curMode = "heat"; |
| | | trait_mode.curValues = "heat"; |
| | | break; |
| | | case 2: |
| | | curMode = "fan"; |
| | | trait_mode.curValues = "fan"; |
| | | break; |
| | | case 3: |
| | | curMode = "auto"; |
| | | trait_mode.curValues = "auto"; |
| | | break; |
| | | case 4: |
| | | curMode = "dry"; |
| | | trait_mode.curValues = "dry"; |
| | | break; |
| | | default: |
| | | curMode = "cool"; |
| | | trait_mode.curValues = "cool"; |
| | | break; |
| | | |
| | | } |
| | |
| | | try |
| | | { |
| | | byte index = 0; |
| | | switch (curFan) |
| | | switch (trait_fan.curValues.ToString()) |
| | | { |
| | | case "high": |
| | | index = 1; |
| | |
| | | switch (value) |
| | | { |
| | | case 0: |
| | | curFan = "auto"; |
| | | trait_fan.curValues = "auto"; |
| | | break; |
| | | case 1: |
| | | curFan = "high"; |
| | | trait_fan.curValues = "high"; |
| | | break; |
| | | case 2: |
| | | curFan = "medium"; |
| | | trait_fan.curValues = "medium"; |
| | | break; |
| | | case 3: |
| | | curFan = "low"; |
| | | trait_fan.curValues = "low"; |
| | | break; |
| | | default: |
| | | curFan = "high"; |
| | | trait_fan.curValues = "high"; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | Trait _trait_mode; |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public Trait trait_mode |
| | | { |
| | | get |
| | | { |
| | | if (_trait_mode == null) |
| | | { |
| | | _trait_mode = propertList.Find((obj) => obj.attri == "mode"); |
| | | //找不到属性需要声明一个,防止报错闪退 |
| | | if (_trait_mode == null) |
| | | { |
| | | _trait_mode = new Trait() |
| | | { |
| | | attri = "mode", |
| | | value = new List<string> { "auto", "cool", "heat", "dry", "fan" }, |
| | | max = 4, |
| | | min = 0, |
| | | }; |
| | | } |
| | | _trait_mode.curValues = _trait_mode.value.Count > 0 ? _trait_mode.value[0] : ""; |
| | | } |
| | | return _trait_mode; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 空调模式 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public List<string> mode |
| | | public List<string> modeList |
| | | { |
| | | get |
| | | { |
| | | try |
| | | { |
| | | //#if DEBUG |
| | | // return new List<string> { "cool", "heat", "dry", "fan", "auto"}; |
| | | //#endif |
| | | string b = ""; |
| | | dicPropert.TryGetValue("mode", out b); |
| | | if (b == "") |
| | | { |
| | | return new List<string> { "auto", "cool", "heat", "dry", "fan" }; |
| | | } |
| | | return new List<string>(b.Split(",")); |
| | | return trait_mode.value; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | return new List<string> { "auto", "cool", "heat", "dry", "fan" }; |
| | | } |
| | | } |
| | | set |
| | | { |
| | | try |
| | | { |
| | | dicPropert["mode"] = value.ToString(); |
| | | } |
| | | catch |
| | | { |
| | | MainPage.Log("mode 数据刷新失败."); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 当前空调风速 |
| | | /// </summary> |
| | | Trait _trait_fan; |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string curFan = "high"; |
| | | |
| | | public Trait trait_fan { |
| | | get |
| | | { |
| | | if (_trait_fan == null) |
| | | { |
| | | _trait_fan = propertList.Find((obj) => obj.attri == "fan"); |
| | | //找不到属性需要声明一个,防止报错闪退 |
| | | if (_trait_fan == null) |
| | | { |
| | | _trait_fan = new Trait() |
| | | { |
| | | attri = "fan", |
| | | value = new List<string> { "high", "medium", "low", "auto" }, |
| | | max = 3, |
| | | min = 0, |
| | | }; |
| | | } |
| | | _trait_fan.curValues = _trait_fan.value.Count > 0 ? _trait_fan.value[0] : ""; |
| | | } |
| | | return _trait_fan; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 空调风速模式 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public List<string> fan |
| | | public List<string> fan_List |
| | | { |
| | | get |
| | | { |
| | | try |
| | | { |
| | | //#if DEBUG |
| | | // return new List<string> { "high", "medium", "low", "auto" }; |
| | | //#endif |
| | | string b = ""; |
| | | dicPropert.TryGetValue("fan", out b); |
| | | if (b == "") |
| | | { |
| | | return new List<string> { "high", "medium", "low", "auto" }; |
| | | } |
| | | return new List<string>(b.Split(",")); |
| | | return trait_fan.value; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | public int curTemp = 20; |
| | | // temperature up, down, value |
| | | // swing up/down/left/right |
| | | |
| | | Trait _trait_swting; |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string curSwting; |
| | | public Trait trait_swting |
| | | { |
| | | get |
| | | { |
| | | if (_trait_swting == null) |
| | | { |
| | | _trait_swting = propertList.Find((obj) => obj.attri == "swting"); |
| | | //找不到属性需要声明一个,防止报错闪退 |
| | | if (_trait_swting == null) |
| | | { |
| | | _trait_swting = new Trait() |
| | | { |
| | | attri = "swting", |
| | | value = 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] : ""; |
| | | } |
| | | return _trait_swting; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 空调扫风模式 |
| | | /// 空调扫风模式列表 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public List<string> swting |
| | |
| | | { |
| | | try |
| | | { |
| | | #if DEBUG |
| | | return new List<string> { "up", "down", "left", "right" }; |
| | | #endif |
| | | string b = ""; |
| | | dicPropert.TryGetValue("swting", out b); |
| | | if (b == "") |
| | | { |
| | | return new List<string> { "up", "down", "left", "right" }; |
| | | } |
| | | return new List<string>(b.Split(",")); |
| | | |
| | | return trait_swting.value; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | try |
| | | { |
| | | var imagePath = "FunctionIcon/AC/CoolIcon.png"; |
| | | switch (curMode) |
| | | switch (trait_mode.curValues.ToString()) |
| | | { |
| | | case "auto": |
| | | imagePath = "FunctionIcon/AC/AutoIcon.png"; |
| | |
| | | try |
| | | { |
| | | var imagePath = "FunctionIcon/AC/WindHighIcon.png"; |
| | | switch (curFan) |
| | | switch (trait_fan.curValues.ToString()) |
| | | { |
| | | case "high": |
| | | imagePath = "FunctionIcon/AC/WindHighIcon.png"; |
| | |
| | | if (command == CommandType_A.write) |
| | | { |
| | | sendJob = new JObject { { "Namespace", vendor_code }, { "Command", command.ToString() }, { "Type", "device" } }; |
| | | JObject data = new JObject { { "openLevel", dicPropert["openLevel"] }, { "sid", sid } }; |
| | | JObject data = new JObject {{ "sid", sid } }; |
| | | sendJob.Add("objects", data); |
| | | } |
| | | else if (command == CommandType_A.read) |