优化
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package top.wms.admin.common.enums;
|
||||
|
||||
|
||||
/**
|
||||
* DPA6024V-2T-1.0 数字控制器命令类型枚举
|
||||
* 定义控制器支持的指令字
|
||||
*/
|
||||
public enum CommandTypeEnum {
|
||||
|
||||
/**
|
||||
* 打开对应通道 (指令字: 1)
|
||||
*/
|
||||
ON('1'),
|
||||
|
||||
/**
|
||||
* 关闭对应通道 (指令字: 2)
|
||||
*/
|
||||
OFF('2'),
|
||||
|
||||
/**
|
||||
* 设置对应通道亮度参数 (指令字: 3)
|
||||
*/
|
||||
SET_BRIGHTNESS('3'),
|
||||
|
||||
/**
|
||||
* 读出对应通道亮度参数 (指令字: 4)
|
||||
*/
|
||||
READ('4');
|
||||
|
||||
private final char commandCode;
|
||||
|
||||
CommandTypeEnum(char commandCode) {
|
||||
this.commandCode = commandCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指令字字符
|
||||
* @return 指令字 (如 '1', '2', '3', '4')
|
||||
*/
|
||||
public char getCommandCode() {
|
||||
return commandCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据指令字获取对应的命令类型
|
||||
* @param commandCode 指令字字符
|
||||
* @return 对应的CommandType,找不到返回null
|
||||
*/
|
||||
public static CommandTypeEnum fromCommandCode(char commandCode) {
|
||||
for (CommandTypeEnum type : values()) {
|
||||
if (type.commandCode == commandCode) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(commandCode);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user