gxc
2020-02-28 66a9965c44ecc32a6696abca876ab9d1cd091584
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayUpdateLogic.cs
@@ -9,7 +9,7 @@
    /// <summary>
    /// 网关的升级逻辑
    /// </summary>
    public class HdlGatewayUpdateLogic
    public class HdlGatewayUpdateLogic : HdlDeviceUpdateCommonLogic
    {
        #region ■ 变量声明___________________________
@@ -23,7 +23,7 @@
        /// </summary>
        public Action<int, string> UpdateStatuChangedEvent = null;
        /// <summary>
        /// 进度值事件
        /// 进度值事件(已经是百分比的值)
        /// </summary>
        public Action<decimal> ProgressEvent = null;
        /// <summary>
@@ -38,14 +38,6 @@
        /// 网关新版本的固件信息
        /// </summary>
        public FirmwareVersionInfo gatewayFirmware = null;
        /// <summary>
        /// 当前执行状态(出现错误时,它也会变成true)
        /// </summary>
        public UpdateStatuMode UpdateStatu = UpdateStatuMode.None;
        /// <summary>
        /// 升级是否完成
        /// </summary>
        public bool IsFinishUpdate = true;
        /// <summary>
        /// 前一次的最终状态
@@ -71,6 +63,7 @@
        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;
@@ -90,9 +83,9 @@
            {
                //如果是等待模式,再次点击时,移除列表
                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;
                //取消
@@ -109,7 +102,7 @@
            //进入等待模式
            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));
@@ -120,7 +113,7 @@
        /// <summary>
        /// 开始执行更新操作(FirmwareUpdateLogic调用)
        /// </summary>
        public void DoStartUpdate()
        public override void DoStartUpdate()
        {
            //状态变更
            this.IsFinishUpdate = false;
@@ -412,6 +405,7 @@
            //协调器固件下载中
            this.UpdateStatuChangedEvent(0, Language.StringByID(R.MyInternationalizationString.uCoordinatorFirmwareDownLoading));
            this.SetProgressValue(0, 100);
            //下载协调器文件的进度
            this.upDatezbGateway.ReportAction += this.DownLoadCoordinatorFileProgress;
@@ -462,6 +456,7 @@
            //设置进度
            var responData = tempZb.downloadFileProgressResponData;
            this.SetProgressValue(responData.DownloadPercent, 100);
            //协调器固件下载中
            this.UpdateStatuChangedEvent?.Invoke(0, Language.StringByID(R.MyInternationalizationString.uCoordinatorFirmwareDownLoading));
@@ -610,6 +605,7 @@
            //网关固件下载中
            this.UpdateStatuChangedEvent?.Invoke(0, Language.StringByID(R.MyInternationalizationString.uGatewayFirmwareDownLoading));
            this.SetProgressValue(0, 100);
            //下载网关文件的进度
            this.upDatezbGateway.ReportAction += this.DownLoadGatewayFileProgress;
@@ -754,7 +750,10 @@
                //执行下一个升级
                HdlFirmwareUpdateLogic.DoUpdateNextFirmware();
                //网关升级成功!
                this.UpdateStatuChangedEvent?.Invoke(1, "");
                this.SetProgressValue(100, 100);
                System.Threading.Thread.Sleep(1500);
                this.UpdateStatuChangedEvent?.Invoke(1, Language.StringByID(R.MyInternationalizationString.uGatewayUpdateSuccess));
            });
        }
@@ -807,7 +806,7 @@
                return;
            }
            decimal result = value / maxValue;
            this.ProgressEvent?.Invoke(value);
            this.ProgressEvent?.Invoke(result);
        }
        /// <summary>
@@ -980,10 +979,6 @@
        {
            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++)
@@ -1023,7 +1018,7 @@
        /// <summary>
        /// 释放缓存
        /// </summary>
        public void Dispose()
        public override void Dispose()
        {
            this.ProgressEvent = null;
            this.UpdateStatuChangedEvent = null;