package com.yupi.project.model.enums;

import lombok.Getter;

/**
 * 机器人指令任务的命令类型枚举
 */
@Getter
public enum CommandTypeEnum {
    MOVE_TO_SPOT("MOVE_TO_SPOT", "移动到指定点"),
    START_CHARGE("START_CHARGE", "开始充电"),
    STOP_CHARGE("STOP_CHARGE", "停止充电"),
    QUERY_STATUS("QUERY_STATUS", "查询状态");

    private final String value;
    private final String ackValue;

    CommandTypeEnum(String value, String ackValue) {
        this.value = value;
        this.ackValue = ackValue;
    }

    public String getValue() {
        return value;
    }

    public String getAckValue() {
        return ackValue;
    }
    
    /**
     * 根据 value 获取枚举
     *
     * @param value
     * @return
     */
    public static CommandTypeEnum getEnumByValue(String value) {
        if (value == null) {
            return null;
        }
        for (CommandTypeEnum anEnum : CommandTypeEnum.values()) {
            if (anEnum.value.equals(value)) {
                return anEnum;
            }
        }
        return null;
    }


    /**
     * 根据ackValue获取枚举
     *
     * @param ackValue
     * @return
     */
    public static CommandTypeEnum fromAck(String ackValue) {
        if (ackValue == null) {
            return null;
        }
        for (CommandTypeEnum anEnum : CommandTypeEnum.values()) {
            if (ackValue.equalsIgnoreCase(anEnum.getAckValue())) {
                return anEnum;
            }
        }
        return null;
    }
}