package com.emato.ich.contant;

import android.util.ArrayMap;

import com.emato.ich.utils.StringUtils;

import java.util.Map;

public class OpenLockerResponseConstant {

    public static final String SUCCESS = "0";
    public static final String FAILED = "1";
    public static final String TIMEOUT = "1701";
    public static final String OCCUPY = "1702";
    public static final String SEND_DATA_ERROR = "1703";
    public static final String DATA_VALIDATE_FAILED = "1704";
    public static final String LOCK_STATUS_ERROR = "1705";
    public static final String NO_SUPPORTED_OPERATION = "1801";

    public static final Map<String, String> causeMap = new ArrayMap<>();

    static {
        causeMap.put(SUCCESS, "操作成功");
        causeMap.put(FAILED, "操作失败");
        causeMap.put(TIMEOUT, "串口通讯超时");
        causeMap.put(OCCUPY, "串口占用");
        causeMap.put(SEND_DATA_ERROR, "串口发送数据错误");
        causeMap.put(DATA_VALIDATE_FAILED, "串口数据校验失败");
        causeMap.put(LOCK_STATUS_ERROR, "开门时返回锁状态错误");
        causeMap.put(NO_SUPPORTED_OPERATION, "不支持该操作");
    }

    public static String getResponseInfo(String code){
        String cause = causeMap.get(code);

        if (StringUtils.isNullOrEmpty(cause)) {
            cause = "开锁未知异常";
        }

        return cause;
    }
}
