From bba578c2f0acf2eca747edcb69426771e0cadd32 Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期一, 23 三月 2020 18:20:50 +0800
Subject: [PATCH] 2020-03-23-3
---
ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs | 563 ++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 382 insertions(+), 181 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs
index 2d698b8..a80cecc 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs
@@ -1,4 +1,5 @@
-锘縰sing System;
+锘縰sing Shared.Common;
+using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
@@ -19,7 +20,7 @@
/// <summary>
/// 鍒楄〃鎺т欢
/// </summary>
- private VerticalListControl listView = null;
+ private VerticalListRefreshControl listView = null;
/// <summary>
/// 琛屾帶浠剁殑淇℃伅(Keys锛歁ac鍦板潃)
/// </summary>
@@ -42,6 +43,8 @@
/// </summary>
public void ShowForm()
{
+ this.ScrollEnabled = false;
+
//璁剧疆鏍囬淇℃伅
base.SetTitleText(Language.StringByID(R.MyInternationalizationString.DeviceManagement));
@@ -89,18 +92,15 @@
this.gatewayViewRow = new MyGatewayControl(GatewayResourse.NowSelectGateway);
bodyFrameLayout.AddChidren(gatewayViewRow);
gatewayViewRow.InitControl();
- //璁剧疆缃戝叧鎺ュ彈鍦ㄧ嚎鐘舵�佹帹閫�
- this.AddGatewayOnlinePush();
//鍒濆鍖栨悳绱㈡帶浠�
this.InitSearchControl();
- new System.Threading.Thread(() =>
+ HdlThreadLogic.Current.RunThread(() =>
{
//鍒濆鍖栬澶囧垪琛ㄦ帶浠�
this.InitDeviceListControl();
- })
- { IsBackground = true }.Start();
+ });
}
#endregion
@@ -128,10 +128,18 @@
txtSearchControl.BindEvent(this.SetRowDataBySearchKeys);
//鍒楄〃鎺т欢
- listView = new VerticalListControl(29);
+ listView = new VerticalListRefreshControl(29);
listView.Y = txtSearchControl.Bottom + Application.GetRealHeight(29);
listView.Height = frame.Height - txtSearchControl.Bottom - Application.GetRealHeight(29);
frame.AddChidren(listView);
+ listView.BeginHeaderRefreshingAction += () =>
+ {
+ HdlThreadLogic.Current.RunThread(() =>
+ {
+ //涓嬫媺鍒锋柊
+ this.ListViewBeginHeaderRefreshing();
+ });
+ };
}
#endregion
@@ -146,6 +154,8 @@
//鑾峰彇璁惧鍒楄〃
string gwID = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
var listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(gwID);
+ var listSpecialOta = Common.LocalDevice.Current.GetSpecialOtaDevice(gwID);
+ listDevice.AddRange(listSpecialOta);
this.dicRowInfo.Clear();
@@ -158,12 +168,12 @@
//鏍规嵁MAC鍚堝苟璁惧鍒楄〃
this.MargeAllDeviceByMac(listDevice);
- Application.RunOnMainThread(() =>
+ if (this.Parent == null)
{
- if (this.Parent == null)
- {
- return;
- }
+ return;
+ }
+ HdlThreadLogic.Current.RunMain(() =>
+ {
var listOta = new List<OTADevice>();
foreach (var macAddress in this.dicRowInfo.Keys)
{
@@ -176,13 +186,7 @@
//娣诲姞璁惧鐨勮彍鍗曡
this.AddDeviceMenuRow(macAddress);
}
- //娣诲姞搴曢儴闂撮殭
- var frameTemp = new FrameLayout();
- frameTemp.Height = Application.GetRealHeight(23);
- listView.AddChidren(frameTemp);
- //寮�鍚澶囧睘鎬у彉鏇寸洃鍚�
- this.AddDeviceAttributePush();
//寮�鍚綉鍏冲湪绾跨洃娴嬬殑绾跨▼
this.StartGatewayOnlieCheckThread();
//妫�娴嬭澶囨柊鐗堟湰
@@ -214,8 +218,10 @@
rowMenu.InitControl();
rowInfo.MenuRow = rowMenu;
//鍚戝彸鍥炬爣
- var btnRight = rowMenu.frameTable.AddRightArrow();
+ var btnRight = rowMenu.frameTable.AddMostRightEmptyIcon(58, 58);
+ btnRight.UnSelectedImagePath = "Item/RightNext.png";
btnRight.SelectedImagePath = "Item/Down.png";
+ rowMenu.frameTable.ChangedChidrenBindMode(btnRight, ChidrenBindMode.NotBind);
//鎻愮ず鏂扮増鏈�
var btnNew = new InformationTipView(rowMenu.btnIcon);
@@ -225,7 +231,7 @@
//妫�娴嬭澶囨槸鍚︽嫢鏈夊畾浣嶇殑鍔熻兘
var listdevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
- if (Common.LocalDevice.Current.DeviceIsCanFixedPosition(listdevice[0]) == true)
+ if (listdevice.Count > 0 && Common.LocalDevice.Current.DeviceIsCanFixedPosition(listdevice[0]) == true)
{
//瀹氫綅
var btnPosition = new NormalViewControl(Application.GetRealWidth(184), rowMenu.Height, false);
@@ -242,22 +248,33 @@
};
}
- rowMenu.frameTable.ButtonClickEvent += (sender, e) =>
+ //灞曞紑,鎶樺彔
+ btnRight.ButtonClickEvent += (sender, e) =>
{
- //澶氬洖璺殑鎯呭喌涓嬶紝鎵嶄細灞曞紑
- if (Common.LocalDevice.Current.GetDevicesByMac(deviceMac).Count == 1)
- {
- var form = new DeviceMacInfoEditorForm();
- form.AddForm(deviceMac);
- //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃
- this.nowActionDeviceMac = deviceMac;
- }
- else
+ //鍥炶矾鏁板ぇ浜�1鎵嶅睍寮�
+ if (Common.LocalDevice.Current.GetDevicesCountByMac(deviceMac) > 1)
{
btnRight.IsSelected = !btnRight.IsSelected;
//灞曞紑鎴栬�呮姌鍙犳槑缁嗗垪琛�
this.ShowDetailList(deviceMac, btnRight.IsSelected);
}
+ else
+ {
+ btnNew.Visible = false;
+ var form = new DeviceMacInfoEditorForm();
+ form.AddForm(deviceMac);
+ //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃
+ this.nowActionDeviceMac = deviceMac;
+ }
+ };
+
+ rowMenu.frameTable.ButtonClickEvent += (sender, e) =>
+ {
+ btnNew.Visible = false;
+ var form = new DeviceMacInfoEditorForm();
+ form.AddForm(deviceMac);
+ //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃
+ this.nowActionDeviceMac = deviceMac;
};
}
@@ -285,10 +302,12 @@
//鏍囬鑷繁灏辨槸涓�涓瓙鎺т欢
if (rowInfo.frameTable.ChildrenCount == 1)
{
+ //鑾峰彇杩欎竴鍫嗚澶囨椂灞炰簬浠�涔堢被鍨嬬殑
+ var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listDevice);
foreach (CommonDevice info in listDevice)
{
//鍔犺浇瀹冪殑鍒楄〃
- this.AddDeviceDetailRow(rowInfo.frameTable, info);
+ this.AddDeviceDetailRow(rowInfo.frameTable, info, deviceEnumInfo);
}
}
}
@@ -301,10 +320,14 @@
/// </summary>
/// <param name="frame">瀹瑰櫒</param>
/// <param name="device"></param>
- private void AddDeviceDetailRow(FrameListControl frame, CommonDevice device)
+ /// <param name="deviceEnumInfo"></param>
+ private void AddDeviceDetailRow(FrameListControl frame, CommonDevice device, DeviceEnumInfo deviceEnumInfo)
{
var rowInfo = this.dicRowInfo[device.DeviceAddr];
- rowInfo.dicDetailRow = new Dictionary<string, DeviceRoomControl>();
+ if (rowInfo.dicDetailRow == null)
+ {
+ rowInfo.dicDetailRow = new Dictionary<string, DeviceRoomControl>();
+ }
//琛屾帶浠�
var rowDevice = new DeviceRoomControl(device, frame.rowSpace / 2);
@@ -315,6 +338,8 @@
rowDevice.frameTable.AddBottomLine();
//鍙崇澶�
rowDevice.frameTable.AddRightArrow();
+ //鍦ㄧ嚎鐘舵��
+ rowDevice.isOnline = device.IsOnline == 1;
//淇濆瓨鎺т欢
string maikey = Common.LocalDevice.Current.GetDeviceMainKeys(device);
@@ -340,11 +365,139 @@
rowDevice.frameTable.ButtonClickEvent += (sender, e) =>
{
- var form = new DeviceMacInfoEditorForm();
- form.AddForm(device.DeviceAddr);
//鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃
this.nowActionDeviceMac = device.DeviceAddr;
+ //鏄剧ず璁惧鍔熻兘閰嶇疆鐣岄潰
+ this.ShowDeviceFunctionSettionForm(device, deviceEnumInfo);
};
+ }
+
+ /// <summary>
+ /// 鏄剧ず璁惧鍔熻兘閰嶇疆鐣岄潰
+ /// </summary>
+ /// <param name="device"></param>
+ /// <param name="deviceEnumInfo"></param>
+ private void ShowDeviceFunctionSettionForm(CommonDevice device, DeviceEnumInfo deviceEnumInfo)
+ {
+ //鏅鸿兘闂ㄩ攣
+ if (deviceEnumInfo.BeloneType == DeviceBeloneType.A鏅鸿兘闂ㄩ攣)
+ {
+ var form = new DeviceMacInfoEditorForm();
+ form.AddForm(device.DeviceAddr);
+ }
+ else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A绐楀笜)
+ {
+ var form = new DeviceMacInfoEditorForm();
+ form.AddForm(device.DeviceAddr);
+ }
+ //pir浼犳劅鍣�
+ else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.Sensor_Pir)
+ {
+ if (device is IASZone)
+ {
+ var form = new DevicePirSensor.PirSensorBindTargetSettionForm();
+ form.AddForm((IASZone)device);
+ }
+ else
+ {
+ //pir浼犳劅鍣�,浠栦滑鍙堟悶浜嗕釜缁х數鍣ㄥ湪閲岄潰
+ var form = new DeviceFunctionSettionForm();
+ form.AddForm(device, true);
+ }
+ }
+ //涓ぎ绌鸿皟
+ else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.AirConditioner_ZbGateway)
+ {
+ var form = new DeviceAirConditioner.IndoorUnitSettionForm();
+ form.AddForm((AC)device);
+ }
+ //鐜闈㈡澘
+ else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueEnvironment)
+ {
+ var form = new DeviceFunctionSettionForm();
+ form.AddForm(device, true);
+ }
+ //鏂伴闈㈡澘
+ else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir)
+ {
+ var form = new DeviceFunctionSettionForm();
+ form.AddForm(device, true);
+ }
+ //鏂规偊闈㈡澘
+ else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueTwo
+ || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFour
+ || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueEight)
+ {
+ //骞叉帴鐐�
+ if (device.Type == DeviceType.OnOffSwitch)
+ {
+ //鏂规偊闈㈡澘鐨勬寜閿厤缃�
+ var form = new DevicePanel.PanelFangyueButtonSettionForm();
+ form.AddForm(device);
+ }
+ //缁х數鍣�
+ else if (device.Type == DeviceType.OnOffOutput)
+ {
+ //鏂规偊闈㈡澘鐨勫姛鑳介厤缃�
+ var form = new DevicePanel.PanelFangyueFunctionSettionForm();
+ form.AddForm(device);
+ }
+ else
+ {
+ var form = new DeviceFunctionSettionForm();
+ form.AddForm(device, true);
+ }
+ }
+ //闈㈡澘璁惧
+ else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A鎸夐敭闈㈡澘)
+ {
+ //骞叉帴鐐�
+ if (device.Type == DeviceType.OnOffSwitch)
+ {
+ //娌充笢璁惧
+ if (deviceEnumInfo.IsHdlDevice == true)
+ {
+ var form = new DevicePanel.PanelButtonSettionForm();
+ form.AddForm(device);
+ }
+ else
+ {
+ var form = new DeviceDryContactSettionForm();
+ form.AddForm(device);
+ }
+ }
+ //缁х數鍣�
+ else if (device.Type == DeviceType.OnOffOutput)
+ {
+ //娌充笢璁惧
+ if (deviceEnumInfo.IsHdlDevice == true)
+ {
+ var form = new DevicePanel.PanelFunctionSettionForm();
+ form.AddForm(device);
+ }
+ else
+ {
+ var form = new DeviceFunctionSettionForm();
+ form.AddForm(device, true);
+ }
+ }
+ else
+ {
+ var form = new DeviceFunctionSettionForm();
+ form.AddForm(device, true);
+ }
+ }
+ //濡傛灉鏄共鎺ョ偣
+ else if (device.Type == DeviceType.OnOffSwitch)
+ {
+ var form = new DeviceDryContactSettionForm();
+ form.AddForm(device);
+ }
+ else
+ {
+ var form = new DeviceFunctionSettionForm();
+ form.AddForm(device, true);
+ }
}
#endregion
@@ -403,6 +556,60 @@
#endregion
+ #region 鈻� 涓嬫媺鍒锋柊___________________________
+
+ /// <summary>
+ /// 婊戝姩鎺т欢涓嬫媺鍒锋柊
+ /// </summary>
+ private async void ListViewBeginHeaderRefreshing()
+ {
+ //濡傛灉鏄湪绾跨殑
+ if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(GatewayResourse.NowSelectGateway) == true)
+ {
+ //妫�娴嬪箍鎾埌鐨勮繖涓綉鍏虫槸鍚︽嫢鏈変綇瀹匢D
+ ZbGateway realWay = null;
+ if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, GatewayResourse.NowSelectGateway) == true)
+ {
+ //閲嶆柊璁剧疆浣忓畢ID(杩欎釜搴旇鏄笉缁忚繃APP,鐩存帴鎶婄綉鍏虫仮澶嶄簡鍑哄巶璁剧疆)
+ if (HdlGatewayLogic.Current.HomeIdIsEmpty(realWay.getGatewayBaseInfo.HomeId) == true)
+ {
+ //鏄剧ず杩涘害鏉�
+ ProgressBar.Show();
+ int result2 = await HdlGatewayLogic.Current.ReBindNewGateway(realWay);
+ //鍏抽棴杩涘害鏉�
+ ProgressBar.Close();
+ if (result2 == -1)
+ {
+ return;
+ }
+ }
+ }
+ }
+ if (this.Parent == null)
+ {
+ return;
+ }
+
+ //鑾峰彇鍏ㄩ儴璁惧
+ int result = LocalDevice.Current.SetDeviceToMemmoryByGateway(GatewayResourse.NowSelectGateway);
+ if (this.Parent == null)
+ {
+ return;
+ }
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ //闅愯棌涓嬫媺鍒锋柊鐗规晥
+ listView.EndHeaderRefreshing();
+ if (result != -1)
+ {
+ //閲嶆柊鍒锋柊鐣岄潰
+ this.InitMiddleFrame(false);
+ }
+ });
+ }
+
+ #endregion
+
#region 鈻� 缃戝叧鍦ㄧ嚎妫�娴媉______________________
/// <summary>
@@ -416,7 +623,7 @@
}
string selectGwId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
- new System.Threading.Thread(() =>
+ HdlThreadLogic.Current.RunThread(() =>
{
ZbGateway zbGateway = HdlGatewayLogic.Current.GetLocalGateway(selectGwId);
if (zbGateway == null)
@@ -436,8 +643,7 @@
this.StartDeviceListControlThread(online);
}
});
- })
- { IsBackground = true }.Start();
+ });
}
/// <summary>
@@ -462,29 +668,7 @@
#endregion
- #region 鈻� 璁惧灞炴�у彉鏇存帹閫乢__________________
-
- /// <summary>
- /// 璁惧灞炴�у彉鏇存帹閫�
- /// </summary>
- /// <param name="device"></param>
- public override void DeviceAttributePush(CommonDevice device)
- {
- if (dicRowInfo.ContainsKey(device.DeviceAddr) == false)
- {
- return;
- }
- var rowInfo = dicRowInfo[device.DeviceAddr];
- Application.RunOnMainThread(() =>
- {
- //鍒锋柊鑿滃崟
- rowInfo.MenuRow?.RefreshControlInfo(false);
- });
- }
-
- #endregion
-
- #region 鈻� 寮�鍚澶囧湪绾跨嚎绋媉__________________
+ #region 鈻� 璁惧鍦ㄧ嚎妫�娴媉______________________
/// <summary>
/// 寮�鍚澶囧湪绾跨嚎绋�
@@ -504,10 +688,6 @@
this.StartCheckDeviceOnline();
}
- #endregion
-
- #region 鈻� 璁惧鍦ㄧ嚎___________________________
-
/// <summary>
/// 寮�鍚澶囧湪绾跨洃娴�
/// </summary>
@@ -518,60 +698,72 @@
{
return;
}
+
+ //娣诲姞鎺ユ敹璁惧鍦ㄧ嚎涓婃姤鐨勭洃鍚�
+ HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormReceivePushOnline", ReceiveComandDiv.A璁惧鍦ㄧ嚎涓婃姤, this.ReceiveDeviceStatu);
+
string gwId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
- new System.Threading.Thread(async () =>
+ HdlThreadLogic.Current.RunThread(() =>
{
//杩欓噷涓昏鍙槸鑾峰彇鍦ㄧ嚎鐘舵��
var zbway = HdlGatewayLogic.Current.GetLocalGateway(gwId);
- var result = await Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, this.ReceiveDeviceStatuPush);
- })
- { IsBackground = true }.Start();
+ int statu = 0;
+ var list = LocalDevice.Current.GetDeviceListFromGateway(zbway, ref statu, false, ShowErrorMode.NO);
+ if (statu != -1)
+ {
+ for (int i = 0; i < list.Count; i++)
+ {
+ //璁剧疆璁惧鍦ㄧ嚎鐘舵��
+ this.ReceiveDeviceStatu(list[i]);
+ }
+ }
+ });
}
/// <summary>
- /// 鎺ュ彈璁惧鍦ㄧ嚎鎺ㄩ�侊紙缃戝叧鍦ㄧ嚎鎺ㄩ�佸嵆鍦ㄧ嚎锛�
+ /// 鎺ュ彈璁惧鐘舵��
/// </summary>
/// <param name="device"></param>
- private void ReceiveDeviceStatuPush(CommonDevice device)
+ private void ReceiveDeviceStatu(CommonDevice device)
{
- lock (dicRowInfo)
+ DeviceObjRowInfo rowInfo = null;
+ if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == true)
{
- if (device == null || this.Parent == null)
- {
- return;
- }
- DeviceObjectControl row = null;
- if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == true)
- {
- row = this.dicRowInfo[device.DeviceAddr].MenuRow;
- }
- if (row == null)
- {
- return;
- }
- //鍒锋柊璁惧鐨勫湪绾跨姸鎬�
- string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
- var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys);
- if (localDevice != null)
- {
- //鍦ㄧ嚎鐘舵�佷竴鏍风殑璇濓紝涓嶉渶瑕佸埛鏂�
- if (localDevice.IsOnline == device.IsOnline)
- {
- return;
- }
- //淇濆瓨鐘舵��
- localDevice.IsOnline = device.IsOnline;
- localDevice.ReSave();
- }
-
- Application.RunOnMainThread(() =>
- {
- if (row != null)
- {
- row.isOnline = device.IsOnline == 1;
- }
- });
+ rowInfo = this.dicRowInfo[device.DeviceAddr];
}
+ if (rowInfo == null || rowInfo.MenuRow == null)
+ {
+ return;
+ }
+ //鍒锋柊璁惧鐨勫湪绾跨姸鎬�
+ string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
+ var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys);
+ if (localDevice != null)
+ {
+ //鍦ㄧ嚎鐘舵�佷竴鏍风殑璇濓紝涓嶉渶瑕佸埛鏂�
+ if (localDevice.IsOnline == device.IsOnline)
+ {
+ return;
+ }
+ //淇濆瓨鐘舵��
+ localDevice.IsOnline = device.IsOnline;
+ localDevice.ReSave();
+ }
+
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ if (rowInfo != null)
+ {
+ rowInfo.MenuRow.isOnline = device.IsOnline == 1;
+ if (rowInfo.dicDetailRow != null)
+ {
+ foreach (var detailRow in rowInfo.dicDetailRow.Values)
+ {
+ detailRow.isOnline = rowInfo.MenuRow.isOnline;
+ }
+ }
+ }
+ });
}
/// <summary>
@@ -596,6 +788,29 @@
#endregion
+ #region 鈻� 浼犳劅鍣ㄦ姤璀________________________
+
+ /// <summary>
+ /// 寮�鍚紶鎰熷櫒鎶ヨ鐩戣
+ /// </summary>
+ private void StartCheckDeviceAlarm()
+ {
+ HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormSensor", ReceiveComandDiv.A浼犳劅鍣ㄤ笂鎶�, (device) =>
+ {
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == false)
+ {
+ return;
+ }
+ //鏄剧ず浼犳劅鍣ㄤ笂鎶ョ殑鐗规晥
+ this.dicRowInfo[device.DeviceAddr].MenuRow?.StartSensorPushAppeal();
+ });
+ });
+ }
+
+ #endregion
+
#region 鈻� 璁惧鏂扮増鏈琠________________________
/// <summary>
@@ -604,7 +819,7 @@
/// <param name="list">ota璁惧</param>
private void CheckDeviceNewVersion(List<OTADevice> list)
{
- new System.Threading.Thread(async () =>
+ HdlThreadLogic.Current.RunThread(async () =>
{
await System.Threading.Tasks.Task.Delay(2000);
foreach (var ota in list)
@@ -644,34 +859,7 @@
}
});
}
- })
- { IsBackground = true }.Start();
- }
-
- #endregion
-
- #region 鈻� 浼犳劅鍣ㄦ姤璀________________________
-
- /// <summary>
- /// 寮�鍚紶鎰熷櫒鎶ヨ鐩戣
- /// </summary>
- private void StartCheckDeviceAlarm()
- {
- HdlDeviceAttributeLogic.Current.AddAttributeEvent("DeviceListFormSensor", "IASInfoReport", (device) =>
- {
- Application.RunOnMainThread(() =>
- {
- if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == false)
- {
- return;
- }
- var row = this.dicRowInfo[device.DeviceAddr].MenuRow;
- if (row != null)
- {
- row.frameTable.StartSelectStatuAppeal(3000);
- }
- });
- });
+ });
}
#endregion
@@ -688,6 +876,17 @@
if (this.dicRowInfo.ContainsKey(deviceAddr) == false)
{
var localDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceAddr);
+ if (localDevice.Count == 0)
+ {
+ //閽堝鍗曠函鍙湁涓�涓�200绔偣鐨勮澶�
+ var ota = Common.LocalDevice.Current.GetOTADevice(deviceAddr);
+ if (ota == null)
+ {
+ //鍏ョ綉涔嬪悗锛屽張鎶婂畠鍒犱簡
+ return;
+ }
+ localDevice.Add(ota);
+ }
var rowNewInfo = new DeviceObjRowInfo();
rowNewInfo.DeviceMac = deviceAddr;
rowNewInfo.MacName = Common.LocalDevice.Current.GetDeviceMacName(localDevice[0]);
@@ -696,8 +895,6 @@
//鍒涘缓鏂扮殑琛�
this.AddDeviceMenuRow(deviceAddr);
-
- return;
}
}
@@ -711,11 +908,9 @@
/// <param name="listDevice"></param>
private void MargeAllDeviceByMac(List<CommonDevice> listDevice)
{
- //璁惧鎺掑簭
- List<CommonDevice> listSort = Common.LocalDevice.Current.SortDeviceList(listDevice);
//鏍规嵁Mac鍏ㄩ儴鍒嗙粍
var dic = new Dictionary<string, List<CommonDevice>>();
- foreach (CommonDevice device in listSort)
+ foreach (CommonDevice device in listDevice)
{
if (device == null || device.DeviceAddr == null)
{
@@ -740,54 +935,37 @@
#endregion
- #region 鈻� 鍏抽棴鐣岄潰___________________________
-
- /// <summary>
- /// 鐢婚潰鍏抽棴
- /// </summary>
- public override void CloseForm()
- {
- HdlDeviceAttributeLogic.Current.RemoveEvent("DeviceListFormSensor");
- HdlDeviceAttributeLogic.Current.RemoveEvent("DeviceListFormReceivePushOnline");
-
- GatewayResourse.NowSelectGateway = null;
-
- base.CloseForm();
- }
-
- #endregion
-
#region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________
/// <summary>
/// 鑷韩鐨勪笂灞傜晫闈㈠叧闂悗,瀹冭嚜韬浜庢渶涓婂眰鏃�,瑙﹀彂鐨勪簨浠�
/// </summary>
- public override void FormActionAgainEvent()
+ public override int FormActionAgainEvent()
{
- if (this.nowActionDeviceMac == null)
+ if (this.nowActionDeviceMac != null)
{
- return;
- }
- var rowInfo = this.dicRowInfo[nowActionDeviceMac];
- //妫�娴嬭繖涓澶囨槸鍚﹁鍒犻櫎
- if (Common.LocalDevice.Current.GetDevicesByMac(nowActionDeviceMac).Count == 0)
- {
- //绉婚櫎鎺т欢
- rowInfo.dicDetailRow = null;
- rowInfo.frameTable.RemoveFromParent();
-
- this.dicRowInfo.Remove(nowActionDeviceMac);
- rowInfo = null;
- }
- else
- {
- //鍒锋柊璁惧淇℃伅
- rowInfo.MenuRow?.RefreshControlInfo(true);
- if (rowInfo.dicDetailRow != null)
+ var rowInfo = this.dicRowInfo[nowActionDeviceMac];
+ //妫�娴嬭繖涓澶囨槸鍚﹁鍒犻櫎 2020.01.13鍙樻洿:杩藉姞Ota璁惧鐨勫垽鏂�
+ if (Common.LocalDevice.Current.GetDevicesByMac(nowActionDeviceMac).Count == 0
+ && Common.LocalDevice.Current.GetOTADevice(nowActionDeviceMac) == null)
{
- foreach (var contr in rowInfo.dicDetailRow.Values)
+ //绉婚櫎鎺т欢
+ rowInfo.dicDetailRow = null;
+ rowInfo.frameTable.RemoveFromParent();
+
+ this.dicRowInfo.Remove(nowActionDeviceMac);
+ rowInfo = null;
+ }
+ else
+ {
+ //鍒锋柊璁惧淇℃伅
+ rowInfo.MenuRow?.RefreshControlInfo(true);
+ if (rowInfo.dicDetailRow != null)
{
- contr?.RefreshControlInfo();
+ foreach (var contr in rowInfo.dicDetailRow.Values)
+ {
+ contr?.RefreshControlInfo();
+ }
}
}
}
@@ -795,6 +973,25 @@
this.nowActionDeviceMac = null;
//缃戝叧鎺т欢鍒锋柊
this.gatewayViewRow.RefreshControl();
+
+ return 1;
+ }
+
+ #endregion
+
+ #region 鈻� 鍏抽棴鐣岄潰___________________________
+
+ /// <summary>
+ /// 鐢婚潰鍏抽棴
+ /// </summary>
+ public override void CloseFormBefore()
+ {
+ HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceListFormSensor");
+ HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceListFormReceivePushOnline");
+
+ GatewayResourse.NowSelectGateway = null;
+
+ base.CloseFormBefore();
}
#endregion
@@ -915,6 +1112,10 @@
{
//鑾峰彇鏈湴缃戝叧瀵硅薄
ZbGateway zbway = HdlGatewayLogic.Current.GetLocalGateway(zbGatewayId);
+ if (zbway == null)
+ {
+ return;
+ }
btnName.Text = HdlGatewayLogic.Current.GetGatewayName(zbway);
if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway) == false)
{
--
Gitblit v1.8.0