From 9f326f4000847e6167d8166fa2f6a66f53cb3734 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 17 十二月 2020 09:07:13 +0800
Subject: [PATCH] 新云端Ver1.3

---
 ZigbeeApp/Shared/Phone/Category/CategoryMainForm.cs |  161 +++++++++++++++++++++++++++++++++--------------------
 1 files changed, 99 insertions(+), 62 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Category/CategoryMainForm.cs b/ZigbeeApp/Shared/Phone/Category/CategoryMainForm.cs
index d30d6cd..26f077a 100755
--- a/ZigbeeApp/Shared/Phone/Category/CategoryMainForm.cs
+++ b/ZigbeeApp/Shared/Phone/Category/CategoryMainForm.cs
@@ -67,9 +67,6 @@
             //鍏堟竻闄ゅ惂
             this.RemoveAll();
 
-            //鍒濆鍖栭粯璁ゆゼ灞侷D
-            this.InitDefultFloorId();
-
             //鍒濆鍖栧ご閮ㄦ帶浠�
             this.InitTopControl();
             //鍒濆鍖栦腑闂存帶浠�
@@ -78,6 +75,8 @@
             this.AddNormalDeviceReportEvent();
             //娣诲姞浼犳劅鍣ㄧ姸鎬佷笂鎶ヤ簨浠�
             this.AddSensorDeviceReportEvent();
+            //寮�鍚紶鎰熷櫒鐘舵�佽繕鍘熺殑绾跨▼
+            this.StartRecoverSenorStatuThread();
         }
 
         /// <summary>
@@ -92,8 +91,8 @@
             topFrameLayout.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
             this.AddChidren(topFrameLayout);
             //鏍囬鍒嗙被
-            var btnTitle = new NormalViewControl(300, 95, true);
-            btnTitle.X = ControlCommonResourse.XXLeft;
+            var btnTitle = new NormalViewControl(400, 95, true);
+            btnTitle.X = HdlControlResourse.XXLeft;
             btnTitle.Gravity = Gravity.CenterVertical;
             btnTitle.TextID = R.MyInternationalizationString.Category;
             btnTitle.TextSize = 24;
@@ -109,7 +108,7 @@
             topFrameLayout.AddChidren(btnTopRightAdd);
             btnTopRightAdd.ButtonClickEvent += (sender, e) =>
             {
-                if (UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 0)
+                if (HdlUserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 0)
                 {
                     //娣诲姞鍦烘櫙
                     var form = new AddOrEditorSceneForm();
@@ -120,7 +119,7 @@
                         this.RefreshBodyView();
                     };
                 }
-                else if (UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 2)
+                else if (HdlUserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 2)
                 {
                     //娣诲姞鑷姩鍖�
                     Device.Logic.SkipView.SkipAddLogic(0);
@@ -202,23 +201,23 @@
             var listTitle = new List<string>();
             listTitle.Add(Language.StringByID(R.MyInternationalizationString.uScence));
             listTitle.Add(Language.StringByID(R.MyInternationalizationString.uFunction));
-            if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
+            if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1 || HdlUserCenterResourse.ResidenceOption.AuthorityNo == 2)
             {
                 //鎴愬憳娌℃湁鑷姩鍖�
                 listTitle.Add(Language.StringByID(R.MyInternationalizationString.Automation));
             }
             //璁剧疆鍒濆鍊�
-            switchContr.SetDefultIndex(UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex);
+            switchContr.SetDefultIndex(HdlUserCenterResourse.ResidenceOption.CategoryPageSwitchIndex);
             //閫夋嫨浜嬩欢
             switchContr.SelectTabEvent += (selectIndex) =>
             {
-                UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex = selectIndex;
+                HdlUserCenterResourse.ResidenceOption.CategoryPageSwitchIndex = selectIndex;
                 if (selectIndex == 2)
                 {
                     Common.Logic.LogicDviceList.Clear();
                     if (Common.Logic.LogicDviceList.Count == 0)
                     {
-                        Common.Logic.LogicDviceList.AddRange(LocalDevice.Current.listAllDevice.ToArray());
+                        Common.Logic.LogicDviceList.AddRange(HdlDeviceCommonLogic.Current.listAllDevice.ToArray());
                     }
                 }
                 //鍒锋柊bodyView
@@ -239,7 +238,7 @@
             {
                 bool floorVisible = true;
                 //鍦烘櫙
-                if (UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 0)
+                if (HdlUserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 0)
                 {
                     //鍒濆鍖栨埧闂磋彍鍗�
                     this.InitRoomMenuControl();
@@ -247,7 +246,7 @@
                     this.btnTopRightAdd.Visible = true;
                 }
                 //鍔熻兘
-                else if (UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 1)
+                else if (HdlUserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 1)
                 {
                     //鍒濆鍖栨埧闂磋彍鍗�
                     this.InitRoomMenuControl();
@@ -255,7 +254,7 @@
                     this.btnTopRightAdd.Visible = false;
                 }
                 //鑷姩鍖�
-                else if (UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 2)
+                else if (HdlUserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 2)
                 {
                     //鑷姩鍖栧姛鑳戒唬鐮佸叆鍙�
                     Device.Logic.SkipView.ShowAutotionView(functionSceneAutoBodyView);
@@ -301,7 +300,7 @@
             {
                 HdlRoomLogic.Current.NowCategoryRoom = selectRoom;
                 //鍦烘櫙
-                if (UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 0)
+                if (HdlUserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 0)
                 {
                     //鍦ㄥ闈㈡竻绌�(鐗规晥鐨勯棶棰�)
                     this.functionSceneBodyView.RemoveAll();
@@ -312,7 +311,7 @@
                     });
                 }
                 //鍔熻兘
-                else if (UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 1)
+                else if (HdlUserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 1)
                 {
                     //鍦ㄥ闈㈡竻绌�(鐗规晥鐨勯棶棰�)
                     this.functionSceneBodyView.RemoveAll();
@@ -356,14 +355,14 @@
 
             //璁惧鑿滃崟鐨勭櫧鑹茶儗鏅�
             var functionBack1 = new FrameLayout();
-            functionBack1.X = ControlCommonResourse.XXLeft;
+            functionBack1.X = HdlControlResourse.XXLeft;
             functionBack1.Height = Application.GetRealHeight(160);
             functionBack1.Width = Application.GetRealWidth(1028);
             functionBack1.BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
             functionSceneBodyView.AddChidren(functionBack1);
             functionBack1.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopLeft);
             var functionBack2 = new FrameLayout();
-            functionBack2.X = ControlCommonResourse.XXLeft;
+            functionBack2.X = HdlControlResourse.XXLeft;
             functionBack2.Y = functionBack1.Bottom - Application.GetRealHeight(50);
             functionBack2.Height = Application.GetRealHeight(279 - 160 + 50);
             functionBack2.Width = Application.GetRealWidth(1028);
@@ -373,14 +372,14 @@
 
             //璁惧鑿滃崟鐨勫乏鍙虫粦鍔ㄧ殑鎺т欢
             var HorizontalView = new HorizontalScrolViewLayout();
-            HorizontalView.X = Application.GetRealWidth(CommonFormResouce.X_Left);
+            HorizontalView.X = HdlControlResourse.XXLeft;
             HorizontalView.Height = Application.GetRealHeight(279);
             HorizontalView.Width = Application.GetRealWidth(1028);
             functionSceneBodyView.AddChidren(HorizontalView);
 
             //璁惧鐨勮儗鏅鍣�
             var frameDeviceBack = new FrameLayout();
-            frameDeviceBack.X = ControlCommonResourse.XXLeft;
+            frameDeviceBack.X = HdlControlResourse.XXLeft;
             frameDeviceBack.Y = HorizontalView.Bottom + Application.GetRealHeight(35);
             frameDeviceBack.BackgroundColor = UserCenterColor.Current.White;
             frameDeviceBack.Width = bodyFrameLayout.Width;
@@ -397,7 +396,7 @@
             frameDeviceBack.AddChidren(listDeviceView);
 
             //涓婁竴娆¢�夋嫨鐨勮彍鍗�
-            MainPage.Controls.DeviceFunctionUnallocatedControl oldSelectContr = null;
+            MainPage.Controls.DeviceFunctionMenuControl oldSelectContr = null;
             DeviceRowInfo nowSelectDeviceInfo = null;
             foreach (string strText in dicGroupDevice.Keys)
             {
@@ -409,9 +408,9 @@
                 HorizontalView.AddChidren(devieFrame);
 
                 //鑿滃崟鍥剧墖鎺т欢
-                var deviceObjContr = new MainPage.Controls.DeviceFunctionUnallocatedControl();
+                var deviceObjContr = new MainPage.Controls.DeviceFunctionMenuControl();
                 devieFrame.AddChidren(deviceObjContr);
-                deviceObjContr.InitControl(strText, rowInfo.IconPath, rowInfo.IconPathSelected, rowInfo.listDeviceKeys);
+                deviceObjContr.InitControl(strText, rowInfo.IconPath, rowInfo.IconPathSelected);
                 deviceObjContr.ButtonClickEvent += (sender, e) =>
                 {
                     //閫夋嫨鐨勬槸鍚屼竴涓笢瑗跨殑璇�,涓嶅鐞�
@@ -460,16 +459,17 @@
         {
             //鍏堟竻绌�
             listView.RemoveAll();
+            this.dicDeviceRowControl = new Dictionary<string, Controls.DeviceRowCommon>();
 
             var listDevice = new List<CommonDevice>();
             for (int i = 0; i < rowInfo.listDeviceKeys.Count; i++)
             {
-                var device = LocalDevice.Current.GetDevice(rowInfo.listDeviceKeys[i]);
+                var device = HdlDeviceCommonLogic.Current.GetDevice(rowInfo.listDeviceKeys[i]);
 
                 //鑾峰彇璁惧绫诲瀷鐨�
-                var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
+                var deviceEnumInfo = HdlDeviceCommonLogic.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                 //鏂伴闈㈡澘涓嬬殑鍥炶矾涓嶆樉绀猴紝锛堝鏂伴銆佹俯/婀垮害浼犳劅鍣ㄥ垯涓嶆樉绀猴級
-                if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir)
+                if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir)
                 {
                     continue;
                 }
@@ -558,13 +558,13 @@
                     listView.AddChidren(cardContr);
                     cardContr.InitControl(device, HdlRoomLogic.Current.NowCategoryRoom);
                     //鎺т欢璁板綍鍒扮紦瀛樹腑
-                    this.dicDeviceRowControl[LocalDevice.Current.GetDeviceMainKeys(device)] = cardContr;
+                    this.dicDeviceRowControl[HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device)] = cardContr;
                     //鍔犵紦瀛�,鐒跺悗鍙戝懡浠�
                     listContr.Add(cardContr);
                     //鎺т欢琚Щ闄ょ殑鍥炶皟鍑芥暟
                     cardContr.RowNeedRemoveEvent += () =>
                     {
-                        string myKeys = LocalDevice.Current.GetDeviceMainKeys(cardContr.device);
+                        string myKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(cardContr.device);
                         rowInfo.listDeviceKeys.Remove(myKeys);
                         this.dicDeviceRowControl.Remove(myKeys);
 
@@ -582,15 +582,30 @@
                 }
                 HdlThreadLogic.Current.RunThread(() =>
                 {
-                    for (int i = 0; i < listContr.Count; i++)
+                    while (listView.Parent != null)
                     {
-                        if (listView.Parent == null)
+                        bool hadSend = false;
+                        for (int i = 0; i < listContr.Count; i++)
                         {
-                            return;
+                            if (listView.Parent == null)
+                            {
+                                return;
+                            }
+                            //濡傛灉杩樻病鏈夋帴鏀跺埌鏁版嵁,鍒欏啀娆″彂閫�
+                            if (listContr[i].ReceiveResponeResultStatu() == false)
+                            {
+                                //鍙戦�佽幏鍙栫姸鎬佺殑鍛戒护
+                                listContr[i].SendStatuComand();
+                                hadSend = true;
+                                System.Threading.Thread.Sleep(200);
+                            }
                         }
-                        System.Threading.Thread.Sleep(200);
-                        //鍙戦�佽幏鍙栫姸鎬佺殑鍛戒护
-                        listContr[i].SendStatuComand();
+                        if (hadSend == false)
+                        {
+                            //濡傛灉宸茬粡鍏ㄩ儴鍥炶矾閮芥帴鏀朵簡缃戝叧鍥炲,鍒欎笉鍐嶄簩娆″彂閫�
+                            break;
+                        }
+                        System.Threading.Thread.Sleep(2000);
                     }
 
                 }, ShowErrorMode.NO);
@@ -611,7 +626,7 @@
             VerticalListRefreshControl listview1 = null;
             //鎴愬憳涓撶敤涓嶈兘鍒锋柊鐨勬帶浠�
             VerticalListControl listview2 = null;
-            if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
+            if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1 || HdlUserCenterResourse.ResidenceOption.AuthorityNo == 2)
             {
                 //涓讳汉锛岀鐞嗗憳涓撶敤鍒锋柊鎺т欢
                 listview1 = new VerticalListRefreshControl();
@@ -820,11 +835,11 @@
                 HdlThreadLogic.Current.RunMain(() =>
                 {
                     //澶勭悊涓�鑸澶囩殑涓婃姤鏁版嵁
-                    string mainKeys = LocalDevice.Current.GetDeviceMainKeys(report);
+                    string mainKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(report);
                     if (this.dicDeviceRowControl.ContainsKey(mainKeys) == true)
                     {
                         //鍒锋柊鍗$墖淇℃伅
-                        var locadevice = LocalDevice.Current.GetDevice(mainKeys);
+                        var locadevice = HdlDeviceCommonLogic.Current.GetDevice(mainKeys);
                         //宸茬粡鎺ユ敹鍒扮綉鍏崇殑鍙嶉 2020.05.09:鍒犻櫎Ack涓婚
                         this.dicDeviceRowControl[mainKeys].SetHadGetResponeResultStatu();
                         //鍒锋柊鎺т欢
@@ -847,11 +862,11 @@
             {
                 HdlThreadLogic.Current.RunMain(() =>
                 {
-                    string mainKeys = LocalDevice.Current.GetDeviceMainKeys(report);
+                    string mainKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(report);
                     if (this.dicDeviceRowControl.ContainsKey(mainKeys) == true)
                     {
                         //鍒锋柊鍗$墖鐘舵��
-                        bool bolOnline = LocalDevice.Current.CheckDeviceIsOnline(report);
+                        bool bolOnline = HdlDeviceCommonLogic.Current.CheckDeviceIsOnline(report);
                         this.dicDeviceRowControl[mainKeys].SetRowOnlineStatu(bolOnline);
                         return;
                     }
@@ -875,7 +890,7 @@
                 HdlThreadLogic.Current.RunMain(() =>
                 {
                     //澶勭悊浼犳劅鍣ㄤ笂鎶ユ暟鎹�
-                    string mainKeys = LocalDevice.Current.GetDeviceMainKeys(report);
+                    string mainKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(report);
                     if (this.dicDeviceRowControl.ContainsKey(mainKeys) == true)
                     {
                         //寮�鍚闂儊鐗规晥
@@ -883,6 +898,45 @@
                     }
 
                 }, ShowErrorMode.NO);
+            });
+        }
+
+        #endregion
+
+        #region 鈻� 浼犳劅鍣ㄧ姸鎬佽繕鍘焈____________________
+
+        /// <summary>
+        /// 寮�鍚紶鎰熷櫒鐘舵�佽繕鍘熺殑绾跨▼
+        /// </summary>
+        private void StartRecoverSenorStatuThread()
+        {
+            HdlThreadLogic.Current.RunThread(() =>
+            {
+                while (this.Parent != null)
+                {
+                    try
+                    {
+                        var dicControl = this.dicDeviceRowControl;
+                        foreach (var contr in dicControl.Values)
+                        {
+                            //濡傛灉鏄紶鎰熷櫒,鍒欏埛鏂扮姸鎬�
+                            if (contr.device.Type == DeviceType.IASZone && contr.Parent != null
+                              && ((IASZone)contr.device).iASInfo == null)
+                            {
+                                HdlThreadLogic.Current.RunMain(() =>
+                                {
+                                    //璁惧鐘舵�佸繀椤诲埛鏂�
+                                    string statuText = HdlDeviceCommonLogic.Current.GetMainPageDeviceStatuText(contr.device);
+                                    contr.SetDeviceStatuText(statuText);
+                                    //浼犳劅鍣ㄥ垏鎹负鐏拌壊鐘舵��
+                                    contr.SwitchRowStatuAppeal(false);
+                                }, ShowErrorMode.NO);
+                            }
+                        }
+                        System.Threading.Thread.Sleep(8000);
+                    }
+                    catch { System.Threading.Thread.Sleep(3000); }
+                }
             });
         }
 
@@ -902,7 +956,7 @@
             foreach (var device in listDeviceTemp)
             {
                 //鍒ゆ柇璇ヨ澶囪兘鍚︽樉绀哄湪鍒嗙被
-                if (LocalDevice.Current.CanShowInHomeHomeMainPage(device) == false)
+                if (HdlDeviceCommonLogic.Current.CanShowInHomeHomeMainPage(device) == false)
                 {
                     continue;
                 }
@@ -910,11 +964,11 @@
             }
 
             //鏍规嵁璁惧鎵�灞炵被鍨嬫帓搴�
-            listDevice = LocalDevice.Current.SortDeviceByBelongType(listDevice);
+            listDevice = HdlDeviceCommonLogic.Current.SortDeviceByBelongType(listDevice);
             var dic = new Dictionary<string, DeviceRowInfo>();
             foreach (var device in listDevice)
             {
-                var typeInfo = LocalDevice.Current.GetDeviceBelongEnumInfo(device);
+                var typeInfo = HdlDeviceCommonLogic.Current.GetDeviceBelongEnumInfo(device);
                 //鎸夋墍灞濱D鍒嗙粍
                 if (dic.ContainsKey(typeInfo.BeloneText) == false)
                 {
@@ -922,12 +976,12 @@
                     string path1 = string.Empty;
                     string path2 = string.Empty;
                     //鑾峰彇鍥剧墖
-                    LocalDevice.Current.GetDeviceFunctionTypeMenuIcon(typeInfo.ConcreteType, ref path1, ref path2);
+                    HdlDeviceCommonLogic.Current.GetDeviceFunctionTypeMenuIcon(typeInfo, ref path1, ref path2);
                     dic[typeInfo.BeloneText].IconPath = path1;
                     dic[typeInfo.BeloneText].IconPathSelected = path2;
                     dic[typeInfo.BeloneText].Text = typeInfo.BeloneText;
                 }
-                dic[typeInfo.BeloneText].listDeviceKeys.Add(LocalDevice.Current.GetDeviceMainKeys(device));
+                dic[typeInfo.BeloneText].listDeviceKeys.Add(HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device));
             }
             return dic;
         }
@@ -981,23 +1035,6 @@
                 timeStr += sec + secondText;
             }
             return timeStr;
-        }
-
-        /// <summary>
-        /// 鍒濆鍖栭粯璁ゆゼ灞侷D
-        /// </summary>
-        private void InitDefultFloorId()
-        {
-            if (Config.Instance.Home.CurrentFloorId != string.Empty)
-            {
-                return;
-            }
-            var dicFloor = HdlRoomLogic.Current.GetFloorSortList();
-            foreach (var floorId in dicFloor.Keys)
-            {
-                Config.Instance.Home.CurrentFloorId = floorId;
-                break;
-            }
         }
 
         #endregion

--
Gitblit v1.8.0