package com.pwt.common.enums;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author linyun
 * @version V1.0
 * @Title: ChargerFault
 * @Description: 充电机故障枚举
 * @date 2022/11/22
 **/
public enum ChargerFault {

    FAULT_3001(3001, "CC1故障"),
    FAULT_3002(3002, "BMS故障"),
    FAULT_3003(3003, "BMS错误"),
    FAULT_3004(3004, "单体电压过高"),
    FAULT_3005(3005, "单体温度过高"),
    FAULT_3006(3006, "输入过压"),
    FAULT_3007(3007, "输入欠压"),
    FAULT_3008(3008, "输入短路"),
    FAULT_3009(3009, "充电机内部故障"),
    FAULT_3010(3010, "输出过压"),
    FAULT_3011(3011, "直流输出断路"),
    FAULT_3012(3012, "系统故障"),
    FAULT_3013(3013, "充电机系统故障"),
    FAULT_3014(3014, "模块故障"),
    FAULT_3015(3015, "电池故障"),
    FAULT_3016(3016, "绝缘不通过"),
    FAULT_3017(3017, "绝缘条件不满足"),
    FAULT_3018(3018, "触摸屏故障"),
    FAULT_3019(3019, "读卡器故障"),
    FAULT_3020(3020, "急停故障"),
    FAULT_3021(3021, "充电桩电表故障"),
    FAULT_3022(3022, "绝缘检测故障"),
    FAULT_3023(3023, "整流模块故障"),
    FAULT_3024(3024, "网络模块故障"),
    FAULT_3025(3025, "单体动力蓄电池电压过高、过低"),
    FAULT_3026(3026, "高压继电器故障"),
    FAULT_3027(3027, "接收BRM超时"),
    FAULT_3028(3028, "接收BCP超时"),
    FAULT_3029(3029, "接收BRO超时"),
    FAULT_3030(3030, "接收BCS超时"),
    FAULT_3031(3031, "接收BCL超时"),
    FAULT_3032(3032, "接收BST超时"),
    FAULT_3033(3033, "接收BSD超时"),
    FAULT_3034(3034, "接收CRM超时"),
    FAULT_3035(3035, "接收CML超时"),
    FAULT_3036(3036, "接收CRO超时"),
    FAULT_3037(3037, "接收CCS超时"),
    FAULT_3039(3039, "接收CST超时"),
    FAULT_3040(3040, "接收CSD超时"),
    FAULT_3041(3041, "接收BSM超时"),
    FAULT_3042(3042, "其他故障");

    private final int faultCode;
    private final String faultMsg;

    public static String getFaultMsgByErrCode(int faultCode)
    {
        Optional<String> optional = Arrays.stream(ChargerFault.values()).filter(f -> f.faultCode == faultCode).map(ChargerFault::getErrMsg).findFirst();
        return optional.orElse(null);
    }

    ChargerFault(int faultCode, String faultMsg)
    {
        this.faultCode = faultCode;
        this.faultMsg = faultMsg;
    }

    public int getErrCode()
    {
        return faultCode;
    }

    public String getErrMsg()
    {
        return faultMsg;
    }

}
