package org.well.well.AlarmEnumDTO;

/**
 * Created by admin on 2017/4/6.
 */
public enum WellAlarmEnum {
    NO_DATA("设备异常", -1),
    NORMAL("心跳", 0),
    WellOpenAlarm("井盖开盖报警", 1),
    WellLowBatteryAlarm("井盖低电量报警", 2),
    WellDeviceBadAlarm("井盖设备故障", 3);
//    WellLDataAlarm("井盖数据异常", 4);

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

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

    public int getIndex() {
        return index;
    }

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

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

    public String getName() {
        return name;
    }
}
