陈嘉乐
2020-12-03 0f2e0147e8990e913d16d99bc1b94fb6bc53abd7
HDL_ON/Entity/Function/FloorHeating.cs
@@ -6,11 +6,11 @@
    public class FloorHeating : Function
    {
        /*
        *地热:trait: [switch, mode, temperature, lock]
        *地热:trait: [switch, mode, set_temperature, lock]
        *属性 描述
        *switch   on/off
        *mode    day, night,away, vacation, timer
        *temperature value(只读)
        *set_temperature value(只读)
        *lock   boolean(Lock锁定控制)
        *set_ point   up,down,value
        */
@@ -48,30 +48,30 @@
                }
            }
        }
        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] : "";
                    _trait_mode.curValue = _trait_mode.value.Count > 0 ? _trait_mode.value[0] : "";
                }
                return _trait_mode;
            }
@@ -95,7 +95,7 @@
                try
                {
                    byte index = 0;
                    switch (trait_mode.value.ToString())
                    switch (trait_mode.curValue.ToString())
                    {
                        case "day":
                            index = 2;
@@ -129,22 +129,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;
                }
@@ -164,63 +164,36 @@
        public int indoorTemp = 20;
        Trait _trait_temperature;
        FunctionAttributes _trait_temp;
        /// <summary>
        /// 当前温度
        /// </summary>/// <summary>
        /// 当前空调温度
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public double curTemp
        public FunctionAttributes trait_temp
        {
            get
            {
                try
                if (_trait_temp == 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_temp = attributes.Find((obj) => obj.key == "set_temperature");
                    //找不到属性需要声明一个,防止报错闪退
                    if (_trait_temperature == null)
                    if (_trait_temp == null)
                    {
                        _trait_temperature = new Trait()
                        _trait_temp = new FunctionAttributes()
                        {
                            name = "temperature",
                            value_key = new List<string>(),
                            max = 4,
                            min = 0,
                            key = "set_temperature",
                            value = new List<string> { },
                            max = 30,
                            min = 5,
                        };
                    }
                    _trait_temperature.value = _trait_temperature.value_key[_trait_temperature.min];
                    _trait_temp.curValue = 16;
                }
                _trait_temperature.value = value;
                return _trait_temp;
            }
        }
        /// <summary>
        /// 当前模式的icon路径
        /// </summary>
@@ -232,7 +205,7 @@
                try
                {
                    var imagePath = "FunctionIcon/AC/HeatingIcon.png";
                    switch (trait_mode.value)
                    switch (trait_mode.curValue)
                    {
                        case "day":
                            imagePath = "FunctionIcon/AC/HeatingIcon.png";