wei
2020-12-17 bb6ad792b598927a5459a5fb6f6c27fb1aa9e94e
HDL_ON/Entity/Function/FloorHeating.cs
@@ -6,11 +6,11 @@
    public class FloorHeating : Function
    {
        /*
        *地热:trait: [switch, mode, temperature, lock]
        *地热:trait: [switch, mode, set_temp, lock]
        *属性 描述
        *switch   on/off
        *mode    day, night,away, vacation, timer
        *temperature value(只读)
        *set_temp value
        *lock   boolean(Lock锁定控制)
        *set_ point   up,down,value
        */
@@ -48,30 +48,33 @@
                }
            }
        }
        Trait _trait_mode;
        FunctionAttributes _trait_mode;
        /// <summary>
        /// 模式属性
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public Trait trait_mode
        public FunctionAttributes trait_mode
        {
            get
            {
                if (_trait_mode == null)
                {
                    _trait_mode = function.Find((obj) => obj.name == "mode");
                    _trait_mode = attributes.Find((obj) => obj.key == "mode");
                    //找不到属性需要声明一个,防止报错闪退
                    if (_trait_mode == null)
                    {
                        _trait_mode = new Trait()
                        _trait_mode = new FunctionAttributes()
                        {
                            name = "mode",
                            value_key = new List<string> { "day", "night", "away", "vacation", "timer" },
                            key = "mode",
                            value = new List<string> { "day", "night", "away", "normal", "timer" },
                            max = 4,
                            min = 0,
                        };
                    }
                    _trait_mode.value = _trait_mode.value_key.Count > 0 ? _trait_mode.value_key[0] : "";
                    if(_trait_mode.curValue.ToString() == "{}")
                    {
                        _trait_mode.curValue = "day";
                    }
                }
                return _trait_mode;
            }
@@ -95,7 +98,7 @@
                try
                {
                    byte index = 0;
                    switch (trait_mode.value.ToString())
                    switch (trait_mode.curValue.ToString())
                    {
                        case "day":
                            index = 2;
@@ -129,22 +132,22 @@
                switch (value)
                {
                    case 5:
                        trait_mode.value = "timer";
                        trait_mode.curValue = "timer";
                        break;
                    case 1:
                        trait_mode.value = "normal";
                        trait_mode.curValue = "normal";
                        break;
                    case 2:
                        trait_mode.value = "day";
                        trait_mode.curValue = "day";
                        break;
                    case 3:
                        trait_mode.value = "night";
                        trait_mode.curValue = "night";
                        break;
                    case 4:
                        trait_mode.value = "away";
                        trait_mode.curValue = "away";
                        break;
                    default:
                        trait_mode.value = "cool";
                        trait_mode.curValue = "cool";
                        break;
                }
@@ -157,70 +160,78 @@
        /// </summary>
        public byte timeFlag = 0;
        FunctionAttributes _trait_IndoorTemp;
        /// <summary>
        /// 室内温度
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public int indoorTemp = 20;
        Trait _trait_temperature;
        /// <summary>
        /// 当前温度
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public double curTemp
        public FunctionAttributes trait_IndoorTemp
        {
            get
            {
                try
                if (_trait_IndoorTemp == null)
                {
                    if (_trait_temperature == null)
                    {
                        _trait_temperature = function.Find((obj) => obj.name == "temperature");
                        //找不到属性需要声明一个,防止报错闪退
                        if (_trait_temperature == null)
                        {
                            _trait_temperature = new Trait()
                            {
                                name = "temperature",
                                value_key = new List<string>(),
                                max = 32,
                                min = 5,
                            };
                        }
                        _trait_temperature.value = 5;
                    }
                    return 5;
                }
                catch (Exception ex)
                {
                    MainPage.Log($"ac get temp error : {ex.Message}");
                    return 5;
                }
            }
            set
            {
                if (_trait_temperature == null)
                {
                    _trait_temperature = function.Find((obj) => obj.name == "temperature");
                    _trait_IndoorTemp = attributes.Find((obj) => obj.key == FunctionAttributeKey.IndoorTemp);
                    //找不到属性需要声明一个,防止报错闪退
                    if (_trait_temperature == null)
                    if (_trait_IndoorTemp == null)
                    {
                        _trait_temperature = new Trait()
                        _trait_IndoorTemp = new FunctionAttributes()
                        {
                            name = "temperature",
                            value_key = new List<string>(),
                            max = 4,
                            key = FunctionAttributeKey.IndoorTemp,
                            value = new List<string> { },
                            max = 30,
                            min = 0,
                        };
                        if (_trait_IndoorTemp.curValue.ToString() == "{}")
                            _trait_IndoorTemp.curValue = 0;
                    }
                    _trait_temperature.value = _trait_temperature.value_key[_trait_temperature.min];
                }
                _trait_temperature.value = value;
                //if (_trait_IndoorTemp.curValue.ToString().Length > 3)
                {
                    var vv = Convert.ToDouble(_trait_IndoorTemp.curValue);
                    _trait_IndoorTemp.curValue = Convert.ToInt32(vv);
                }
                return _trait_IndoorTemp;
            }
        }
        FunctionAttributes _trait_temp;
        /// <summary>
        /// 当前温度
        /// </summary>/// <summary>
        /// 当前空调温度
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public FunctionAttributes trait_temp
        {
            get
            {
                if (_trait_temp == null)
                {
                    _trait_temp = attributes.Find((obj) => obj.key == "set_temp");
                    //找不到属性需要声明一个,防止报错闪退
                    if (_trait_temp == null)
                    {
                        _trait_temp = new FunctionAttributes()
                        {
                            key = "set_temp",
                            value = new List<string> { },
                            max = 30,
                            min = 5,
                        };
                    }
                    if(_trait_temp.curValue.ToString() == "{}")
                        _trait_temp.curValue = 16;
                }
                //if (_trait_temp.curValue.ToString().Length > 3)
                {
                    var vv = Convert.ToDouble(_trait_temp.curValue);
                    _trait_temp.curValue = Convert.ToInt32(vv);
                }
                return _trait_temp;
            }
        }
        /// <summary>
        /// 当前模式的icon路径
        /// </summary>
@@ -232,7 +243,7 @@
                try
                {
                    var imagePath = "FunctionIcon/AC/HeatingIcon.png";
                    switch (trait_mode.value)
                    switch (trait_mode.curValue)
                    {
                        case "day":
                            imagePath = "FunctionIcon/AC/HeatingIcon.png";