From b74c052b43d7c4a830386940a036eb7c2ec9abc2 Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期二, 14 一月 2020 13:37:26 +0800
Subject: [PATCH] 2020-1-14-01
---
ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs | 110 +++++++++++++++++++++++++++++++-----------------------
1 files changed, 63 insertions(+), 47 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs
index aca18a0..f9561e4 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs
@@ -31,7 +31,11 @@
/// <summary>
/// 涓婚闂寸殑瓒呮椂鏃堕棿 -100:涓柇绾跨▼(鍗曚綅锛氱)
/// </summary>
- private int topTimeOut = 60;
+ private int topTimeOut = 120;
+ /// <summary>
+ /// 瓒呮椂鏈�澶ф椂闂�
+ /// </summary>
+ private int topMaxTime = 120;
/// <summary>
/// 鐢婚潰ID,鏍囪瀹冪敱鍝釜鐣岄潰璋冪敤骞舵墦寮�鐨�
/// </summary>
@@ -40,6 +44,10 @@
/// 缃戝叧ID
/// </summary>
private string gatewayId = string.Empty;
+ /// <summary>
+ /// 鐪熷疄缃戝叧
+ /// </summary>
+ private ZbGateway realGateway = null;
/// <summary>
/// 杩涘害鏉�
/// </summary>
@@ -60,24 +68,25 @@
/// <summary>
/// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
/// </summary>
- /// <param name="i_formId">鐢婚潰ID,鏍囪瀹冪敱鍝釜鐣岄潰璋冪敤骞舵墦寮�鐨�</param>
- public void ShowForm(string i_formId)
- {
- this.targetFormId = i_formId;
-
- //璁剧疆鏍囬淇℃伅
- base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddDevice));
-
- this.gatewayId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
-
- //鍒濆鍖栦腑閮ㄦ帶浠�
- this.InitMiddleFrame();
- }
-
- /// <summary>
- /// 鍒濆鍖栦腑閮ㄦ帶浠�
- /// </summary>
- private void InitMiddleFrame()
+ /// <param name="i_formId">鐢婚潰ID,鏍囪瀹冪敱鍝釜鐣岄潰璋冪敤骞舵墦寮�鐨�</param>
+ public void ShowForm(string i_formId)
+ {
+ this.targetFormId = i_formId;
+
+ //璁剧疆鏍囬淇℃伅
+ base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddDevice));
+
+ this.gatewayId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
+ HdlGatewayLogic.Current.GetRealGateway(ref this.realGateway, this.gatewayId);
+
+ //鍒濆鍖栦腑閮ㄦ帶浠�
+ this.InitMiddleFrame();
+ }
+
+ /// <summary>
+ /// 鍒濆鍖栦腑閮ㄦ帶浠�
+ /// </summary>
+ private void InitMiddleFrame()
{
//娓呯┖bodyFrame
this.ClearBodyFrame();
@@ -98,17 +107,17 @@
bodyFrameLayout.AddChidren(btnSearch);
//杩涘害鏉�
- var btnProRow = new FrameLayout();
- btnProRow.Gravity = Gravity.CenterHorizontal;
- btnProRow.Y = Application.GetRealHeight(861);
- btnProRow.Width = Application.GetRealWidth(559);
- btnProRow.Height = Application.GetRealHeight(29);
+ var btnProRow = new FrameLayout();
+ btnProRow.Gravity = Gravity.CenterHorizontal;
+ btnProRow.Y = Application.GetRealHeight(861);
+ btnProRow.Width = Application.GetRealWidth(559);
+ btnProRow.Height = Application.GetRealHeight(29);
btnProRow.BackgroundColor = 0xffe6e6e6;
btnProRow.Radius = (uint)Application.GetRealHeight(29) / 2;
- bodyFrameLayout.AddChidren(btnProRow);
- this.btnProgressBar = new FrameLayout();
- btnProgressBar.Width = 0;
- btnProgressBar.Height = btnProRow.Height;
+ bodyFrameLayout.AddChidren(btnProRow);
+ this.btnProgressBar = new FrameLayout();
+ btnProgressBar.Width = 0;
+ btnProgressBar.Height = btnProRow.Height;
btnProgressBar.Radius = btnProRow.Radius;
btnProgressBar.BackgroundColor = 0xfffb744a;
btnProgressBar.Radius = (uint)Application.GetRealHeight(29) / 2;
@@ -140,16 +149,15 @@
return;
}
//璁╃綉鍏冲厑璁稿叆缃�
- GatewayResourse.NowSelectGateway.AddNewDeviceToGateway(255);
+ this.realGateway.AddNewDeviceToGateway(180);
System.Threading.Thread.Sleep(1000);
}
});
//娣诲姞鐩戣璁惧鏂颁笂鎶ョ殑浜嬩欢
- GatewayResourse.NowSelectGateway.GwResDataAction += this.AdjustGatewayResultData;
-
- //寮�鍚繛鎺ョ殑鍋囨兂鍔ㄧ敾鏁堟灉绾跨▼
- this.StartConcetionAnimeteThread();
+ this.realGateway.GwResDataAction += this.AdjustGatewayResultData;
+ //寮�鍚繛鎺ョ殑鍋囨兂鍔ㄧ敾鏁堟灉绾跨▼
+ this.StartConcetionAnimeteThread();
}
#endregion
@@ -168,7 +176,7 @@
if (result == -1)
{
//鍋滄鎺ユ敹
- GatewayResourse.NowSelectGateway.GwResDataAction -= this.AdjustGatewayResultData;
+ this.realGateway.GwResDataAction -= this.AdjustGatewayResultData;
Application.RunOnMainThread(() =>
{
@@ -205,7 +213,7 @@
//缁欐柊璁惧璁剧疆涓婚敭灞炴��
Common.LocalDevice.Current.SetNewDeviceMainKeys(device, jobject);
- device.CurrentGateWayId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
+ device.CurrentGateWayId = HdlGatewayLogic.Current.GetGatewayId(this.realGateway);
//灏咲eviceInfo鐨勫睘鎬ц缃埌涓诲睘鎬т腑
Common.LocalDevice.Current.SetDeviceInfoToMain(device, device);
@@ -260,7 +268,7 @@
this.waitDeviceTimeOut--;
}
//鍋滄鎺ユ敹
- GatewayResourse.NowSelectGateway.GwResDataAction -= this.AdjustGatewayResultData;
+ this.realGateway.GwResDataAction -= this.AdjustGatewayResultData;
System.Threading.Thread.Sleep(500);
//鐩墠灏卞紕涓�涓�
@@ -333,9 +341,17 @@
HdlThreadLogic.Current.RunThread(() =>
{
int index = 1;
+ int timeCount = 0;
while (this.Parent != null)
{
System.Threading.Thread.Sleep(500);
+ timeCount++;
+ if (timeCount >= 240)
+ {
+ //120绉掑悗,鍐嶆鍙戦�佺綉鍏宠澶囧叆缃戝懡浠�
+ this.realGateway.AddNewDeviceToGateway(180);
+ timeCount = 0;
+ }
Application.RunOnMainThread(() =>
{
if (btnRound != null)
@@ -366,7 +382,7 @@
{
if (topic == gatewayId + "/Device/DeviceAnnounce_Respon")
{
- this.topTimeOut = 60;
+ this.topTimeOut = topMaxTime;
//缃戝叧鍛婄煡瀹㈡埛绔湁璁惧澹版槑
this.SetDeviceProgressValue(1);
return 2;
@@ -383,7 +399,7 @@
HdlLogLogic.Current.WriteLog(-1, resultData);
return 2;
}
- this.topTimeOut = 60;
+ this.topTimeOut = topMaxTime;
//璁剧疆杩涘害鍊�
this.SetDeviceProgressValue(2);
return 2;
@@ -400,7 +416,7 @@
HdlLogLogic.Current.WriteLog(-1, resultData);
return 2;
}
- this.topTimeOut = 60;
+ this.topTimeOut = topMaxTime;
//璁剧疆杩涘害鍊�
this.SetDeviceProgressValue(3);
return 2;
@@ -417,7 +433,7 @@
//HdlLogLogic.Current.WriteLog(-1, resultData);
return 2;
}
- this.topTimeOut = 60;
+ this.topTimeOut = topMaxTime;
//璁剧疆杩涘害鍊�
this.SetDeviceProgressValue(4);
return 2;
@@ -434,7 +450,7 @@
HdlLogLogic.Current.WriteLog(-1, resultData);
return 2;
}
- this.topTimeOut = 60;
+ this.topTimeOut = topMaxTime;
//璁剧疆杩涘害鍊�
this.SetDeviceProgressValue(5);
return 2;
@@ -510,19 +526,19 @@
/// <summary>
/// 鐢婚潰鍏抽棴
- /// </summary>
- public override void CloseForm()
- {
- base.CloseForm();
+ /// </summary>
+ public override void CloseFormBefore()
+ {
//鍋滄鎺ユ敹
- GatewayResourse.NowSelectGateway.GwResDataAction -= this.AdjustGatewayResultData;
+ this.realGateway.GwResDataAction -= this.AdjustGatewayResultData;
HdlThreadLogic.Current.RunThread(() =>
{
System.Threading.Thread.Sleep(1200);
//鍏抽棴鍏ョ綉妯″紡
- GatewayResourse.NowSelectGateway.AddNewDeviceToGateway(0);
+ this.realGateway.AddNewDeviceToGateway(0);
});
+ base.CloseFormBefore();
}
#endregion
--
Gitblit v1.8.0