| | |
| | | //从设备列表中获取在线状态
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //首先获取这些传感器所在的网关
|
| | | var listWay = new List<ZbGateway>();
|
| | | foreach (var device in listDevice)
|
| | | {
|
| | | ZbGateway realWay = null;
|
| | | //是否存在真实物理网关
|
| | | if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, device.CurrentGateWayId) == false)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | listWay.Add(realWay);
|
| | | }
|
| | | foreach (var zbway in listWay)
|
| | | {
|
| | | if (this.Parent == null)
|
| | | {
|
| | | //界面关闭
|
| | | return;
|
| | | }
|
| | | int statu = 0;
|
| | | var list = Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, ref statu, false, ShowErrorMode.NO);
|
| | | if (statu != -1)
|
| | | var deviceInfo = Common.LocalDevice.Current.ReadDeviceEpointDeviceInfo(device);
|
| | | if (deviceInfo != null)
|
| | | {
|
| | | for (int i = 0; i < list.Count; i++)
|
| | | {
|
| | | //设置设备在线状态
|
| | | this.ReceiveDeviceStatuPush(list[i]);
|
| | | }
|
| | | //设置设备在线状态
|
| | | this.ReceiveDeviceStatuPush(device, deviceInfo);
|
| | | }
|
| | | System.Threading.Thread.Sleep(50);
|
| | | }
|
| | | });
|
| | | }, ShowErrorMode.NO);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 接受设备在线推送
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | private void ReceiveDeviceStatuPush(CommonDevice device)
|
| | | private void ReceiveDeviceStatuPush(CommonDevice device, CommonDevice.DeviceInfoData deviceInfo)
|
| | | {
|
| | | if (this.Parent == null)
|
| | | {
|
| | | //界面关闭
|
| | | return;
|
| | | }
|
| | |
|
| | | lock (objOnlineLock)
|
| | | string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
|
| | | if (this.dicSensorStatuView.ContainsKey(mainkeys) == true)
|
| | | {
|
| | | string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
|
| | | if (this.dicSensorStatuView.ContainsKey(mainkeys) == true)
|
| | | CommonDevice Loacldevice = Common.LocalDevice.Current.GetDevice(mainkeys);
|
| | | if (Loacldevice == null)
|
| | | {
|
| | | CommonDevice Loacldevice = Common.LocalDevice.Current.GetDevice(mainkeys);
|
| | | if (Loacldevice == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //在线状态一样的话,不需要刷新
|
| | | if (Loacldevice.IsOnline == device.IsOnline)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //保存状态
|
| | | Loacldevice.IsOnline = device.IsOnline;
|
| | | Loacldevice.ReSave();
|
| | |
|
| | | //因为这是推送过来的,我不保证那一瞬间这个东西会不会被移除
|
| | | var control = this.dicSensorStatuView[mainkeys];
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //设置控件的在线状态文本效果
|
| | | bool bolOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(device);
|
| | | control?.SetOnlineStatu(bolOnline);
|
| | | });
|
| | | return;
|
| | | }
|
| | | //在线状态一样的话,不需要刷新
|
| | | if (Loacldevice.IsOnline == deviceInfo.IsOnline)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //保存状态
|
| | | Loacldevice.IsOnline = deviceInfo.IsOnline;
|
| | |
|
| | | //因为这是推送过来的,我不保证那一瞬间这个东西会不会被移除
|
| | | var control = this.dicSensorStatuView[mainkeys];
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //设置控件的在线状态文本效果
|
| | | bool bolOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(device);
|
| | | control?.SetOnlineStatu(bolOnline);
|
| | | });
|
| | | }
|
| | | }
|
| | |
|