From 8cd7b0fd1c53fc35a9817de31ab5d90f7dc7814b Mon Sep 17 00:00:00 2001
From: tzy <hxb@hdlchina.com.cn>
Date: 星期一, 29 三月 2021 16:59:43 +0800
Subject: [PATCH] 上传一个版本

---
 HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/AirFreshControlPage.cs |   63 +++++++++++++++++++++----------
 1 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/AirFreshControlPage.cs b/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/AirFreshControlPage.cs
index 9a6c5c9..4cf8131 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/AirFreshControlPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/AirFreshControlPage.cs
@@ -291,7 +291,7 @@
             {
                 frameBack.Close();
                 //鍙戦�佽妭鑳藉懡浠�
-                this.SendOtherComand(this.btnMode1, "energy", "true");
+                this.SendOtherComand(this.btnMode1, FunctionAttributeKey.Energy, "true");
             });
 
             //鑸掗��
@@ -300,7 +300,7 @@
             {
                 frameBack.Close();
                 //鍙戦�佽垝閫傚懡浠�
-                this.SendOtherComand(this.btnMode1, "energy", "false");
+                this.SendOtherComand(this.btnMode1, FunctionAttributeKey.Energy, "false");
             });
         }
 
@@ -338,7 +338,7 @@
             {
                 frameBack.Close();
                 //鍙戦�侀�氶鍛戒护
-                this.SendOtherComand(this.btnMode2, "mode", "fan");
+                this.SendOtherComand(this.btnMode2, FunctionAttributeKey.Mode, "fan");
             });
 
             //鍔犳箍
@@ -347,7 +347,7 @@
             {
                 frameBack.Close();
                 //鍙戦�佸姞婀垮懡浠�
-                this.SendOtherComand(this.btnMode2, "mode", "humidification");
+                this.SendOtherComand(this.btnMode2, FunctionAttributeKey.Mode, "humidification");
             });
         }
 
@@ -385,7 +385,7 @@
             {
                 frameBack.Close();
                 //鍙戦�佹。浣嶅懡浠�
-                this.SendOtherComand(this.btnFan, "fan", "level_1");
+                this.SendOtherComand(this.btnFan, FunctionAttributeKey.FanSpeed, "level_1");
             });
 
             //2妗�
@@ -394,7 +394,7 @@
             {
                 frameBack.Close();
                 //鍙戦�佹。浣嶅懡浠�
-                this.SendOtherComand(this.btnFan, "fan", "level_2");
+                this.SendOtherComand(this.btnFan, FunctionAttributeKey.FanSpeed, "level_2");
             });
 
             //3妗�
@@ -403,7 +403,7 @@
             {
                 frameBack.Close();
                 //鍙戦�佹。浣嶅懡浠�
-                this.SendOtherComand(this.btnFan, "fan", "level_3");
+                this.SendOtherComand(this.btnFan, FunctionAttributeKey.FanSpeed, "level_3");
             });
         }
 
@@ -532,9 +532,10 @@
 
             HdlThreadLogic.Current.RunThread(() =>
             {
-                var dic = new Dictionary<string, string>();
-                dic.Add(comadKey, comadValue);
-                Control.Ins.SendWriteCommand(this.device, dic, true);
+                //鑾峰彇鍙戦�佸懡浠ょ殑鏍锋澘(bus鍗忚鏄渶瑕佷竴娆℃�ф妸鍏ㄩ儴鍛戒护涓�璧峰彂閫佺殑)
+                var dic = this.GetSendComandSample();
+                dic[comadKey] = comadValue;
+                Control.Ins.SendWriteCommand(this.device, dic);
                 HdlThreadLogic.Current.RunMain(() =>
                 {
                     btnIcon.CanClick = true;
@@ -552,14 +553,34 @@
             string statu = this.btnSwitch.IsSelected == true ? "off" : "on";
             HdlThreadLogic.Current.RunThread(() =>
             {
-                var dic = new Dictionary<string, string>();
-                dic.Add(FunctionAttributeKey.OnOff, statu);
-                Control.Ins.SendWriteCommand(this.device, dic, true);
+                //鑾峰彇鍙戦�佸懡浠ょ殑鏍锋澘(bus鍗忚鏄渶瑕佷竴娆℃�ф妸鍏ㄩ儴鍛戒护涓�璧峰彂閫佺殑)
+                var dic = this.GetSendComandSample();
+                dic[FunctionAttributeKey.OnOff] = statu;
+                Control.Ins.SendWriteCommand(this.device, dic);
                 HdlThreadLogic.Current.RunMain(() =>
                 {
                     this.btnSwitch.CanClick = true;
                 });
             });
+        }
+
+        /// <summary>
+        /// 鑾峰彇鍙戦�佸懡浠ょ殑鏍锋澘(bus鍗忚鏄渶瑕佷竴娆℃�ф妸鍏ㄩ儴鍛戒护涓�璧峰彂閫佺殑)
+        /// </summary>
+        /// <returns></returns>
+        private Dictionary<string, string> GetSendComandSample()
+        {
+            var dic = new Dictionary<string, string>();
+            //寮�鍏�
+            dic[FunctionAttributeKey.OnOff] = this.airFreshData.Open == true ? "on" : "off";
+            //妯″紡
+            dic[FunctionAttributeKey.Mode] = this.airFreshData.Mode;
+            //鑺傝兘
+            dic[FunctionAttributeKey.Energy] = this.airFreshData.Energy;
+            //椋庨��
+            dic[FunctionAttributeKey.FanSpeed] = this.airFreshData.Fan ;
+
+            return dic;
         }
 
         #endregion
@@ -575,15 +596,15 @@
             {
                 var data = i_LocalDevice.attributes[i];
                 //寮�鍏�
-                if (data.key == "on_off") { this.airFreshData.Open = data.state == "on"; }
+                if (data.key == FunctionAttributeKey.OnOff) { this.airFreshData.Open = data.state == "on"; }
                 //妯″紡
-                else if (data.key == "mode") { this.airFreshData.Mode = data.state; }
+                else if (data.key == FunctionAttributeKey.Mode) { this.airFreshData.Mode = data.state; }
                 //鑺傝兘
-                else if (data.key == "energy") { this.airFreshData.Energy = data.state; }
+                else if (data.key == FunctionAttributeKey.Energy) { this.airFreshData.Energy = data.state; }
                 //椋庨��
-                else if (data.key == "fan") { this.airFreshData.Fan = data.state; }
+                else if (data.key == FunctionAttributeKey.FanSpeed) { this.airFreshData.Fan = data.state; }
                 //婀垮害
-                else if (data.key == "humidity")
+                else if (data.key == FunctionAttributeKey.Humidity)
                 {
                     if (data.state != string.Empty)
                     {
@@ -591,7 +612,7 @@
                     }
                 }
                 //瀹ゅ唴娓╁害
-                else if (data.key == "indoor_temp")
+                else if (data.key == FunctionAttributeKey.IndoorTemp)
                 {
                     if (data.state != string.Empty)
                     {
@@ -599,7 +620,7 @@
                     }
                 }
                 //瀹ゅ唴婀垮害
-                else if (data.key == "indoor_humidity")
+                else if (data.key == FunctionAttributeKey.IndoorHumidity)
                 {
                     if (data.state != string.Empty)
                     {
@@ -607,7 +628,7 @@
                     }
                 }
                 //杩囨护缃戝墿浣欓噺
-                else if (data.key == "filter_remain")
+                else if (data.key == FunctionAttributeKey.FilterRemain)
                 {
                     if (data.state != string.Empty)
                     {

--
Gitblit v1.8.0