package com.jsowell.common.enums.ykc;

/**
 * 启动充电失败原因
 *
 * @author JS-ZZA
 * @date 2022/11/16 14:32
 */
public enum ChargingFailedReasonEnum {
    NULL(0x00, "无"),
    EQUIPMENT_PILE_SN_NOT_MATCH(0x01, "设备桩号不匹配"),
    CONNECTOR_IS_CHARGING(0x02, "枪已在充电"),
    EQUIPMENT_BREAKDOWN(0x03, "设备故障"),
    EQUIPMENT_OFFLINE(0x04, "设备离线"),
    UNPLUGGED_GUN(0x05, "未插枪"),

    ;
    private int code;
    private String msg;

    ChargingFailedReasonEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    /**
     * 根据code获取停止原因描述
     *
     * @param code 编码
     * @return 停止原因描述
     */
    public static String getMsgByCode(int code) {
        for (ChargingFailedReasonEnum item : ChargingFailedReasonEnum.values()) {
            if (item.getCode() == code) {
                return item.getMsg();
            }
        }
        return null;
    }
}
