update 电单车协议

This commit is contained in:
Guoqs
2024-09-05 15:51:51 +08:00
parent f3d4b13895
commit 8c273e5a39
6 changed files with 218 additions and 18 deletions

View File

@@ -0,0 +1,91 @@
package com.jsowell.common.enums.ykc;
import com.jsowell.common.util.BytesUtil;
/**
* 云快充充电停止原因enum
*
* @author JS-ZZA
* @date 2022/11/4 16:46
*/
public enum EBikeChargingStopReasonEnum {
FULL_AUTO_STOP(0x01, "充满自停"),
TIME_AUTO_STOP(0x02, "达到最大充电时间"),
PRESET_TIME_AUTO_STOP(0x03, "达到预设时间"),
PRESET_ELECTRICITY_AUTO_STOP(0x04, "达到预设电量"),
USER_PULL_OUT(0x05, "用户拔出"),
LOAD_TOO_LARGE(0x06, "负载过大"),
SERVER_FORCE_STOP(0x07, "服务器控制停止"),
DYNAMIC_OVERLOAD(0x08, "动态过载"),
POWER_TOO_SMALL(0x09, "功率过小"),
ENVIRONMENT_TEMPERATURE_TOO_HIGH(0x0A, "环境温度过高"),
PORT_TEMPERATURE_TOO_HIGH(0x0B, "端口温度过高"),
OVER_CURRENT(0x0C, "过流"),
USER_PULL_OUT_1(0x0D, "用户拔出-1可能是插座弹片卡住"),
NO_CONTACT(0x0E, "无功率停止,可能是接触不良或保险丝烧断故障"),
RELAY_BAD(0x0F, "预检-继电器坏或保险丝断"),
WATER_INTRUSION(0x10, "水浸断电"),
FIRE_SETTLEMENT_LOCAL_PORT(0x11, "灭火结算(本端口)"),
FIRE_SETTLEMENT_NON_LOCAL_PORT(0x12, "灭火结算(非本端口)"),
USER_PASSWORD_OPEN_DOOR_SHUTDOWN(0x13, "用户密码开柜断电"),
NOT_CLOSE_DOOR(0x14, "未关好柜门"),
USER_OPERATION_STOP(0x15, "外部操作停止"),
SWIPE_OPERATION_STOP(0x16, "刷卡操作停止"),
SERVER_FORCE_STOP_2(0x17, "服务器强制停止(主要用于充电柜强制开柜门)"),
FIRE_SYSTEM_TRIGGER_STOP(0x18, "消防系统触发停止"),
STORAGE_ERROR(0x19, "存储器错误"),
OVER_VOLTAGE(0x1A, "过压"),
UNDER_VOLTAGE(0x1B, "欠压"),
;
private int code;
private String msg;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
EBikeChargingStopReasonEnum(int code, String msg) {
this.code = code;
this.msg = msg;
}
/**
* 根据code获取停止原因描述
*
* @param code 编码
* @return 停止原因描述
*/
public static String getMsgByCode(int code) {
for (EBikeChargingStopReasonEnum item : EBikeChargingStopReasonEnum.values()) {
if (item.getCode() == code) {
return item.getMsg();
}
}
return null;
}
public static void main(String[] args) {
String stopReason = "6B";
byte[] stopReasonByteArr = new byte[]{0x6B};
String s = BytesUtil.bin2HexStr(stopReasonByteArr);
int i = Integer.parseInt(stopReason, 16);
String stopReasonMsg = EBikeChargingStopReasonEnum.getMsgByCode(i);
System.out.println(stopReasonMsg);
}
}