From da3634e011bbda29cf4e1c168997b780fe795b20 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期三, 13 五月 2020 09:05:23 +0800 Subject: [PATCH] 优化新风模块和新风面板的测试功能,请合并代码 --- ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs | 156 +++++++++++++++++++++++++++++++-------------------- 1 files changed, 95 insertions(+), 61 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs index 4d4c692..b98b37a 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs @@ -30,10 +30,6 @@ /// </summary> private Dictionary<string, DeviceObjRowInfo> dicRowInfo = new Dictionary<string, DeviceObjRowInfo>(); /// <summary> - /// 閲嶆柊鑾峰彇璁惧鐨勫湪绾跨姸鎬� - /// </summary> - private bool reGetDeviceOnlineStatu = false; - /// <summary> /// 褰撳墠姝e湪鎿嶄綔鐨勮澶囧璞ac鍦板潃(璁惧淇℃伅缂栬緫鐣岄潰鐢�) /// </summary> private string nowActionDeviceMac = null; @@ -65,15 +61,28 @@ //鍒濆鍖栦腑閮ㄦ帶浠� this.InitMiddleFrame(); + + //寮�鍚紶鎰熷櫒鎶ヨ鐩戣 + this.StartCheckDeviceAlarm(); + //娣诲姞鎺ユ敹璁惧鍦ㄧ嚎涓婃姤鐨勭洃鍚� + HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormReceivePushOnline", ReceiveComandDiv.A璁惧鍦ㄧ嚎涓婃姤, (report) => + { + HdlThreadLogic.Current.RunMain(() => + { + //鎺ュ彈璁惧鐘舵�� + this.ReceiveDeviceStatu(report); + + }, ShowErrorMode.NO); + }); + //寮�鍚娴嬬綉鍏冲湪绾跨姸鎬佺殑绾跨▼ + HdlGatewayLogic.Current.StartCheckGatewayOnlineThread(this); } /// <summary> /// 鍒濆鍖栦腑閮ㄦ帶浠�(澶栭儴鍙互璋冪敤) /// </summary> - /// <param name="i_reGetDeviceOnlineStatu">閲嶆柊鑾峰彇璁惧鐨勫湪绾跨姸鎬�</param> - public void InitMiddleFrame(bool i_reGetDeviceOnlineStatu = true) + public void InitMiddleFrame() { - this.reGetDeviceOnlineStatu = i_reGetDeviceOnlineStatu; //娓呯┖bodyFrame this.ClearBodyFrame(); @@ -125,6 +134,9 @@ frame.AddChidren(listView); listView.BeginHeaderRefreshingAction += () => { + //鍒锋柊璁惧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂� + UserView.UserPage.Instance.RefreshForm = true; + HdlThreadLogic.Current.RunThread(() => { //涓嬫媺鍒锋柊 @@ -348,8 +360,7 @@ //鍙崇澶� rowDevice.frameTable.AddRightArrow(); //鍦ㄧ嚎鐘舵�� - rowDevice.isOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(device); - + rowDevice.IsOnline = rowInfo.MenuRow.IsOnline; //淇濆瓨鎺т欢 string maikey = Common.LocalDevice.Current.GetDeviceMainKeys(device); rowInfo.dicDetailRow[maikey] = rowDevice; @@ -646,7 +657,7 @@ if (result != -1) { //閲嶆柊鍒锋柊鐣岄潰 - this.InitMiddleFrame(false); + this.InitMiddleFrame(); } }); } @@ -676,9 +687,10 @@ if (this.gatewayViewRow != null && this.gatewayViewRow.zbGatewayId == selectGwId) { bool online = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbGateway); - this.gatewayViewRow.RefreshControl(); - //寮�鍚澶囧湪绾跨嚎绋� - this.StartDeviceListControlThread(online); + //鍒锋柊鎺т欢鍦ㄧ嚎鐘舵�� + this.gatewayViewRow?.RefreshOnlineStatu(); + //鏍规嵁缃戝叧鍦ㄧ嚎鐘舵�佸埛鏂拌澶囧湪绾跨姸鎬� + this.RefreshDeviceOnlineStatuByGatewayOnline(online); } }); }); @@ -699,7 +711,14 @@ { Application.RunOnMainThread(() => { - this.gatewayViewRow?.RefreshControl(); + //鐩稿悓鐨勭姸鎬�,涓嶉渶瑕佸啀娆″埛鏂� + if (this.gatewayViewRow.isOnline != online) + { + //鏍规嵁缃戝叧鍦ㄧ嚎鐘舵�佸埛鏂拌澶囧湪绾跨姸鎬� + this.RefreshDeviceOnlineStatuByGatewayOnline(online); + } + //鍒锋柊鎺т欢鍦ㄧ嚎鐘舵�� + this.gatewayViewRow?.RefreshOnlineStatu(); }); } } @@ -709,52 +728,43 @@ #region 鈻� 璁惧鍦ㄧ嚎妫�娴媉______________________ /// <summary> - /// 寮�鍚澶囧湪绾跨嚎绋� + /// 鏍规嵁缃戝叧鍦ㄧ嚎鐘舵�佸埛鏂拌澶囧湪绾跨姸鎬� /// </summary> /// <param name="gatewayOnline">缃戝叧鐨勫湪绾跨姸鎬�</param> - private void StartDeviceListControlThread(bool gatewayOnline) + private void RefreshDeviceOnlineStatuByGatewayOnline(bool gatewayOnline) { if (gatewayOnline == false) { //璁剧疆鍏ㄩ儴璁惧绂荤嚎 this.SetAllDeviceOffLine(); - return; } - //寮�鍚紶鎰熷櫒鎶ヨ鐩戣 - this.StartCheckDeviceAlarm(); - //寮�鍚澶囧湪绾跨洃娴� - this.StartCheckDeviceOnline(); + else + { + //鍒锋柊璁惧鍦ㄧ嚎鐘舵�� + this.RefreshDeviceOnlineStatu(); + } } /// <summary> - /// 寮�鍚澶囧湪绾跨洃娴� + /// 鍒锋柊璁惧鍦ㄧ嚎鐘舵�� /// </summary> - private void StartCheckDeviceOnline() + private void RefreshDeviceOnlineStatu() { - //澶栭儴璋冪敤鐨勮瘽,涓嶅啀閲嶆柊鑾峰彇璁惧鐘舵�� - if (this.reGetDeviceOnlineStatu == false) - { - return; - } - - //娣诲姞鎺ユ敹璁惧鍦ㄧ嚎涓婃姤鐨勭洃鍚� - HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormReceivePushOnline", ReceiveComandDiv.A璁惧鍦ㄧ嚎涓婃姤, this.ReceiveDeviceStatu); - string gwId = GatewayResourse.NowSelectGatewayId; HdlThreadLogic.Current.RunThread(() => { + System.Threading.Thread.Sleep(2000); //杩欓噷涓昏鍙槸鑾峰彇鍦ㄧ嚎鐘舵�� - var zbway = HdlGatewayLogic.Current.GetLocalGateway(gwId); - int statu = 0; - var list = LocalDevice.Current.GetDeviceListFromGateway(zbway, ref statu, false, ShowErrorMode.NO); - if (statu != -1) + var list = LocalDevice.Current.GetDeviceOnlineList(gwId); + HdlThreadLogic.Current.RunMain(() => { for (int i = 0; i < list.Count; i++) { //璁剧疆璁惧鍦ㄧ嚎鐘舵�� this.ReceiveDeviceStatu(list[i]); } - } + + }, ShowErrorMode.NO); }); } @@ -788,20 +798,14 @@ localDevice.ReSave(); } - HdlThreadLogic.Current.RunMain(() => + rowInfo.MenuRow.IsOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(device); + if (rowInfo.dicDetailRow != null) { - if (rowInfo != null) + foreach (var detailRow in rowInfo.dicDetailRow.Values) { - rowInfo.MenuRow.isOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(device); - if (rowInfo.dicDetailRow != null) - { - foreach (var detailRow in rowInfo.dicDetailRow.Values) - { - detailRow.isOnline = rowInfo.MenuRow.isOnline; - } - } + detailRow.IsOnline = rowInfo.MenuRow.IsOnline; } - }); + } } /// <summary> @@ -809,17 +813,20 @@ /// </summary> private void SetAllDeviceOffLine() { - lock (dicRowInfo) + foreach (var rowInfo in this.dicRowInfo.Values) { - foreach (var rowInfo in this.dicRowInfo.Values) + //鑿滃崟 + if (rowInfo.MenuRow != null) { - Application.RunOnMainThread(() => + rowInfo.MenuRow.IsOnline = false; + } + //鏄庣粏 + if (rowInfo.dicDetailRow != null) + { + foreach (var detailRow in rowInfo.dicDetailRow.Values) { - if (rowInfo.MenuRow != null) - { - rowInfo.MenuRow.isOnline = false; - } - }); + detailRow.IsOnline = false; + } } } } @@ -1082,6 +1089,10 @@ /// 缃戝叧鍚嶅瓧鎺т欢 /// </summary> private NormalViewControl btnName = null; + /// <summary> + /// 鍦ㄧ嚎鐘舵�� + /// </summary> + public bool isOnline = false; /// <summary> /// 鑷畾涔夌綉鍏虫帶浠� @@ -1124,7 +1135,9 @@ if (zbway != null) { btnName.Text = HdlGatewayLogic.Current.GetGatewayName(zbway); - if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway) == false) + //鍦ㄧ嚎鐘舵�� + this.isOnline = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway); + if (this.isOnline == false) { btnName.TextColor = UserCenterColor.Current.TextGrayColor1; } @@ -1176,13 +1189,34 @@ return; } btnName.Text = HdlGatewayLogic.Current.GetGatewayName(zbway); - if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway) == false) + //鍒锋柊鎺т欢鍦ㄧ嚎鐘舵�� + this.RefreshOnlineStatu(); + } + + /// <summary> + /// 鍒锋柊鎺т欢鍦ㄧ嚎鐘舵�� + /// </summary> + public void RefreshOnlineStatu() + { + //鑾峰彇鏈湴缃戝叧瀵硅薄 + ZbGateway zbway = HdlGatewayLogic.Current.GetLocalGateway(zbGatewayId); + if (zbway == null) { - btnName.TextColor = UserCenterColor.Current.TextGrayColor1; + return; } - else + //鍦ㄧ嚎鐘舵�� + bool statu = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway); + if (this.isOnline != statu) { - btnName.TextColor = UserCenterColor.Current.TextColor1; + this.isOnline = statu; + if (this.isOnline == false) + { + btnName.TextColor = UserCenterColor.Current.TextGrayColor1; + } + else + { + btnName.TextColor = UserCenterColor.Current.TextColor1; + } } } } -- Gitblit v1.8.0