package org.well.well.AlarmEnumDTO;

/**
 * Created by admin on 2017/4/6.
 */
public enum NoiseAlarmEnum {

    NO_DATA("设备异常", -1),
    NORMAL("正常", 0),
    NoiseFail("噪声探头采集失败", 1),
    NoiseError("噪声探头数据异常", 2),
    NoiseUnknown("噪声未知异常", 3),
    OVER_THRESH("噪声超限", 4);


    // 成员变量
    private String name;
    private int index;

    // 构造方法
    private NoiseAlarmEnum(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public String getName() {
        return name;
    }

    public int getIndex() {
        return index;
    }

    //覆盖方法
    @Override
    public String toString() {
        return this.name;
    }

    public static NoiseAlarmEnum getByIndex(String index) {
        try {
            for (NoiseAlarmEnum temp : values()) {
                if (temp.index == Integer.parseInt(index)) {
                    return temp;
                }
            }
        } catch (Exception e) {
        }
        return null;
    }
}
