From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 30 八月 2022 09:37:38 +0800
Subject: [PATCH] 合并了IOS的代码

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs |  103 +++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 75 insertions(+), 28 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs
index 5d48933..867258a 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitListForm.cs
@@ -24,6 +24,10 @@
         /// 婵�娲荤殑璁惧鍦板潃
         /// </summary>
         private string actionDeviceKeys = null;
+        /// <summary>
+        /// 鎺ユ敹鍥炲鐨勭鐐�
+        /// </summary>
+        private HashSet<int> listReceivePoint = new HashSet<int>();
 
         #endregion
 
@@ -36,6 +40,11 @@
         public void ShowForm(string i_diviceMac)
         {
             this.listDevice = Common.LocalDevice.Current.GetDevicesByMac(i_diviceMac);
+            //鏀堕泦鍏ㄩ儴绔偣
+            foreach (var device in this.listDevice)
+            {
+                listReceivePoint.Add(device.DeviceEpoint);
+            }
             //璁剧疆澶撮儴淇℃伅
             base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uIndoorUnitSettion));
 
@@ -133,9 +142,19 @@
             btnValue.Y = Application.GetRealHeight(58);
             btnValue.X = frameTable.Width - Application.GetRealWidth(300 + 58);
             btnValue.TextAlignment = TextAlignment.CenterRight;
-            btnValue.TextID = R.MyInternationalizationString.uGetting;
             frameTable.AddChidren(btnValue, ChidrenBindMode.BindEvent);
             rowInfo.btnValue = btnValue;
+            //瀹ゅ唴娓╁害
+            if (device.currentLocalTemperature == 0)
+            {
+                //0鈩�
+                btnValue.Text = "0.0鈩�";
+            }
+            else
+            {
+                btnValue.Text = device.currentLocalTemperature + ".0鈩�";
+            }
+
             //璀﹀憡鍥炬爣
             var btnWarningIcon = new IconViewControl(69);
             btnWarningIcon.X = btnIconBack.X;
@@ -164,28 +183,46 @@
             {
                 if (btnSwitch.IsSelected == false)
                 {
-                    //鎵撳紑绌鸿皟
-                    var result = await HdlDeviceAirConditionerLogic.Current.OpenAirConditioner(device);
-                    if (result == false)
+                    //濡傛灉涓嶆槸铏氭嫙浣忓畢鐨勮瘽
+                    if (Common.Config.Instance.Home.IsVirtually == false)
                     {
-                        return;
+                        //鎵撳紑绌鸿皟
+                        var result = await HdlDeviceAirConditionerLogic.Current.OpenAirConditioner(device);
+                        if (result == false)
+                        {
+                            return;
+                        }
                     }
                     btnIcon.IsSelected = true;
                     btnIconBack.BackgroundColor = 0xfffef1ed;
                 }
                 else
                 {
-                    //鍏抽棴绌鸿皟
-                    var result = await HdlDeviceAirConditionerLogic.Current.CloseAirConditioner(device);
-                    if (result == false)
+                    //濡傛灉涓嶆槸铏氭嫙浣忓畢鐨勮瘽
+                    if (Common.Config.Instance.Home.IsVirtually == false)
                     {
-                        return;
+                        //鍏抽棴绌鸿皟
+                        var result = await HdlDeviceAirConditionerLogic.Current.CloseAirConditioner(device);
+                        if (result == false)
+                        {
+                            return;
+                        }
                     }
                     btnIcon.IsSelected = false;
                     btnIconBack.BackgroundColor = 0xfff5f6fa;
                 }
                 btnSwitch.IsSelected = !btnSwitch.IsSelected;
+                //濡傛灉鏄櫄鎷熶綇瀹呯殑璇�
+                if (Common.Config.Instance.Home.IsVirtually == true)
+                {
+                    device.currentSystemMode = btnSwitch.IsSelected == true ? 3 : 0;
+                }
             };
+            //濡傛灉鏄睍绀烘ā鏉跨殑璇�
+            if (Common.Config.Instance.Home.IsShowTemplate == true)
+            {
+                btnSwitch.CanClick = false;
+            }
 
             frameTable.ButtonClickEvent += (sender, e) =>
             {
@@ -207,17 +244,31 @@
         /// </summary>
         private void SetReadAttributeComand()
         {
+            //濡傛灉鏄櫄鎷熶綇瀹呮垨鑰呭睍绀烘ā鏉跨殑璇�
+            if (Common.Config.Instance.Home.IsShowTemplate == true || Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return;
+            }
             HdlThreadLogic.Current.RunThread(() =>
             {
-                for (int i = 0; i < listDevice.Count; i++)
+                while (this.listReceivePoint.Count > 0 && this.Parent != null)
                 {
-                    if (this.Parent == null)
+                    for (int i = 0; i < listDevice.Count; i++)
                     {
-                        return;
+                        if (this.Parent == null)
+                        {
+                            return;
+                        }
+                        //宸茬粡鍙戦�佽繃浜�,灏变笉鐢ㄥ啀鍙戦��
+                        if (this.listReceivePoint.Contains(listDevice[i].DeviceEpoint) == true)
+                        {
+                            //璇诲彇鐘舵��
+                            HdlDeviceAttributeLogic.Current.SendThermostatStatuComand(listDevice[i]);
+                            System.Threading.Thread.Sleep(200);
+                        }
                     }
-                    //璇诲彇鐘舵��
-                    HdlDeviceAttributeLogic.Current.SendThermostatStatuComand(listDevice[i]);
-                    System.Threading.Thread.Sleep(200);
+                    //3绉掑悗鍐嶆寰幆
+                    System.Threading.Thread.Sleep(3000);
                 }
             });
         }
@@ -238,6 +289,13 @@
                 {
                     return;
                 }
+                var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys);
+                if (localDevice == null)
+                {
+                    return;
+                }
+                //宸茬粡鎺ユ敹鍒版暟鎹�,鍒欑Щ闄ょ鐐�
+                this.listReceivePoint.Remove(device.DeviceEpoint);
 
                 var rowInfo = dicControl[mainkeys];
                 for (int i = 0; i < device.DeviceStatusReport.AttriBute.Count; i++)
@@ -248,25 +306,14 @@
                         HdlThreadLogic.Current.RunMain(() =>
                         {
                             //瀹ゅ唴娓╁害
-                            if (data.AttriButeData == 0)
+                            if (((AC)localDevice).currentLocalTemperature == 0)
                             {
                                 //0鈩�
                                 rowInfo.btnValue.Text = "0.0鈩�";
                             }
-                            else if (data.AttriButeData > 32767)
-                            {
-                                //璐熸暟(鐗规畩澶勭悊)
-                                string strValue = (data.AttriButeData - 65536).ToString();
-                                //灏忔暟鐐归渶瑕佷竴浣�
-                                strValue = strValue.Substring(0, strValue.Length - 1);
-                                rowInfo.btnValue.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�";
-                            }
                             else
                             {
-                                //灏忔暟鐐归渶瑕佷竴浣�
-                                string strValue = data.AttriButeData.ToString();
-                                strValue = strValue.Substring(0, strValue.Length - 1);
-                                rowInfo.btnValue.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�";
+                                rowInfo.btnValue.Text = ((AC)localDevice).currentLocalTemperature + ".0鈩�";
                             }
                         });
                     }

--
Gitblit v1.8.0