package org.springblade.enums;

public enum WarnKindEnum {

	/**
	 * 测站离线
	 */
	WARN_SITE_OFFLINE(1, "离线"),
	/**
	 * 上报延时
	 */
	WARN_UP_DELAY(2, "上报延时"),
	/**
	 * 水位仪表故障
	 */
	WARN_WATER_LEVEL_SENSOR_FAILURE(3, "水位仪表故障"),
	/**
	 * 交流电故障
	 */
	WARN_AC_CHARGE_FAILURE(4, "交流电故障"),
	/**
	 * 电池电压故障
	 */
	WARN_BV_FAILURE(5, "电池电压故障"),
	/**
	 * RTU时钟故障
	 */
	WARN_CLOCK_ERROR(6, "RTU时钟故障"),
	/**
	 * 数据采集故障
	 */
	WARN_SENSOR_COLLECT_FAILURE(7, "数据采集故障"),
	/**
	 * SD卡损坏
	 */
	WARN_SD_DAMAGE(8, "SD卡损坏"),
	/**
	 * RTU上报堵塞
	 */
	WARN_DATAGRAM_UP_FAIL(9, "RTU上报堵塞"),
	/**
	 * 太阳能充电电压
	 */
	WARN_SUN_POWER_BV_FAILURE(10, "太阳能充电电压");

	private int code;

	private String name;

	private WarnKindEnum(int code, String name) {
		this.code = code;
		this.name = name;
	}

	/**
	 * Function:根据code来获取对应的name
	 * Author: Admin
	 * Date:2021/6/26
	 *
	 * @param code
	 * @return java.lang.String
	 * @throws Exception
	 */
	public static String getName(int code) {
		for (WarnKindEnum type : WarnKindEnum.values()) {
			if (type.code == code) {
				return type.name;
			}
		}
		return "";
	}

	/**
	 * Function:根据code来获取对应的枚举常量
	 * Author: Admin
	 * Date:2021/6/26
	 *
	 * @param code
	 * @return com.zhgzjg.web.enums.DeleteFlag
	 * @throws Exception
	 */
	public static WarnKindEnum getEnumByCode(int code) {
		for (WarnKindEnum type : WarnKindEnum.values()) {
			if (type.code == code) {
				return type;
			}
		}
		return null;
	}


	/**
	 * Function:根据name来获取对应的枚举常量
	 * Author: Admin
	 * Date:2021/6/26
	 *
	 * @param name
	 * @return com.zhgzjg.web.enums.DeleteFlag
	 * @throws Exception
	 */
	public static WarnKindEnum getEnumByName(String name) {
		for (WarnKindEnum type : WarnKindEnum.values()) {
			if (type.name.equals(name)) {
				return type;
			}
		}
		return null;
	}


	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}
