From f23ad1b3f9f6193f35f72104d690b21dc67d5c1f Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期一, 06 七月 2020 12:35:25 +0800 Subject: [PATCH] 去掉了访问外网的异步 --- ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs | 48 ++++++++++++++++++++++++++++-------------------- 1 files changed, 28 insertions(+), 20 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs index 3683150..4e36633 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs @@ -826,18 +826,31 @@ string gwId = GatewayResourse.NowSelectGatewayId; HdlThreadLogic.Current.RunThread(() => { - System.Threading.Thread.Sleep(2000); - //杩欓噷涓昏鍙槸鑾峰彇鍦ㄧ嚎鐘舵�� - var list = LocalDevice.Current.GetDeviceOnlineList(gwId); - HdlThreadLogic.Current.RunMain(() => + if (this.Parent == null) { return; } + //鑾峰彇璁惧鍒楄〃 + var listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(gwId); + var listCheck = new List<string>(); + foreach (var device in listDevice) { - for (int i = 0; i < list.Count; i++) + if (this.Parent == null) { return; } + if (listCheck.Contains(device.DeviceAddr) == false) { - //璁剧疆璁惧鍦ㄧ嚎鐘舵�� - this.ReceiveDeviceStatu(list[i]); + //鍙涓�涓洖璺嵆鍙� + listCheck.Add(device.DeviceAddr); + var deviceInfo = Common.LocalDevice.Current.ReadDeviceEpointDeviceInfo(device); + if (deviceInfo != null) + { + //鍙樻洿鍦ㄧ嚎鐘舵�� + device.IsOnline = deviceInfo.IsOnline; + HdlThreadLogic.Current.RunMain(() => + { + //璁剧疆璁惧鍦ㄧ嚎鐘舵�� + this.ReceiveDeviceStatu(device); + }, ShowErrorMode.NO); + } + System.Threading.Thread.Sleep(30); } - - }, ShowErrorMode.NO); + } }); } @@ -861,13 +874,8 @@ var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys); if (localDevice != null) { - //鍦ㄧ嚎鐘舵�佷竴鏍风殑璇濓紝涓嶉渶瑕佸埛鏂� - if (localDevice.IsOnline != device.IsOnline) - { - //淇濆瓨鐘舵�� - localDevice.IsOnline = device.IsOnline; - localDevice.ReSave(); - } + //淇濆瓨鐘舵�� + localDevice.IsOnline = device.IsOnline; } rowInfo.MenuRow.IsOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(device); @@ -936,9 +944,9 @@ /// <param name="list">ota璁惧</param> private void CheckDeviceNewVersion(List<OTADevice> list) { - HdlThreadLogic.Current.RunThread(async () => + HdlThreadLogic.Current.RunThread(() => { - await System.Threading.Tasks.Task.Delay(2000); + System.Threading.Thread.Sleep(2000); foreach (var ota in list) { if (this.Parent == null) @@ -946,7 +954,7 @@ return; } //娣诲姞鍗囩骇鍥轰欢淇℃伅(鎴愪笉鎴愬姛閮芥棤鎵�璋�) - var result = await HdlFirmwareUpdateLogic.AddFirmwareVersionInfo(FirmwareLevelType.ZigbeeDevice, ota.HwVersion.ToString(), ota.ImgTypeId.ToString()); + var result = HdlFirmwareUpdateLogic.AddFirmwareVersionInfo(FirmwareLevelType.ZigbeeDevice, ota.HwVersion.ToString(), ota.ImgTypeId.ToString()); //鑾峰彇璁惧鏈�鏂扮増鏈� var deviceFirmware = HdlFirmwareUpdateLogic.GetFirmwareMostVersionInfo(FirmwareLevelType.ZigbeeDevice, @@ -960,7 +968,7 @@ } //鎷ユ湁鏂扮増鏈� - Application.RunOnMainThread(() => + HdlThreadLogic.Current.RunMain(() => { if (this.dicRowInfo.ContainsKey(ota.DeviceAddr) == true) { -- Gitblit v1.8.0