From bd46c57c77c276014db3192a4e2cc96e23c93202 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期五, 21 二月 2020 13:08:47 +0800 Subject: [PATCH] 先上传个版本吧 --- ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs | 126 +++++++++++++++++++++++------------------ 1 files changed, 70 insertions(+), 56 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs index e714665..a32c91a 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs @@ -21,9 +21,9 @@ /// </summary> private bool isDeviceThreadStart = false; /// <summary> - /// 绛夊緟璁惧鐨勫洖棣堢殑瓒呮椂鏃堕棿(鍗曚綅锛氱) + /// 绛夊緟璁惧鐨勫洖棣堢殑瓒呮椂鏃堕棿(鍗曚綅锛氱櫨姣) /// </summary> - private int waitDeviceTimeOut = 3; + private int waitDeviceTimeOut = 20; /// <summary> /// 涓婚瓒呮椂鐨勭嚎绋嬫槸鍚﹀紑鍚� /// </summary> @@ -45,6 +45,10 @@ /// </summary> private string gatewayId = string.Empty; /// <summary> + /// 鐪熷疄缃戝叧 + /// </summary> + private ZbGateway realGateway = null; + /// <summary> /// 杩涘害鏉� /// </summary> private FrameLayout btnProgressBar = null; @@ -64,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(); @@ -102,18 +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; - btnProgressBar.Radius = btnProRow.Radius; + bodyFrameLayout.AddChidren(btnProRow); + this.btnProgressBar = new FrameLayout(); + btnProgressBar.Width = 0; + btnProgressBar.Height = btnProRow.Height; btnProgressBar.BackgroundColor = 0xfffb744a; btnProgressBar.Radius = (uint)Application.GetRealHeight(29) / 2; btnProRow.AddChidren(btnProgressBar); @@ -144,13 +148,15 @@ return; } //璁╃綉鍏冲厑璁稿叆缃� - GatewayResourse.NowSelectGateway.AddNewDeviceToGateway(255); + this.realGateway.AddNewDeviceToGateway(180); System.Threading.Thread.Sleep(1000); } }); //娣诲姞鐩戣璁惧鏂颁笂鎶ョ殑浜嬩欢 - GatewayResourse.NowSelectGateway.GwResDataAction += this.AdjustGatewayResultData; + this.realGateway.GwResDataAction += this.AdjustGatewayResultData; + //寮�鍚繛鎺ョ殑鍋囨兂鍔ㄧ敾鏁堟灉绾跨▼ + this.StartConcetionAnimeteThread(); } #endregion @@ -169,7 +175,7 @@ if (result == -1) { //鍋滄鎺ユ敹 - GatewayResourse.NowSelectGateway.GwResDataAction -= this.AdjustGatewayResultData; + this.realGateway.GwResDataAction -= this.AdjustGatewayResultData; Application.RunOnMainThread(() => { @@ -184,8 +190,6 @@ this.StartTopicTimeOutThread(); return; } - //涓柇涓婚瓒呮椂绾跨▼ - this.topTimeOut = -100; lock (this.dicNewDevice) { @@ -206,7 +210,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); @@ -220,19 +224,16 @@ } //鍒锋柊瓒呮椂鏃堕棿 - this.waitDeviceTimeOut = 3; + this.waitDeviceTimeOut = 20; //鑾峰彇璁惧鐨勫浐瀹氬睘鎬� HdlDeviceFixedAttributeLogic.Current.SetAllFixedAttributeToDevice(device); - if ((device is OTADevice) == false) - { - //涓嶉渶瑕�200绔偣鐨勯偅涓澶� - this.dicNewDevice[device.DeviceAddr].Add(device); + //涓嶉渶瑕�200绔偣鐨勯偅涓澶� 2020.01.13 鍙樻洿:ota涔熷姞杩涙潵 + this.dicNewDevice[device.DeviceAddr].Add(device); - //鏈夋柊璁惧锛屽紑鍚樉绀鸿澶囦俊鎭晫闈㈢殑绾跨▼(閲岄潰浼氱瓑寰呬笁绉掕繖鏍�) - this.StartShowDeviceAddSuccessFormThread(); - } + //鏈夋柊璁惧锛屽紑鍚樉绀鸿澶囦俊鎭晫闈㈢殑绾跨▼(閲岄潰浼氱瓑寰呬笁绉掕繖鏍�) + this.StartShowDeviceAddSuccessFormThread(); } } @@ -257,12 +258,12 @@ while (this.waitDeviceTimeOut >= 0) { //绛夊緟涓嬩竴涓洖璺� - System.Threading.Thread.Sleep(1000); + System.Threading.Thread.Sleep(100); this.waitDeviceTimeOut--; } //鍋滄鎺ユ敹 - GatewayResourse.NowSelectGateway.GwResDataAction -= this.AdjustGatewayResultData; - System.Threading.Thread.Sleep(500); + this.realGateway.GwResDataAction -= this.AdjustGatewayResultData; + System.Threading.Thread.Sleep(200); //鐩墠灏卞紕涓�涓� Application.RunOnMainThread(() => @@ -272,6 +273,10 @@ //閲嶆柊鍙樻洿UI foreach (var device in listDevice) { + if (device is OTADevice) + { + continue; + } device.IconPath = string.Empty; device.ReSave(); } @@ -334,9 +339,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) @@ -414,8 +427,8 @@ if (info.Result != 0) { //鍑虹幇鏈煡閿欒,璇烽噸鏂板叆缃� - this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndReAccessNetwork)); - //HdlLogLogic.Current.WriteLog(-1, resultData); + //this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndReAccessNetwork)); + HdlLogLogic.Current.WriteLog(-1, resultData); return 2; } this.topTimeOut = topMaxTime; @@ -442,6 +455,7 @@ } else if (topic == gatewayId + "/DeviceInComingRespon") { + this.topTimeOut = topMaxTime; //缃戝叧鏈�缁堜笂鎶ヨ妭鐐硅澶囦俊鎭� this.SetDeviceProgressValue(6); return 1; @@ -492,7 +506,7 @@ System.Threading.Thread.Sleep(1000); this.topTimeOut--; } - if (this.topTimeOut < 0 && this.topTimeOut >= -10) + if (this.topTimeOut < 0) { //鍝嶅簲瓒呮椂,璇烽噸鏂板叆缃� this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uResponseTimeoutsAndReAccessNetwork)); @@ -511,19 +525,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