package com.pwt.common.enums;

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

/**
 * @author linyun
 * @version V1.0
 * @Title: BatteryFault
 * @Description: 电池故障枚举
 * @date 2022/11/27
 **/
public enum BatteryFault {
    FAULT1("fault1", "电芯温差异常"),
    FAULT2("fault2", "电芯温度过高报警"),
    FAULT3("fault3", "PACK过压报警"),
    FAULT4("fault4", "PACK欠压报警"),
    FAULT5("fault5", "SOC过低报警"),
    FAULT6("fault6", "单体电压过高报警"),
    FAULT7("fault7", "单体电压欠压报警"),
    FAULT8("fault8", "绝缘报警"),
    FAULT9("fault9", "电池一致性差报警"),
    FAULT10("fault10", "车载储能装置过充报警"),
    FAULT11("fault11", "SOC过高报警"),
    FAULT12("fault12", "SOC跳变报警"),
    FAULT13("fault13", "充电储能系统不匹配报警"),
    FAULT14("fault14", "高压互锁报警"),
    FAULT15("fault15", "GBT32960.3中规定的故障数目"),
    FAULT16("fault16", "BMS故障数目"),
    FAULT17("fault17", "电芯过放故障数"),
    FAULT18("fault18", "电芯低温报警"),
    FAULT19("fault19", "放电电流超限"),
    FAULT20("fault20", "回冲电流超限"),
    FAULT21("fault21", "电流传感器"),
    FAULT22("fault22", "低压供电异常"),
    FAULT23("fault23", "热管理机组故障"),
    FAULT24("fault24", "热管理机组故障"),
    FAULT25("fault25", "电池包自保护故障"),
    FAULT26("fault26", "主回路预充(预检)故障"),
    FAULT27("fault27", "辅回路预充(预检)故障"),
    FAULT28("fault28", "绝缘阻值低故障"),
    FAULT29("fault29", "ACAN通讯故障"),
    FAULT30("fault30", "BMS内部通讯故障"),
    FAULT31("fault31", "BMS DC故障"),
    FAULT32("fault32", "支路断路故障"),
    FAULT33("fault33", "加热膜或TMS接触器故障无法闭合报警"),
    FAULT34("fault34", "加热膜或TMS接触器故障无法断开报警"),
    FAULT35("fault35", "主正接触器故障无法闭合报警"),
    FAULT36("fault36", "主正接触器故障无法闭合报警"),
    FAULT37("fault37", "主正接触器故障无法断开报警"),
    FAULT38("fault38", "主正接触器故障无法闭合报警"),
    FAULT39("fault39", "主正接触器故障无法闭合报警"),
    FAULT40("fault40", "直流充电A正接触器无法闭合故障报警"),
    FAULT41("fault41", "直流充电A正接触器无法断开故障报警"),
    FAULT42("fault42", "直流充电A负接触器无法闭合故障报警"),
    FAULT43("fault43", "直流充电A负接触器无法断开故障报警"),
    FAULT44("fault44", "直流充电B正接触器无法闭合故障报警"),
    FAULT45("fault45", "直流充电B正接触器无法断开故障报警"),
    FAULT46("fault46", "直流充电B正接触器无法断开故障报警"),
    FAULT47("fault47", "直流充电B负接触器无法闭合故障报警"),
    FAULT48("fault48", "直流充电B负接触器无法断开故障报警"),
    FAULT49("fault49", "交流充电正接触器无法闭合故障报警"),
    FAULT50("fault50", "交流充电正接触器无法断开故障报警"),
    FAULT51("fault51", "交流充电负接触器无法闭合故障报警"),
    FAULT52("fault52", "交流充电负接触器无法断开故障报警"),
    FAULT53("fault53", "集电弓正接触器无法闭合故障报警"),
    FAULT54("fault54", "集电弓正接触器无法断开故障报警"),
    FAULT55("fault55", "集电弓负接触器无法闭合故障报警"),
    FAULT56("fault56", "集电弓负接触器无法断开故障报警"),
    FAULT57("fault57", "插枪连接信号异常"),
    FAULT58("fault58", "充电时放电电流过大"),
    FAULT59("fault59", "充电电流超限报警"),
    FAULT60("fault60", "充电插座NTC故障"),
    FAULT61("fault61", "充电插座过温报警"),
    FAULT62("fault62", "电子锁故障"),
    FAULT63("fault63", "火警探测器故障"),
    FAULT64("fault64", "持续回充过流故障"),
    FAULT65("fault65", "SOC差异过大"),
    FAULT66("fault66", "持续放电过流故障")
    ;

    private String fieldName;
    private String faultMsg;

    public String getFieldName()
    {
        return fieldName;
    }

    public String getFaultMsg()
    {
        return faultMsg;
    }

    BatteryFault(String fieldName, String faultMsg)
    {
        this.fieldName = fieldName;
        this.faultMsg = faultMsg;
    }

    public static String getFaultMsgByFieldName(String fieldName)
    {
        Optional<String> optional = Arrays.stream(BatteryFault.values()).filter(f -> fieldName.equals(f.getFieldName())).map(BatteryFault::getFaultMsg).findFirst();
        return optional.orElse(null);
    }
}
