package com.ruoyi.ss.device.domain.enums;

public enum DeviceCommand {

    REBOOT("reboot", "重启设备"),
    OPEN("open", "打开"),
    CLOSE("close", "关闭"),
    RECHARGE("time", "通电时长"),
    REVERSE_RECHARGE("ttme", "断电时长"),
    UPLOAD_DATA("111", "强制上报数据");

    private final String command;
    private final String desc;

    DeviceCommand(String command, String desc) {
        this.command = command;
        this.desc = desc;
    }

    /**
     * 根据命令获取描述
     * @param command 命令
     * @return 描述
     */
    public static String getDescByCommand(String command) {
        for (DeviceCommand value : DeviceCommand.values()) {
            if (value.getCommand().equals(command)) {
                return value.getDesc();
            }
        }
        return "";
    }

    /**
     * 检查命令是否有效
     * @param command 命令
     * @return true-有效，false-无效
     */
    public static boolean isValidCommand(String command) {
        for (DeviceCommand value : DeviceCommand.values()) {
            if (value.getCommand().equals(command)) {
                return true;
            }
        }
        return false;
    }

    public String getCommand() {
        return command;
    }

    public String getDesc() {
        return desc;
    }
}
