提交 | 用户 | 时间
|
149dd0
|
1 |
package com.iailab.netsdk.lib.enumeration; |
H |
2 |
|
|
3 |
/** |
|
4 |
* @author 251823 |
|
5 |
* @description 继电器状态 |
|
6 |
* @date 2020/12/14 |
|
7 |
*/ |
|
8 |
public enum EM_RELAY_STATE_TYPE { |
|
9 |
// 未知 |
|
10 |
EM_RELAY_STATE_TYPE_UNKNOWN(-1, "未知"), |
|
11 |
// 关 |
|
12 |
EM_RELAY_STATE_TYPE_CLOSE(0, "关"), |
|
13 |
// 开 |
|
14 |
EM_RELAY_STATE_TYPE_OPEN(1, "开"), |
|
15 |
// 不支持 |
|
16 |
EM_RELAY_STATE_TYPE_NO_SUPPORT(255, "不支持"); |
|
17 |
|
|
18 |
private int value; |
|
19 |
private String note; |
|
20 |
|
|
21 |
private EM_RELAY_STATE_TYPE(int givenValue, String note) { |
|
22 |
this.value = givenValue; |
|
23 |
this.note = note; |
|
24 |
} |
|
25 |
|
|
26 |
public String getNote() { |
|
27 |
return note; |
|
28 |
} |
|
29 |
|
|
30 |
public int getValue() { |
|
31 |
return value; |
|
32 |
} |
|
33 |
|
|
34 |
public static String getNoteByValue(int givenValue) { |
|
35 |
for (EM_RELAY_STATE_TYPE enumType : EM_RELAY_STATE_TYPE.values()) { |
|
36 |
if (givenValue == enumType.getValue()) { |
|
37 |
return enumType.getNote(); |
|
38 |
} |
|
39 |
} |
|
40 |
return null; |
|
41 |
} |
|
42 |
|
|
43 |
public static int getValueByNote(String givenNote) { |
|
44 |
for (EM_RELAY_STATE_TYPE enumType : EM_RELAY_STATE_TYPE.values()) { |
|
45 |
if (givenNote.equals(enumType.getNote())) { |
|
46 |
return enumType.getValue(); |
|
47 |
} |
|
48 |
} |
|
49 |
return -2; |
|
50 |
} |
|
51 |
|
|
52 |
} |