package com.emato.ich.contant;

public enum OpenLockerResponseEnum {

    SUCCESS("0", "操作成功"),
    FAILED("1", "操作失败"),
    TIMEOUT("1701", "串口通讯超时"),
    OCCUPY("1702", "串口占用"),
    SEND_DATA_ERROR("1703", "串口发送数据错误"),
    DATA_VALIDATE_FAILED("1704", "串口数据校验失败"),
    LOCK_STATUS_ERROR("1705", "开门时返回锁状态错误"),
    NO_SUPPORTED_OPERATION("1801", "不支持该操作")
    ;

    private String code;

    private String cause;

    OpenLockerResponseEnum(String code, String cause) {
        this.code = code;
        this.cause = cause;
    }

    public String getCode() {
        return code;
    }

    public String getCause() {
        return cause;
    }


    public static String getResponseInfo(String code){
        String cause = "开锁未知异常";
        for (OpenLockerResponseEnum value : OpenLockerResponseEnum.values()) {
            if (code.equals(value.getCode())) {
                cause = value.getCause();
                break;
            }
        }
        return cause;
    }
}
