wxr
2020-11-04 e6a26ee148587327478d9a82624a820c907b6e16
HDL_ON/Entity/Function/FloorHeating.cs
@@ -6,12 +6,13 @@
    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 up,down,value
        *set_temperature value(只读)
        *lock   boolean(Lock锁定控制)
        *set_ point   up,down,value
        */
        public FloorHeating()
        {
@@ -33,7 +34,7 @@
        /// <summary>
        /// 当前温度模式字符
        /// </summary>
        public string curTempTypeString
        public string tempUnitString
        {
            get
            {
@@ -47,20 +48,46 @@
                }
            }
        }
        Trait _trait_mode;
        /// <summary>
        /// 当前模式
        /// 模式属性
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public string curMode = "day";
        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> { "day", "night", "away", "normal", "timer" },
                            max = 4,
                            min = 0,
                        };
                    }
                    _trait_mode.value = _trait_mode.value_key.Count > 0 ? _trait_mode.value_key[0] : "";
                }
                return _trait_mode;
            }
        }
        /// <summary>
        /// 工作模式对应的工作温度
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public Dictionary<string, byte> modeTemp = new Dictionary<string, byte>();
        /// <summary>
        /// 当前模式索引
        /// bus控制命令使用
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public byte curModeIndex
        {
            get
@@ -68,7 +95,7 @@
                try
                {
                    byte index = 0;
                    switch (curMode)
                    switch (trait_mode.value.ToString())
                    {
                        case "day":
                            index = 2;
@@ -79,7 +106,7 @@
                        case "away":
                            index = 4;
                            break;
                        case "ordinary":
                        case "normal":
                            index = 1;
                            break;
                        case "timer":
@@ -102,62 +129,24 @@
                switch (value)
                {
                    case 5:
                        curMode = "timer";
                        trait_mode.value = "timer";
                        break;
                    case 1:
                        curMode = "ordinary";
                        trait_mode.value = "normal";
                        break;
                    case 2:
                        curMode = "day";
                        trait_mode.value = "day";
                        break;
                    case 3:
                        curMode = "night";
                        trait_mode.value = "night";
                        break;
                    case 4:
                        curMode = "away";
                        trait_mode.value = "away";
                        break;
                    default:
                        curMode = "cool";
                        trait_mode.value = "cool";
                        break;
                }
            }
        }
        [Newtonsoft.Json.JsonIgnore]
        public Trait trait_mode;
        /// <summary>
        /// 模式列表
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public List<string> modeList
        {
            get
            {
                try
                {
                    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> { "day", "night", "away", "timer", "ordinary" },
                                max = 4,
                                min = 0,
                            };
                        }
                        trait_mode.curValues = trait_mode.value[trait_mode.min];
                    }
                    return trait_mode.value;
                }
                catch (Exception ex)
                {
                    MainPage.Log($"ac get mode error : {ex.Message}");
                    return new List<string> { "day", "night", "away", "timer", "ordinary" };
                }
            }
        }
@@ -173,133 +162,38 @@
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public int indoorTemp = 20;
        Trait _trait_temp;
        /// <summary>
        /// 当前温度
        /// </summary>/// <summary>
        /// 当前空调温度
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public int curTemp
        public Trait trait_temp
        {
            get
            {
                switch (curMode)
                if (_trait_temp == null)
                {
                    case "day":
                        if (!modeTemp.ContainsKey("day"))
                    _trait_temp = function.Find((obj) => obj.name == "set_temperature");
                    //找不到属性需要声明一个,防止报错闪退
                    if (_trait_temp == null)
                    {
                        _trait_temp = new Trait()
                        {
                            modeTemp.Add("day", 20);
                        }
                        return modeTemp["day"];
                    case "night":
                        if (!modeTemp.ContainsKey("night"))
                        {
                            modeTemp.Add("night", 20);
                        }
                        return modeTemp["night"];
                    case "away":
                        if (!modeTemp.ContainsKey("away"))
                        {
                            modeTemp.Add("away", 20);
                        }
                        return modeTemp["away"];
                    case "ordinary":
                        if (!modeTemp.ContainsKey("ordinary"))
                        {
                            modeTemp.Add("ordinary", 20);
                        }
                        return modeTemp["ordinary"];
                    case "timer":
                        if (timeFlag == 0)
                        {
                            if (!modeTemp.ContainsKey("day"))
                            {
                                modeTemp.Add("day", 20);
                            }
                            return modeTemp["day"];
                        }
                        else
                        {
                            if (!modeTemp.ContainsKey("night"))
                            {
                                modeTemp.Add("night", 20);
                            }
                            return modeTemp["night"];
                        }
                            name = "set_temperature",
                            value_key = new List<string> { },
                            max = 30,
                            min = 5,
                        };
                    }
                    _trait_temp.value = 16;
                }
                return 20;
            }
            set
            {
                switch (curMode)
                {
                    case "day":
                        if (!modeTemp.ContainsKey("day"))
                        {
                            modeTemp.Add("day", (byte)value);
                        }
                        else
                        {
                            modeTemp["day"] = (byte)value;
                        }
                        return;
                    case "night":
                        if (!modeTemp.ContainsKey("night"))
                        {
                            modeTemp.Add("night", (byte)value);
                        }
                        else
                        {
                            modeTemp["night"] = (byte)value;
                        }
                        break;
                    case "away":
                        if (!modeTemp.ContainsKey("away"))
                        {
                            modeTemp.Add("away", (byte)value);
                        }
                        else
                        {
                            modeTemp["away"] = (byte)value;
                        }
                        break;
                    case "ordinary":
                        if (!modeTemp.ContainsKey("ordinary"))
                        {
                            modeTemp.Add("ordinary", (byte)value);
                        }
                        else
                        {
                            modeTemp["ordinary"] = (byte)value;
                        }
                        break;
                    case "timer":
                        if (timeFlag == 0)
                        {
                            if (!modeTemp.ContainsKey("day"))
                            {
                                modeTemp.Add("day", (byte)value);
                            }
                            else
                            {
                                modeTemp["day"] = (byte)value;
                            }
                        }
                        else
                        {
                            if (!modeTemp.ContainsKey("night"))
                            {
                                modeTemp.Add("night", (byte)value);
                            }
                            else
                            {
                                modeTemp["night"] = (byte)value;
                            }
                        }
                        break;
                }
                return _trait_temp;
            }
        }
        /// <summary>
        /// 当前模式的icon路径
        /// </summary>
@@ -311,7 +205,7 @@
                try
                {
                    var imagePath = "FunctionIcon/AC/HeatingIcon.png";
                    switch (curMode)
                    switch (trait_mode.value)
                    {
                        case "day":
                            imagePath = "FunctionIcon/AC/HeatingIcon.png";
@@ -325,7 +219,7 @@
                        case "timer":
                            imagePath = "FunctionIcon/AC/AutoIcon.png";
                            break;
                        case "ordinary":
                        case "normal":
                            imagePath = "FunctionIcon/FloorHeating/OrdinaryIcon.png";
                            break;
                        default: