From 7d005a7618e3d7a80d8ede3baf6ecc4bf8019cd5 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 01 九月 2020 15:22:09 +0800
Subject: [PATCH] 2020-09-01

---
 HDL_ON/Entity/Function/FloorHeating.cs |  237 +++++++++++++++++++---------------------------------------
 1 files changed, 79 insertions(+), 158 deletions(-)

diff --git a/HDL_ON/Entity/Function/FloorHeating.cs b/HDL_ON/Entity/Function/FloorHeating.cs
index c66dda9..d9cf8b3 100644
--- a/HDL_ON/Entity/Function/FloorHeating.cs
+++ b/HDL_ON/Entity/Function/FloorHeating.cs
@@ -10,8 +10,9 @@
         *灞炴�� 鎻忚堪
         *switch	on/off
         *mode    day, night,away, vacation, timer
-        *temperature up,down,value
+        *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");
+                    //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂��
+                    if (_trait_mode == null)
+                    {
+                        _trait_mode = new Trait()
+                        {
+                            name = "mode",
+                            value_key = new List<string> { "day", "night", "away", "vacation", "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 = function.Find((obj) => obj.attri == "mode");
-                        //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂��
-                        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,132 +162,64 @@
         /// </summary>
         [Newtonsoft.Json.JsonIgnore]
         public int indoorTemp = 20;
+
+
+        Trait _trait_temperature;
         /// <summary>
         /// 褰撳墠娓╁害
         /// </summary>
         [Newtonsoft.Json.JsonIgnore]
-        public int curTemp
+        public double curTemp
         {
             get
             {
-                switch (curMode)
+                try
                 {
-                    case "day":
-                        if (!modeTemp.ContainsKey("day"))
+                    if (_trait_temperature == null)
+                    {
+                        _trait_temperature = function.Find((obj) => obj.name == "temperature");
+                        //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂��
+                        if (_trait_temperature == null)
                         {
-                            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"))
+                            _trait_temperature = new Trait()
                             {
-                                modeTemp.Add("day", 20);
-                            }
-                            return modeTemp["day"];
+                                name = "temperature",
+                                value_key = new List<string>(),
+                                max = 32,
+                                min = 5,
+                            };
                         }
-                        else
-                        {
-                            if (!modeTemp.ContainsKey("night"))
-                            {
-                                modeTemp.Add("night", 20);
-                            }
-                            return modeTemp["night"];
-                        }
+                        _trait_temperature.value = 5;
+                    }
+                    return 5;
                 }
-                return 20;
+                catch (Exception ex)
+                {
+                    MainPage.Log($"ac get temp error : {ex.Message}");
+                    return 5;
+                }
             }
             set
             {
-                switch (curMode)
+                if (_trait_temperature == null)
                 {
-                    case "day":
-                        if (!modeTemp.ContainsKey("day"))
+                    _trait_temperature = function.Find((obj) => obj.name == "temperature");
+                    //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂��
+                    if (_trait_temperature == null)
+                    {
+                        _trait_temperature = new Trait()
                         {
-                            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;
+                            name = "temperature",
+                            value_key = new List<string>(),
+                            max = 4,
+                            min = 0,
+                        };
+                    }
+                    _trait_temperature.value = _trait_temperature.value_key[_trait_temperature.min];
                 }
+                _trait_temperature.value = value;
             }
         }
-            
 
         /// <summary>
         /// 褰撳墠妯″紡鐨刬con璺緞
@@ -311,7 +232,7 @@
                 try
                 {
                     var imagePath = "FunctionIcon/AC/HeatingIcon.png";
-                    switch (curMode)
+                    switch (trait_mode.value)
                     {
                         case "day":
                             imagePath = "FunctionIcon/AC/HeatingIcon.png";
@@ -325,7 +246,7 @@
                         case "timer":
                             imagePath = "FunctionIcon/AC/AutoIcon.png";
                             break;
-                        case "ordinary":
+                        case "normal":
                             imagePath = "FunctionIcon/FloorHeating/OrdinaryIcon.png";
                             break;
                         default:

--
Gitblit v1.8.0