using System;
|
using System.Collections.Generic;
|
|
namespace HDL_ON.Entity
|
{
|
public class AC : Function
|
{
|
/*
|
* 空调:trait: [switch, mode, fan, temperature, swing, lock]
|
* 属性 描述
|
* on_off on/off
|
* mode mode: auto, cool, heat, dry, fan
|
* fan high, medium, low, auto
|
* temperature up,down,value
|
* swing up/down/left/right
|
* lock boolean (Lock锁定控制)
|
*/
|
public AC()
|
{
|
}
|
/// <summary>
|
/// 当前温度模式
|
/// 0:摄氏度
|
/// 1:华氏度
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
public int curTempType = 0;
|
/// <summary>
|
/// 当前温度模式字符
|
/// </summary>
|
public string tempUnitString
|
{
|
get
|
{
|
if (curTempType == 0)
|
{
|
return "°C";
|
}
|
else
|
{
|
return "°F";
|
}
|
}
|
}
|
|
/// <summary>
|
/// 当前模式索引
|
/// bus控制命令使用
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
public byte curModeIndex
|
{
|
get
|
{
|
try
|
{
|
byte index = 0;
|
switch (trait_mode.value.ToString())
|
{
|
case "auto":
|
index = 3;
|
break;
|
case "cool":
|
index = 0;
|
break;
|
case "heat":
|
index = 1;
|
break;
|
case "dry":
|
index = 4;
|
break;
|
case "fan":
|
index = 2;
|
break;
|
default:
|
index = 0;
|
break;
|
}
|
return index;
|
}
|
catch (Exception ex)
|
{
|
MainPage.Log($"get curModeIndex error : {ex.Message}");
|
return 0;
|
}
|
}
|
set
|
{
|
switch (value)
|
{
|
case 0:
|
trait_mode.value = "cool";
|
break;
|
case 1:
|
trait_mode.value = "heat";
|
break;
|
case 2:
|
trait_mode.value = "fan";
|
break;
|
case 3:
|
trait_mode.value = "auto";
|
break;
|
case 4:
|
trait_mode.value = "dry";
|
break;
|
default:
|
trait_mode.value = "cool";
|
break;
|
|
}
|
}
|
}
|
/// <summary>
|
/// 当前风速索引
|
/// bus控制命令使用
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
public byte curFanIndex
|
{
|
get
|
{
|
try
|
{
|
byte index = 0;
|
switch (trait_fan.value.ToString())
|
{
|
case "high":
|
index = 1;
|
break;
|
case "medium":
|
index = 2;
|
break;
|
case "low":
|
index = 3;
|
break;
|
case "auto":
|
index = 0;
|
break;
|
default:
|
index = 0;
|
break;
|
}
|
return index;
|
}
|
catch (Exception ex)
|
{
|
MainPage.Log($"get curFanIndex error : {ex.Message}");
|
return 0;
|
}
|
}
|
set
|
{
|
switch (value)
|
{
|
case 0:
|
trait_fan.value = "auto";
|
break;
|
case 1:
|
trait_fan.value = "high";
|
break;
|
case 2:
|
trait_fan.value = "medium";
|
break;
|
case 3:
|
trait_fan.value = "low";
|
break;
|
default:
|
trait_fan.value = "high";
|
break;
|
}
|
}
|
}
|
|
Trait _trait_mode;
|
/// <summary>
|
/// 模式属性
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
public Trait trait_mode
|
{
|
get
|
{
|
if (_trait_mode == null)
|
{
|
_trait_mode = function.Find((obj) => obj.name == "mode");
|
//找不到属性需要声明一个,防止报错闪退
|
if (_trait_mode == null)
|
{
|
_trait_mode = new Trait()
|
{
|
name = "mode",
|
value_key = new List<string> { "auto", "cool", "heat", "dry", "fan" },
|
max = 4,
|
min = 0,
|
};
|
}
|
_trait_mode.value = _trait_mode.value_key.Count > 0 ? _trait_mode.value_key[0] : "";
|
}
|
return _trait_mode;
|
}
|
}
|
|
Trait _trait_fan;
|
[Newtonsoft.Json.JsonIgnore]
|
public Trait trait_fan
|
{
|
get
|
{
|
if (_trait_fan == null)
|
{
|
_trait_fan = function.Find((obj) => obj.name == "fan");
|
//找不到属性需要声明一个,防止报错闪退
|
if (_trait_fan == null)
|
{
|
_trait_fan = new Trait()
|
{
|
name = "fan",
|
value_key = new List<string> { "high", "medium", "low", "auto" },
|
max = 3,
|
min = 0,
|
};
|
}
|
_trait_fan.value = _trait_fan.value_key.Count > 0 ? _trait_fan.value_key[0] : "";
|
}
|
return _trait_fan;
|
}
|
}
|
|
Trait _trait_temp;
|
/// <summary>
|
/// 当前空调温度
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
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]
|
public Trait trait_swting
|
{
|
get
|
{
|
if (_trait_swting == null)
|
{
|
_trait_swting = function.Find((obj) => obj.name == "swting");
|
//找不到属性需要声明一个,防止报错闪退
|
if (_trait_swting == null)
|
{
|
_trait_swting = new Trait()
|
{
|
name = "swting",
|
value_key = new List<string> { "up", "down", "left", "right" },
|
max = 3,
|
min = 0,
|
};
|
}
|
_trait_swting.value = _trait_swting.value_key.Count > 0 ? _trait_swting.value_key[trait_mode.min] : "";
|
}
|
return _trait_swting;
|
}
|
}
|
/// <summary>
|
/// 空调扫风模式列表
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
public List<string> swting
|
{
|
get
|
{
|
try
|
{
|
return trait_swting.value_key;
|
}
|
catch (Exception ex)
|
{
|
MainPage.Log($"ac get swting error : {ex.Message}");
|
return new List<string> { "up", "down", "left", "right" };
|
}
|
}
|
}
|
/// <summary>
|
/// 室内温度
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
public int indoorTemp = 20;
|
|
/// <summary>
|
/// 当前模式的icon路径
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
public string curModeImage
|
{
|
get
|
{
|
try
|
{
|
var imagePath = "FunctionIcon/AC/CoolIcon.png";
|
switch (trait_mode.value.ToString())
|
{
|
case "auto":
|
imagePath = "FunctionIcon/AC/AutoIcon.png";
|
break;
|
case "cool":
|
imagePath = "FunctionIcon/AC/CoolIcon.png";
|
break;
|
case "heat":
|
imagePath = "FunctionIcon/AC/HeatingIcon.png";
|
break;
|
case "dry":
|
imagePath = "FunctionIcon/AC/DehumidificationIcon.png";
|
break;
|
case "fan":
|
imagePath = "FunctionIcon/AC/AirSupplyIcon.png";
|
break;
|
default:
|
imagePath = "FunctionIcon/AC/CoolIcon.png";
|
break;
|
}
|
return imagePath;
|
}
|
catch (Exception ex)
|
{
|
MainPage.Log($"ac ge curModeImage error : {ex.Message}");
|
return "FunctionIcon/AC/CoolIcon.png";
|
}
|
}
|
}
|
/// <summary>
|
/// 当前风速的icon路径
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
public string curFanImage
|
{
|
get
|
{
|
try
|
{
|
var imagePath = "FunctionIcon/AC/WindHighIcon.png";
|
switch (trait_fan.value.ToString())
|
{
|
case "high":
|
imagePath = "FunctionIcon/AC/WindHighIcon.png";
|
break;
|
case "medium":
|
imagePath = "FunctionIcon/AC/WindMediumIcon.png";
|
break;
|
case "low":
|
imagePath = "FunctionIcon/AC/WindLowIcon.png";
|
break;
|
case "auto":
|
imagePath = "FunctionIcon/AC/AutoIcon.png";
|
break;
|
default:
|
imagePath = "FunctionIcon/AC/WindHighIcon.png";
|
break;
|
}
|
return imagePath;
|
}catch (Exception ex)
|
{
|
MainPage.Log($"ac get curFanImage error : {ex.Message}");
|
return "FunctionIcon/AC/WindHighIcon.png";
|
}
|
}
|
}
|
|
}
|
}
|