From e79b65b97a8ae1eae5ee172dea1b52d041006599 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期三, 02 九月 2020 17:24:32 +0800
Subject: [PATCH] 2020-09-02-3
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceUpdateLogic.cs | 76 +++++++++++++++++++------------------
1 files changed, 39 insertions(+), 37 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceUpdateLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceUpdateLogic.cs
index 30dc880..a76bb38 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 鈻� 鍙橀噺澹版槑___________________________
@@ -27,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>
@@ -65,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;
@@ -89,9 +83,9 @@
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;
@@ -107,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));
@@ -117,9 +111,9 @@
}
/// <summary>
- /// 寮�濮嬫墽琛屾洿鏂版搷浣�
+ /// 寮�濮嬫墽琛屾洿鏂版搷浣�(FirmwareUpdateLogic璋冪敤)
/// </summary>
- public void DoStartUpdate()
+ public override void DoStartUpdate()
{
//鐘舵�佸彉鏇�
this.IsFinishUpdate = false;
@@ -210,7 +204,7 @@
return;
}
var tempZb = (ZbGateway)objValue;
- if (tempZb.CurrentGateWayId != HdlGatewayLogic.Current.GetGatewayId(this.zbGateway))
+ if (tempZb.GwId != this.zbGateway.GwId)
{
//涓嶆槸鑷繁鐨勭綉鍏虫帹閫侊紝鍒欎笉澶勭悊
return;
@@ -369,7 +363,7 @@
return;
}
var tempZb = (ZbGateway)objValue;
- if (tempZb.CurrentGateWayId != HdlGatewayLogic.Current.GetGatewayId(this.zbGateway))
+ if (tempZb.GwId != this.zbGateway.GwId)
{
//涓嶆槸鑷繁鐨勭綉鍏虫帹閫侊紝鍒欎笉澶勭悊
return;
@@ -418,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)
{
@@ -505,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;
}
@@ -562,11 +556,22 @@
{
System.Threading.Thread.Sleep(3000);
- //閲嶆柊鍒锋柊缂撳瓨
- HdlDeviceImageInfoLogic.Current.SetAllImageInfoToOtaDevice(otaDevice, (device, reportData) =>
- {
- this.IsFinishUpdate = true;
- });
+ string checkKey = Common.LocalDevice.Current.GetDeviceMainKeys(otaDevice.DeviceAddr, otaDevice.DeviceEpoint);
+ HdlGatewayReceiveLogic.Current.AddAttributeEvent("HdlDeviceUpdate" + otaDevice.DeviceAddr, ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) =>
+ {
+ if (report.DeviceStatusReport.CluterID == (int)Cluster_ID.Ota)
+ {
+ string mainKey = Common.LocalDevice.Current.GetDeviceMainKeys(report.DeviceAddr, report.DeviceEpoint);
+ if (checkKey == mainKey)
+ {
+ //宸茬粡鎺ユ敹寰楀埌
+ this.IsFinishUpdate = true;
+ }
+ }
+ });
+
+ //鍙戦�佸懡浠�
+ HdlDeviceImageInfoLogic.Current.SetFirmwareVersionComand(otaDevice);
System.Threading.Thread.Sleep(1500);
int count = 12;
@@ -578,22 +583,19 @@
count--;
}
//绉婚櫎浜嬩欢
- HdlDeviceImageInfoLogic.Current.RemoveDeviceFirmwareVersionThread(otaDevice);
+ HdlGatewayReceiveLogic.Current.RemoveEvent("HdlDeviceUpdate");
- 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));
- });
+ //璁惧鍗囩骇鎴愬姛!
+ this.UpdateStatuChangedEvent?.Invoke(1, Language.StringByID(R.MyInternationalizationString.uDeviceUpdateSuccess));
});
}
@@ -737,7 +739,7 @@
/// <summary>
/// 閲婃斁缂撳瓨
/// </summary>
- public void Dispose()
+ public override void Dispose()
{
this.ProgressEvent = null;
this.UpdateStatuChangedEvent = null;
--
Gitblit v1.8.0