update 电单车协议

This commit is contained in:
Guoqs
2024-09-20 08:39:45 +08:00
parent 501e3fc085
commit 9a2af549d8
8 changed files with 123 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
package com.jsowell.common.enums.ebike;
public enum EBikeChargeCommandResponse {
public enum EBikeChargeResponseEnum {
SUCCESS(0, "执行成功(启动或停止充电)"),
NO_CHARGER_PLUGGED(1, "端口未插充电器(不执行)"),
@@ -19,7 +19,7 @@ public enum EBikeChargeCommandResponse {
private final int code;
private final String description;
EBikeChargeCommandResponse(int code, String description) {
EBikeChargeResponseEnum(int code, String description) {
this.code = code;
this.description = description;
}
@@ -32,8 +32,8 @@ public enum EBikeChargeCommandResponse {
return description;
}
public static EBikeChargeCommandResponse fromCode(int code) {
for (EBikeChargeCommandResponse response : values()) {
public static EBikeChargeResponseEnum fromCode(int code) {
for (EBikeChargeResponseEnum response : values()) {
if (response.getCode() == code) {
return response;
}
@@ -43,7 +43,7 @@ public enum EBikeChargeCommandResponse {
public static String getDescriptionByCode(int code) {
try {
EBikeChargeCommandResponse response = fromCode(code);
EBikeChargeResponseEnum response = fromCode(code);
return response.getDescription();
} catch (IllegalArgumentException e) {
return "未知应答码: " + code;

View File

@@ -0,0 +1,68 @@
package com.jsowell.common.enums.ebike;
/**
* 电单车停止原因枚举
*/
public enum EBikeStopReasonEnum {
FULLY_CHARGED(0x01, "充满自停"),
MAX_CHARGE_TIME_REACHED(0x02, "达到最大充电时间"),
PRESET_TIME_REACHED(0x03, "达到预设时间"),
PRESET_POWER_REACHED(0x04, "达到预设电量"),
USER_REMOVED(0x05, "用户拔出"),
OVERLOAD(0x06, "负载过大"),
SERVER_CONTROL_STOPPED(0x07, "服务器控制停止"),
DYNAMIC_OVERLOAD(0x08, "动态过载"),
POWER_TOO_LOW(0x09, "功率过小"),
ENVIRONMENTAL_TEMP_HIGH(0x0A, "环境温度过高 (仅适用于AP262、AP360)"),
PORT_TEMP_HIGH(0x0B, "端口温度过高 (仅适用于AP262)"),
OVERCURRENT(0x0C, "过流"),
USER_REMOVED_1(0x0D, "用户拔出-1可能是插座弹片卡住"),
NO_POWER_STOPPED(0x0E, "无功率停止,可能是接触不良或保险丝烧断故障"),
RELAY_BAD_FUSE_BROKEN(0x0F, "预检-继电器坏或保险丝断"),
WATER_INTRUSION(0x10, "水浸断电"),
FIRE_EXTINGUISHING_SETTLEMENT_LOCAL(0x11, "灭火结算(本端口)"),
FIRE_EXTINGUISHING_SETTLEMENT_REMOTE(0x12, "灭火结算(非本端口)"),
USER_PASSWORD_LOCKOUT(0x13, "用户密码开柜断电"),
DOOR_NOT_CLOSED(0x14, "未关好柜门"),
EXTERNAL_OPERATION_STOPPED(0x15, "外部操作停止"),
CARD_SWIPE_STOPPED(0x16, "刷卡操作停止"),
SERVER_FORCED_STOP(0x17, "服务器强制停止(主要用于充电柜强制开柜门)"),
FIRE_SYSTEM_TRIGGERED(0x18, "消防系统触发停止"),
MEMORY_ERROR(0x19, "存储器错误"),
OVERVOLTAGE(0x1A, "过压"),
UNDERVOLTAGE(0x1B, "欠压");
private final int code;
private final String description;
EBikeStopReasonEnum(int code, String description) {
this.code = code;
this.description = description;
}
public int getCode() {
return code;
}
public String getDescription() {
return description;
}
public static EBikeStopReasonEnum fromCode(int code) {
for (EBikeStopReasonEnum reason : values()) {
if (reason.getCode() == code) {
return reason;
}
}
throw new IllegalArgumentException("Invalid code: " + code);
}
public static String getDescriptionByCode(int code) {
try {
EBikeStopReasonEnum reason = fromCode(code);
return reason.getDescription();
} catch (IllegalArgumentException e) {
return "未知停止原因: " + Integer.toHexString(code);
}
}
}