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 |  252 ++++++++++++++++++++++++++++++++++---------------
 1 files changed, 174 insertions(+), 78 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Category/CategoryMainForm.cs b/ZigbeeApp/Shared/Phone/Category/CategoryMainForm.cs
index aeccb00..26f077a 100755
--- a/ZigbeeApp/Shared/Phone/Category/CategoryMainForm.cs
+++ b/ZigbeeApp/Shared/Phone/Category/CategoryMainForm.cs
@@ -23,11 +23,11 @@
         /// <summary>
         /// 鍦烘櫙鍔熻兘涓儴鑳屾櫙bodyView(楂樺害涓鸿澶囪彍鍗曠殑閭d釜鐧借壊鑳屾櫙鐨勪笂閮ㄥ埌灞忓箷搴曢儴)
         /// </summary>
-        public FrameLayout functionSceneBodyView;
+        public NormalFrameLayout functionSceneBodyView;
         /// <summary>
         /// 涓儴鑳屾櫙bodyView(楂樺害涓哄満鏅姛鑳藉垏鎹㈡帶浠剁殑搴曢儴鍒板睆骞曞簳閮�)
         /// </summary>
-        public FrameLayout functionSceneAutoBodyView;
+        public NormalFrameLayout functionSceneAutoBodyView;
         /// <summary>
         /// 鍙充笂瑙掓坊鍔犳寜閽�
         /// </summary>
@@ -54,6 +54,7 @@
         /// </summary>
         public CategoryMainForm()
         {
+            this.FormID = "CategoryMainForm";
             BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
             instance = this;
         }
@@ -65,6 +66,7 @@
         {
             //鍏堟竻闄ゅ惂
             this.RemoveAll();
+
             //鍒濆鍖栧ご閮ㄦ帶浠�
             this.InitTopControl();
             //鍒濆鍖栦腑闂存帶浠�
@@ -73,6 +75,8 @@
             this.AddNormalDeviceReportEvent();
             //娣诲姞浼犳劅鍣ㄧ姸鎬佷笂鎶ヤ簨浠�
             this.AddSensorDeviceReportEvent();
+            //寮�鍚紶鎰熷櫒鐘舵�佽繕鍘熺殑绾跨▼
+            this.StartRecoverSenorStatuThread();
         }
 
         /// <summary>
@@ -81,14 +85,14 @@
         private void InitTopControl()
         {
             //澶撮儴FrameLayout
-            this.topFrameLayout = new FrameLayout();
+            this.topFrameLayout = new NormalFrameLayout();
             topFrameLayout.Y = Application.GetRealHeight(104);
             topFrameLayout.Height = Application.GetRealHeight(127);
             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;
@@ -104,7 +108,7 @@
             topFrameLayout.AddChidren(btnTopRightAdd);
             btnTopRightAdd.ButtonClickEvent += (sender, e) =>
             {
-                if (UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 0)
+                if (HdlUserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 0)
                 {
                     //娣诲姞鍦烘櫙
                     var form = new AddOrEditorSceneForm();
@@ -115,7 +119,7 @@
                         this.RefreshBodyView();
                     };
                 }
-                else if (UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 2)
+                else if (HdlUserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 2)
                 {
                     //娣诲姞鑷姩鍖�
                     Device.Logic.SkipView.SkipAddLogic(0);
@@ -129,7 +133,7 @@
         private void InitMidControls()
         {
             //搴旇鏄痓ody鍚�
-            this.bodyFrameLayout = new FrameLayout();
+            this.bodyFrameLayout = new NormalFrameLayout();
             bodyFrameLayout.Y = topFrameLayout.Bottom;
             bodyFrameLayout.Height = this.Height - topFrameLayout.Bottom;
             bodyFrameLayout.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
@@ -151,18 +155,21 @@
                 btnFloorName.Y = Application.GetRealHeight(17);
                 btnFloorName.TextAlignment = TextAlignment.CenterRight;
                 btnFloorName.IsBold = true;
-                btnFloorName.Text = HdlResidenceLogic.Current.GetFloorNameById(Config.Instance.Home.CurrentFloorId);
+                btnFloorName.Text = Common.Config.Instance.Home.GetCurrentFloorName;
                 frameSwitchBack.AddChidren(btnFloorName);
                 btnFloorName.ButtonClickEvent += (sender, e) =>
                 {
                     var floors = new SelectFloorForm();
+                    floors.CurFloorId = Config.Instance.Home.CurrentFloorId;
                     AddChidren(floors);
                     floors.Init(580, 330, Direction.Right);
-                    floors.changeFloor = true;
                     floors.FloorAction += (floorId) =>
                     {
-                        btnFloorName.Text = Config.Instance.Home.GetFloorNameById(floorId);
+                        btnFloorName.Text = HdlResidenceLogic.Current.GetFloorNameById(floorId);
+                        Config.Instance.Home.CurrentFloorId = floorId;
                         HdlRoomLogic.Current.NowCategoryRoom = HdlRoomLogic.Current.GetLoveRoom();
+                        //杩欎釜鏃跺�欓渶瑕佸埛鏂颁富椤�
+                        UserPage.Instance.RefreshMainPageForm = true;
                         //鍒锋柊bodyView
                         this.RefreshBodyView();
                     };
@@ -180,36 +187,37 @@
             }
 
             //鐩墠涓嶇煡閬撻儹闆煄鐨勮繖涓叿浣撴斁鍦ㄥ摢涓殑浣嶇疆
-            this.functionSceneAutoBodyView = new FrameLayout();
+            this.functionSceneAutoBodyView = new NormalFrameLayout();
             functionSceneAutoBodyView.Y = frameSwitchBack.Bottom;
             functionSceneAutoBodyView.Height = bodyFrameLayout.Height - frameSwitchBack.Bottom;
             bodyFrameLayout.AddChidren(functionSceneAutoBodyView);
 
             //鍦烘櫙,鍔熻兘,鑷姩鍖栫殑鍒囨崲鎺т欢
             var switchContr = new SceneFunctionSwitchControl();
+            switchContr.Y = Application.GetRealHeight(40);
             switchContr.Width = Application.GetRealWidth(650);
             switchContr.Gravity = Gravity.CenterVertical;
             frameSwitchBack.AddChidren(switchContr);
             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
@@ -230,7 +238,7 @@
             {
                 bool floorVisible = true;
                 //鍦烘櫙
-                if (UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 0)
+                if (HdlUserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 0)
                 {
                     //鍒濆鍖栨埧闂磋彍鍗�
                     this.InitRoomMenuControl();
@@ -238,7 +246,7 @@
                     this.btnTopRightAdd.Visible = true;
                 }
                 //鍔熻兘
-                else if (UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 1)
+                else if (HdlUserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 1)
                 {
                     //鍒濆鍖栨埧闂磋彍鍗�
                     this.InitRoomMenuControl();
@@ -246,7 +254,7 @@
                     this.btnTopRightAdd.Visible = false;
                 }
                 //鑷姩鍖�
-                else if (UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 2)
+                else if (HdlUserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 2)
                 {
                     //鑷姩鍖栧姛鑳戒唬鐮佸叆鍙�
                     Device.Logic.SkipView.ShowAutotionView(functionSceneAutoBodyView);
@@ -275,7 +283,7 @@
         private void InitRoomMenuControl()
         {
             //褰撳墠妤煎眰鐨勫叏閮ㄦ埧闂�
-            var lisrRoom = HdlRoomLogic.Current.GetRoomsByCurrentFloorIdAppendLoveRoom();
+            var lisrRoom = HdlRoomLogic.Current.GetRoomsByFloorIdAppendLoveRoom(Config.Instance.Home.CurrentFloorId);
             if (HdlRoomLogic.Current.NowCategoryRoom == null)
             {
                 //璁剧疆绗竴涓负鍒濆鎴块棿
@@ -292,7 +300,7 @@
             {
                 HdlRoomLogic.Current.NowCategoryRoom = selectRoom;
                 //鍦烘櫙
-                if (UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 0)
+                if (HdlUserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 0)
                 {
                     //鍦ㄥ闈㈡竻绌�(鐗规晥鐨勯棶棰�)
                     this.functionSceneBodyView.RemoveAll();
@@ -303,7 +311,7 @@
                     });
                 }
                 //鍔熻兘
-                else if (UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 1)
+                else if (HdlUserCenterResourse.ResidenceOption.CategoryPageSwitchIndex == 1)
                 {
                     //鍦ㄥ闈㈡竻绌�(鐗规晥鐨勯棶棰�)
                     this.functionSceneBodyView.RemoveAll();
@@ -316,7 +324,7 @@
             };
 
             //鍔熻兘鍜屽満鏅痓odyView
-            this.functionSceneBodyView = new FrameLayout();
+            this.functionSceneBodyView = new NormalFrameLayout();
             functionSceneBodyView.Y = roomSwitchContr.Bottom;
             functionSceneBodyView.Height = functionSceneAutoBodyView.Height - roomSwitchContr.Bottom;
             functionSceneAutoBodyView.AddChidren(functionSceneBodyView);
@@ -347,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);
@@ -364,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;
@@ -388,11 +396,11 @@
             frameDeviceBack.AddChidren(listDeviceView);
 
             //涓婁竴娆¢�夋嫨鐨勮彍鍗�
-            MainPage.Controls.DeviceFunctionUnallocatedControl oldSelectContr = null;
+            MainPage.Controls.DeviceFunctionMenuControl oldSelectContr = null;
             DeviceRowInfo nowSelectDeviceInfo = null;
-            foreach (int Textid in dicGroupDevice.Keys)
+            foreach (string strText in dicGroupDevice.Keys)
             {
-                var rowInfo = dicGroupDevice[Textid];
+                var rowInfo = dicGroupDevice[strText];
 
                 //璁惧绫诲瀷鐨勫鍣�
                 var devieFrame = new FrameLayout();
@@ -400,13 +408,13 @@
                 HorizontalView.AddChidren(devieFrame);
 
                 //鑿滃崟鍥剧墖鎺т欢
-                var deviceObjContr = new MainPage.Controls.DeviceFunctionUnallocatedControl();
+                var deviceObjContr = new MainPage.Controls.DeviceFunctionMenuControl();
                 devieFrame.AddChidren(deviceObjContr);
-                deviceObjContr.InitControl(Language.StringByID(Textid), rowInfo.IconPath, rowInfo.IconPathSelected, rowInfo.listDeviceKeys);
+                deviceObjContr.InitControl(strText, rowInfo.IconPath, rowInfo.IconPathSelected);
                 deviceObjContr.ButtonClickEvent += (sender, e) =>
                 {
                     //閫夋嫨鐨勬槸鍚屼竴涓笢瑗跨殑璇�,涓嶅鐞�
-                    if (nowSelectDeviceInfo.TextId != rowInfo.TextId)
+                    if (nowSelectDeviceInfo.Text != rowInfo.Text)
                     {
                         //涓婁竴娆$殑鑿滃崟鍙栨秷,鏈鑿滃崟閫夋嫨
                         oldSelectContr.SetSelectStatu(false);
@@ -451,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;
                 }
@@ -532,6 +541,11 @@
                     {
                         cardContr = new Controls.DeviceDoorLockRowControl();
                     }
+                    //鑹叉俯鐏�
+                    else if (device.Type == DeviceType.ColorTemperatureLight)
+                    {
+                        cardContr = new Controls.DeviceColorTemperatureRowControl();
+                    }
                     //鏃犳硶璇嗗埆
                     else
                     {
@@ -544,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);
 
@@ -568,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);
@@ -597,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();
@@ -605,17 +634,35 @@
                 //涓嬫媺鍒锋柊
                 listview1.BeginHeaderRefreshingAction += () =>
                 {
+                    //濡傛灉褰撳墠鏄櫄鎷熶綇瀹�,鍒欏彧缁欎釜鐗规晥
+                    if (Common.Config.Instance.Home.IsVirtually == true)
+                    {
+                        HdlThreadLogic.Current.RunThread(() =>
+                        {
+                            System.Threading.Thread.Sleep(1500);
+                            HdlThreadLogic.Current.RunMain(() =>
+                            {
+                                listview1.EndHeaderRefreshing();
+                            });
+                        });
+                        return;
+                    }
+
                     HdlThreadLogic.Current.RunThread(() =>
                     {
                         //浠庣綉鍏冲埛鏂板満鏅垪琛�
-                        bool result = HdlSceneLogic.Current.RefreshSceneUIList();
+                        bool result = HdlSceneLogic.Current.RefreshSceneUIList(false);
                         HdlThreadLogic.Current.RunMain(() =>
                         {
                             listview1.EndHeaderRefreshing();
-                            if (result == true)
+                            //listview1.Parent涓簄ull浠h〃瀹冨垏鎹㈡埧闂翠簡
+                            if (result == true && listview1.Parent != null)
                             {
+                                //鍒锋柊鍦烘櫙鐨勬椂鍊�,鍏抽棴宸﹀垝鑿滃崟鐨勬湭鍒嗛厤鐣岄潰
+                                MainPage.LeftListRoomViewFrom.Instance?.CloseUnallocatedRoomForm();
                                 //鍦ㄥ闈㈡竻绌�(鐗规晥鐨勯棶棰�)
                                 this.functionSceneBodyView.RemoveAll();
+
                                 HdlThreadLogic.Current.RunMainInThread(() =>
                                 {
                                     //鍒锋柊鍦烘櫙鍒嗘敮鎺т欢
@@ -755,13 +802,13 @@
                 while (remainTime > 0 && this.Parent != null)
                 {
                     System.Threading.Thread.Sleep(1000);
-                    Application.RunOnMainThread(() =>
+                    HdlThreadLogic.Current.RunMain(() =>
                     {
                         sceneContr.SetTimeText(this.GetTimeString(remainTime, hourText, minuText, secondText));
-                    });
+                    }, ShowErrorMode.NO);
                     remainTime--;
                 }
-                Application.RunOnMainThread(() =>
+                HdlThreadLogic.Current.RunMain(() =>
                 {
                     if (listview.Parent != null)
                     {
@@ -769,7 +816,7 @@
                         //寮�鍚疞oading鐗规晥
                         sceneContr.StartLoadingApreal();
                     }
-                });
+                }, ShowErrorMode.NO);
             });
         }
 
@@ -783,34 +830,43 @@
         private void AddNormalDeviceReportEvent()
         {
             //璁惧灞炴�т笂鎶�(缂撳瓨鐨勪慨鏀逛氦鐢� HdlGatewayReceiveLogic 澶勭悊)
-            HdlGatewayReceiveLogic.Current.AddAttributeEvent("UserHomeViewDeviceStatus", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) =>
+            HdlGatewayReceiveLogic.Current.AddAttributeEvent("CategoryMainFormDeviceStatus", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) =>
             {
                 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();
                         //鍒锋柊鎺т欢
-                        this.dicDeviceRowControl[mainKeys].RefreshControlInfo(locadevice);
+                        if (locadevice.Type != DeviceType.IASZone)
+                        {
+                            //浼犳劅鍣ㄤ笉闇�瑕佸睘鎬т笂鎶�(浣嗘槸閭d釜鐞冨瀷浼犳劅鍣ㄥ眳鐒朵細灞炴�т笂鎶�)
+                            this.dicDeviceRowControl[mainKeys].RefreshControlInfo(locadevice);
+                        }
+                        else if (report.DeviceStatusReport.CluterID == 1)
+                        {
+                            //杩欎釜鏄數閲忔帹閫�
+                            this.dicDeviceRowControl[mainKeys].RefreshBatteryStatu();
+                        }
                     }
                 }, ShowErrorMode.NO);
             });
 
             //璁惧鍦ㄧ嚎涓婃姤(缂撳瓨鐨勪慨鏀逛氦鐢� HdlGatewayReceiveLogic 澶勭悊)
-            HdlGatewayReceiveLogic.Current.AddAttributeEvent("UserHomeViewDeviceOnline", ReceiveComandDiv.A璁惧鍦ㄧ嚎涓婃姤, (report) =>
+            HdlGatewayReceiveLogic.Current.AddAttributeEvent("CategoryMainFormDeviceOnline", ReceiveComandDiv.A璁惧鍦ㄧ嚎涓婃姤, (report) =>
             {
                 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;
                     }
@@ -829,21 +885,58 @@
         private void AddSensorDeviceReportEvent()
         {
             //浼犳劅鍣ㄤ笂鎶�(缂撳瓨鐨勪慨鏀逛氦鐢� HdlGatewayReceiveLogic 澶勭悊)
-            HdlGatewayReceiveLogic.Current.AddAttributeEvent("UserHomeViewSensor", ReceiveComandDiv.A浼犳劅鍣ㄤ笂鎶�, (report) =>
+            HdlGatewayReceiveLogic.Current.AddAttributeEvent("CategoryMainFormSensor", ReceiveComandDiv.A浼犳劅鍣ㄤ笂鎶�, (report) =>
             {
                 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);
-                        //鍒锋柊鍗$墖淇℃伅
-                        this.dicDeviceRowControl[mainKeys].RefreshControlInfo(locadevice);
+                        //寮�鍚闂儊鐗规晥
+                        this.dicDeviceRowControl[mainKeys].StartRowLightAppeal();
                     }
 
                 }, 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); }
+                }
             });
         }
 
@@ -855,7 +948,7 @@
         /// 鑾峰彇鍒嗙粍鍚庣殑璁惧
         /// </summary>
         /// <returns></returns>
-        private Dictionary<int, DeviceRowInfo> GetAllGroupDevice(Common.Room room)
+        private Dictionary<string, DeviceRowInfo> GetAllGroupDevice(Common.Room room)
         {
             //鍏ㄩ儴鐨勮澶�
             var listDeviceTemp = HdlRoomLogic.Current.GetRoomListDevice(room);
@@ -863,7 +956,7 @@
             foreach (var device in listDeviceTemp)
             {
                 //鍒ゆ柇璇ヨ澶囪兘鍚︽樉绀哄湪鍒嗙被
-                if (LocalDevice.Current.CanShowInHomeHomeMainPage(device) == false)
+                if (HdlDeviceCommonLogic.Current.CanShowInHomeHomeMainPage(device) == false)
                 {
                     continue;
                 }
@@ -871,24 +964,24 @@
             }
 
             //鏍规嵁璁惧鎵�灞炵被鍨嬫帓搴�
-            listDevice = LocalDevice.Current.SortDeviceByBelongType(listDevice);
-            var dic = new Dictionary<int, DeviceRowInfo>();
+            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.BeloneTextId) == false)
+                if (dic.ContainsKey(typeInfo.BeloneText) == false)
                 {
-                    dic[typeInfo.BeloneTextId] = new DeviceRowInfo();
+                    dic[typeInfo.BeloneText] = new DeviceRowInfo();
                     string path1 = string.Empty;
                     string path2 = string.Empty;
                     //鑾峰彇鍥剧墖
-                    LocalDevice.Current.GetDeviceFunctionTypeMenuIcon(typeInfo.ConcreteType, ref path1, ref path2);
-                    dic[typeInfo.BeloneTextId].IconPath = path1;
-                    dic[typeInfo.BeloneTextId].IconPathSelected = path2;
-                    dic[typeInfo.BeloneTextId].TextId = typeInfo.BeloneTextId;
+                    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.BeloneTextId].listDeviceKeys.Add(LocalDevice.Current.GetDeviceMainKeys(device));
+                dic[typeInfo.BeloneText].listDeviceKeys.Add(HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device));
             }
             return dic;
         }
@@ -904,6 +997,9 @@
         {
             //鎶婇潤鎬佸彉閲忕殑杩欎釜涓滆タ缃┖
             instance = null;
+            HdlGatewayReceiveLogic.Current.RemoveEvent("CategoryMainFormDeviceStatus");
+            HdlGatewayReceiveLogic.Current.RemoveEvent("CategoryMainFormDeviceOnline");
+            HdlGatewayReceiveLogic.Current.RemoveEvent("CategoryMainFormSensor");
 
             base.CloseFormBefore();
         }
@@ -951,9 +1047,9 @@
         private class DeviceRowInfo
         {
             /// <summary>
-            /// 鏂囨湰ID,鐩墠鐢ㄦ潵鍋氫富閿�
+            /// 鏂囨湰,鐩墠鐢ㄦ潵鍋氫富閿�
             /// </summary>
-            public int TextId = 0;
+            public string Text = string.Empty;
             /// <summary>
             /// 鍥炬爣
             /// </summary>

--
Gitblit v1.8.0