From da9285368099529de4f6aa92be55297d05dc63dc Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 29 五月 2020 09:45:11 +0800
Subject: [PATCH] 2020-05-29-1
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceUpdateLogic.cs | 76 ++++++++++++++++---------------------
1 files changed, 33 insertions(+), 43 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceUpdateLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceUpdateLogic.cs
index e07eeb3..bfb0ab6 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceUpdateLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceUpdateLogic.cs
@@ -8,7 +8,7 @@
/// <summary>
/// HDL璁惧鍗囩骇鐨勯�昏緫
/// </summary>
- public class HdlDeviceUpdateLogic
+ public class HdlDeviceUpdateLogic : HdlDeviceUpdateCommonLogic
{
#region 鈻� 鍙橀噺澹版槑___________________________
@@ -19,6 +19,7 @@
/// <para> 0:鏇存柊鐘舵�佹甯稿彉鍖�,鍚庨潰鐨勫�间负鐘舵�佸彉鏇寸殑鏂囨湰缈昏瘧</para>
/// <para> 1:鍗囩骇鎴愬姛</para>
/// <para> 2:涓诲姩缁堟鍗囩骇</para>
+ /// <para> 3:浠庣瓑寰呬腑鍙栨秷(鐩墠杩樻病鏈夌敤)</para>
/// </summary>
public Action<int, string> UpdateStatuChangedEvent = null;
/// <summary>
@@ -26,17 +27,10 @@
/// </summary>
public Action<decimal> ProgressEvent = null;
/// <summary>
- /// 褰撳墠鎵ц鐨勭姸鎬�
- /// </summary>
- public UpdateStatuMode UpdateStatu = UpdateStatuMode.None;
- /// <summary>
/// 璁惧鏂扮増鏈殑鍥轰欢淇℃伅(澶氫釜璁惧鍗囩骇鏃�,搴旇浼氶渶瑕佸叕寮�杩欎釜瀵硅薄)
/// </summary>
public FirmwareVersionInfo deviceFirmware = null;
- /// <summary>
- /// 鍗囩骇鏄惁瀹屾垚(鍑虹幇閿欒鏃�,瀹冧篃浼氬彉鎴恡rue)
- /// </summary>
- public bool IsFinishUpdate = true;
+
/// <summary>
/// 缃戝叧
/// </summary>
@@ -64,6 +58,7 @@
/// <param name="i_deviceFirmware">璁惧鐨勫浐浠朵俊鎭�</param>
public HdlDeviceUpdateLogic(OTADevice i_otaDevice, FirmwareVersionInfo i_deviceFirmware)
{
+ this.ClassDiv = 2;
this.otaDevice = i_otaDevice;
this.deviceFirmware = i_deviceFirmware;
this.zbGateway = i_otaDevice.Gateway;
@@ -88,11 +83,13 @@
if (this.UpdateStatu == UpdateStatuMode.Wait)
{
//濡傛灉鏄瓑寰呮ā寮忥紝鍐嶆鐐瑰嚮鏃讹紝绉婚櫎鍒楄〃
- if (FirmwareUpdateResourse.dicDeviceUpdateList.ContainsKey(otaDevice.DeviceAddr) == true)
+ if (FirmwareUpdateResourse.dicUpdateList.ContainsKey(otaDevice.DeviceAddr) == true)
{
- FirmwareUpdateResourse.dicDeviceUpdateList.Remove(otaDevice.DeviceAddr);
+ FirmwareUpdateResourse.dicUpdateList.Remove(otaDevice.DeviceAddr);
}
+ //鍙栨秷
this.UpdateStatu = UpdateStatuMode.None;
+ this.UpdateStatuChangedEvent?.Invoke(3, "");
return;
}
//濡傛灉瀹冩湁鐘舵�侊紝鍒欒〃绀轰箣鍓嶅畠琚粈涔堥敊璇腑鏂簡
@@ -104,7 +101,7 @@
//杩涘叆绛夊緟妯″紡
this.UpdateStatu = UpdateStatuMode.Wait;
- FirmwareUpdateResourse.dicDeviceUpdateList[otaDevice.DeviceAddr] = this;
+ FirmwareUpdateResourse.dicUpdateList[otaDevice.DeviceAddr] = this;
//绛夊緟涓��
this.UpdateStatuChangedEvent?.Invoke(0, Language.StringByID(R.MyInternationalizationString.uWaitting));
@@ -114,9 +111,9 @@
}
/// <summary>
- /// 寮�濮嬫墽琛屾洿鏂版搷浣�
+ /// 寮�濮嬫墽琛屾洿鏂版搷浣�(FirmwareUpdateLogic璋冪敤)
/// </summary>
- public void DoStartUpdate()
+ public override void DoStartUpdate()
{
//鐘舵�佸彉鏇�
this.IsFinishUpdate = false;
@@ -207,7 +204,7 @@
return;
}
var tempZb = (ZbGateway)objValue;
- if (tempZb.CurrentGateWayId != HdlGatewayLogic.Current.GetGatewayId(this.zbGateway))
+ if (HdlGatewayLogic.Current.GetGatewayId(tempZb) != HdlGatewayLogic.Current.GetGatewayId(this.zbGateway))
{
//涓嶆槸鑷繁鐨勭綉鍏虫帹閫侊紝鍒欎笉澶勭悊
return;
@@ -366,7 +363,7 @@
return;
}
var tempZb = (ZbGateway)objValue;
- if (tempZb.CurrentGateWayId != HdlGatewayLogic.Current.GetGatewayId(this.zbGateway))
+ if (HdlGatewayLogic.Current.GetGatewayId(tempZb) != HdlGatewayLogic.Current.GetGatewayId(this.zbGateway))
{
//涓嶆槸鑷繁鐨勭綉鍏虫帹閫侊紝鍒欎笉澶勭悊
return;
@@ -382,12 +379,11 @@
{
this.zbGateway.ReportAction -= this.UpdateDeviceProgress;
- new System.Threading.Thread(async () =>
+ HdlThreadLogic.Current.RunThread(async () =>
{
//缁堟鍗囩骇
await this.otaDevice.KillUpdateAsync(this.zbGateway, 200);
- })
- { IsBackground = true }.Start();
+ });
this.UpdateStatu = UpdateStatuMode.DeviceUpdateFail;
return;
@@ -416,7 +412,7 @@
/// </summary>
/// <param name="statusData"></param>
/// <returns></returns>
- private bool CheckStatusCode(ZbGatewayData.OTAScheduleResponData statusData)
+ private bool CheckStatusCode(CommonDevice.OTAScheduleResponData statusData)
{
if (statusData == null)
{
@@ -503,7 +499,7 @@
this.UpdateStatuChangedEvent?.Invoke(0, Language.StringByID(R.MyInternationalizationString.uDeviceUpdating));
this.SetProgressValue(0);
- FirmwareUpdateResourse.dicDeviceUpdateList[otaDevice.DeviceAddr] = this;
+ FirmwareUpdateResourse.dicUpdateList[otaDevice.DeviceAddr] = this;
//鍚屾杩涘害
this.zbGateway.ReportAction += UpdateDeviceProgress;
}
@@ -556,7 +552,7 @@
//鍗囩骇鎴愬姛
this.UpdateStatu = UpdateStatuMode.UpdateSuccess;
- new System.Threading.Thread(() =>
+ HdlThreadLogic.Current.RunThread(() =>
{
System.Threading.Thread.Sleep(3000);
@@ -578,22 +574,18 @@
//绉婚櫎浜嬩欢
HdlDeviceImageInfoLogic.Current.RemoveDeviceFirmwareVersionThread(otaDevice);
- Application.RunOnMainThread(() =>
- {
- //璁剧疆杩涘害鍊肩洿鎺ヤ负100%
- this.ProgressEvent?.Invoke(100);
- //鐘舵�佸彉鏇�
- this.IsFinishUpdate = true;
- //鍗囩骇瀹屾垚
- this.UpdateStatu = UpdateStatuMode.UpdateFinish;
+ //璁剧疆杩涘害鍊肩洿鎺ヤ负100%
+ this.ProgressEvent?.Invoke(100);
+ //鐘舵�佸彉鏇�
+ this.IsFinishUpdate = true;
+ //鍗囩骇瀹屾垚
+ this.UpdateStatu = UpdateStatuMode.UpdateFinish;
- HdlFirmwareUpdateLogic.DoUpdateNextFirmware();
+ HdlFirmwareUpdateLogic.DoUpdateNextFirmware();
- //璁惧鍗囩骇鎴愬姛!
- this.UpdateStatuChangedEvent?.Invoke(1, Language.StringByID(R.MyInternationalizationString.uDeviceUpdateSuccess));
- });
- })
- { IsBackground = true }.Start();
+ //璁惧鍗囩骇鎴愬姛!
+ this.UpdateStatuChangedEvent?.Invoke(1, Language.StringByID(R.MyInternationalizationString.uDeviceUpdateSuccess));
+ });
}
#endregion
@@ -636,7 +628,7 @@
private void StartDownLoadTimeOutThread()
{
this.downLoadTimeOutCount = 30;
- new System.Threading.Thread(() =>
+ HdlThreadLogic.Current.RunThread(() =>
{
while (true)
{
@@ -665,8 +657,7 @@
break;
}
}
- })
- { IsBackground = true }.Start();
+ });
}
/// <summary>
@@ -691,7 +682,7 @@
private void StartUpdateTimeOutThread()
{
this.UpdateTimeOutCount = 60;
- new System.Threading.Thread(() =>
+ HdlThreadLogic.Current.RunThread(() =>
{
while (true)
{
@@ -719,8 +710,7 @@
break;
}
}
- })
- { IsBackground = true }.Start();
+ });
}
/// <summary>
@@ -738,7 +728,7 @@
/// <summary>
/// 閲婃斁缂撳瓨
/// </summary>
- public void Dispose()
+ public override void Dispose()
{
this.ProgressEvent = null;
this.UpdateStatuChangedEvent = null;
--
Gitblit v1.8.0