using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GatewayTool.Models
{
    /// <summary>
    /// 固件升级信息类
    /// </summary>
    public class UpgradeInfo
    {
        /// <summary>
        /// 固件文件路径
        /// </summary>
        public string FirmwareFilePath { get; set; } = string.Empty;

        /// <summary>
        /// 固件文件总字节数据
        /// </summary>
        public byte[] TotalData { get; set; }

        private int _SeperatePackNum = 0;
        /// <summary>
        /// 当前分包计数
        /// </summary>
        public int SeperatePackNum
        {
            get => _SeperatePackNum;
            set => _SeperatePackNum = value;
        }

        private int _TotalPackNum = 0;
        /// <summary>
        /// 总分包数
        /// </summary>
        public int TotalPackNum
        {
            get => _TotalPackNum;
            set => _TotalPackNum = value;
        }

        /// <summary>
        /// 固件升级进度（%）
        /// </summary>
        public int UpgradeProgress
        {
            get
            {
                if (_TotalPackNum == 0 || _SeperatePackNum == 0) return 0;
                return (int)(Math.Round(((decimal)_SeperatePackNum / _TotalPackNum), 2) * 100);
            }
        }
    }
}