package com.mvc.constant;

/**
 * 升级规范
 */
public enum UpgradeSpecification {
    SMALL_FILE(20, "Small", 10, 3.4),
    MEDIUM_FILE(50, "Medium", 10, 3.55),
    LARGE_FILE(200, "Large", 15, 3.6);

    private final int fileSize; // 升级文件大小（单位：MB）
    private final String description; // 描述
    private final int csq; // 信号CSQ
    private final double voltage; // 电压（单位：V）

    UpgradeSpecification(int fileSize, String description, int csq, double voltage) {
        this.fileSize = fileSize;
        this.description = description;
        this.csq = csq;
        this.voltage = voltage;
    }

    public int getFileSize() {
        return fileSize;
    }

    public String getDescription() {
        return description;
    }

    public int getCsq() {
        return csq;
    }

    public double getVoltage() {
        return voltage;
    }

    /**
     * 获取文件大小获取在大小范围内的升级规范要求
     * @param fileSize
     * @return
     */
    public static UpgradeSpecification getUpgradeSpecification(int fileSize) {
        for (UpgradeSpecification upgradeSpecification : UpgradeSpecification.values()) {
            if (upgradeSpecification.getFileSize() < fileSize) {
                return upgradeSpecification;
            }
        }
        return null;
    }
}
