| | |
| | | /// <summary>
|
| | | /// 网关的升级逻辑
|
| | | /// </summary>
|
| | | public class HdlGatewayUpdateLogic
|
| | | public class HdlGatewayUpdateLogic : HdlDeviceUpdateCommonLogic
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | |
| | | /// </summary>
|
| | | public Action<int, string> UpdateStatuChangedEvent = null;
|
| | | /// <summary>
|
| | | /// 进度值事件
|
| | | /// 进度值事件(已经是百分比的值)
|
| | | /// </summary>
|
| | | public Action<decimal> ProgressEvent = null;
|
| | | /// <summary>
|
| | |
| | | /// 网关新版本的固件信息
|
| | | /// </summary>
|
| | | public FirmwareVersionInfo gatewayFirmware = null;
|
| | | /// <summary>
|
| | | /// 当前执行状态(出现错误时,它也会变成true)
|
| | | /// </summary>
|
| | | public UpdateStatuMode UpdateStatu = UpdateStatuMode.None;
|
| | | /// <summary>
|
| | | /// 升级是否完成
|
| | | /// </summary>
|
| | | public bool IsFinishUpdate = true;
|
| | |
|
| | | /// <summary>
|
| | | /// 前一次的最终状态
|
| | |
| | | public HdlGatewayUpdateLogic(ZbGateway zbGateway, FirmwareVersionInfo i_virtualFirmware,
|
| | | FirmwareVersionInfo i_coordinatorFirmware, FirmwareVersionInfo i_gatewayFirmware)
|
| | | {
|
| | | this.ClassDiv = 1;
|
| | | this.upDatezbGateway = zbGateway;
|
| | | this.virtualFirmware = i_virtualFirmware;
|
| | | this.coordinatorFirmware = i_coordinatorFirmware;
|
| | |
| | | {
|
| | | //如果是等待模式,再次点击时,移除列表
|
| | | string gwId = HdlGatewayLogic.Current.GetGatewayId(this.upDatezbGateway);
|
| | | if (FirmwareUpdateResourse.dicGatewayUpdateList.ContainsKey(gwId) == true)
|
| | | if (FirmwareUpdateResourse.dicUpdateList.ContainsKey(gwId) == true)
|
| | | {
|
| | | FirmwareUpdateResourse.dicGatewayUpdateList.Remove(gwId);
|
| | | FirmwareUpdateResourse.dicUpdateList.Remove(gwId);
|
| | | }
|
| | | this.UpdateStatu = UpdateStatuMode.None;
|
| | | //取消
|
| | |
| | | //进入等待模式
|
| | | this.UpdateStatu = UpdateStatuMode.Wait;
|
| | | string gwId2 = HdlGatewayLogic.Current.GetGatewayId(this.upDatezbGateway);
|
| | | FirmwareUpdateResourse.dicGatewayUpdateList[gwId2] = this;
|
| | | FirmwareUpdateResourse.dicUpdateList[gwId2] = this;
|
| | | //等待中…
|
| | | this.UpdateStatuChangedEvent?.Invoke(0, Language.StringByID(R.MyInternationalizationString.uWaitting));
|
| | |
|
| | |
| | | /// <summary>
|
| | | /// 开始执行更新操作(FirmwareUpdateLogic调用)
|
| | | /// </summary>
|
| | | public void DoStartUpdate()
|
| | | public override void DoStartUpdate()
|
| | | {
|
| | | //状态变更
|
| | | this.IsFinishUpdate = false;
|
| | |
| | |
|
| | | //协调器固件下载中
|
| | | this.UpdateStatuChangedEvent(0, Language.StringByID(R.MyInternationalizationString.uCoordinatorFirmwareDownLoading));
|
| | | this.SetProgressValue(0, 100);
|
| | |
|
| | | //下载协调器文件的进度
|
| | | this.upDatezbGateway.ReportAction += this.DownLoadCoordinatorFileProgress;
|
| | |
| | |
|
| | | //设置进度
|
| | | var responData = tempZb.downloadFileProgressResponData;
|
| | | this.SetProgressValue(responData.DownloadPercent, 100);
|
| | |
|
| | | //协调器固件下载中
|
| | | this.UpdateStatuChangedEvent?.Invoke(0, Language.StringByID(R.MyInternationalizationString.uCoordinatorFirmwareDownLoading));
|
| | |
| | |
|
| | | //网关固件下载中
|
| | | this.UpdateStatuChangedEvent?.Invoke(0, Language.StringByID(R.MyInternationalizationString.uGatewayFirmwareDownLoading));
|
| | | this.SetProgressValue(0, 100);
|
| | |
|
| | | //下载网关文件的进度
|
| | | this.upDatezbGateway.ReportAction += this.DownLoadGatewayFileProgress;
|
| | |
| | | //执行下一个升级
|
| | | HdlFirmwareUpdateLogic.DoUpdateNextFirmware();
|
| | | //网关升级成功!
|
| | | this.UpdateStatuChangedEvent?.Invoke(1, "");
|
| | | this.SetProgressValue(100, 100);
|
| | | System.Threading.Thread.Sleep(1500);
|
| | |
|
| | | this.UpdateStatuChangedEvent?.Invoke(1, Language.StringByID(R.MyInternationalizationString.uGatewayUpdateSuccess));
|
| | | });
|
| | | }
|
| | |
|
| | |
| | | return;
|
| | | }
|
| | | decimal result = value / maxValue;
|
| | | this.ProgressEvent?.Invoke(value);
|
| | | this.ProgressEvent?.Invoke(result);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | {
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | //当前网关的版本
|
| | | var oldVersion = HdlGatewayLogic.Current.GetGwInfoAttribute(this.upDatezbGateway, "LinuxFWVersion");
|
| | | int oldLinuxVersion = Convert.ToInt32(oldVersion);
|
| | |
|
| | | //先等个120秒吧,网关升级和网关完全重启需要很长时间
|
| | | int count = 12;
|
| | | for (int i = 0; i < count; i++)
|
| | |
| | | /// <summary>
|
| | | /// 释放缓存
|
| | | /// </summary>
|
| | | public void Dispose()
|
| | | public override void Dispose()
|
| | | {
|
| | | this.ProgressEvent = null;
|
| | | this.UpdateStatuChangedEvent = null;
|