mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
update 电单车协议
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package com.jsowell.common.enums.ebike;
|
||||
|
||||
public enum EBikeChargeCommandResponse {
|
||||
SUCCESS(0, "执行成功(启动或停止充电)"),
|
||||
|
||||
NO_CHARGER_PLUGGED(1, "端口未插充电器(不执行)"),
|
||||
|
||||
SAME_PORT_STATE(2, "端口状态和充电命令相同(不执行)"),
|
||||
|
||||
PORT_FAULT(3, "端口故障(执行)"),
|
||||
|
||||
INVALID_PORT_NUMBER(4, "无此端口号(不执行)"),
|
||||
|
||||
// 响应FF充电命令,不执行,只针对双路,双路设备的二维码只有一个,且端口号为FF,当2个口都插了充电器,服务器下发充电端口为FF时,设备检测到有2个口待充电,不知道充哪个,就会返回此应答
|
||||
MULTIPLE_PENDING_PORTS(5, "有多个待充端口"),
|
||||
|
||||
POWER_EXCEEDED(6, "多路设备功率超标(不执行)");
|
||||
|
||||
private final int code;
|
||||
private final String description;
|
||||
|
||||
EBikeChargeCommandResponse(int code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public static EBikeChargeCommandResponse fromCode(int code) {
|
||||
for (EBikeChargeCommandResponse response : values()) {
|
||||
if (response.getCode() == code) {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid code: " + code);
|
||||
}
|
||||
|
||||
public static String getDescriptionByCode(int code) {
|
||||
try {
|
||||
EBikeChargeCommandResponse response = fromCode(code);
|
||||
return response.getDescription();
|
||||
} catch (IllegalArgumentException e) {
|
||||
return "未知应答码: " + code;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user