mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-13 11:49:49 +08:00
update 电单车
This commit is contained in:
@@ -102,7 +102,7 @@ public class AbsEBikeMessage {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String s = "444e592300198bca00a6158233300000000031300013273881012409031435319214300030002107";
|
String s = "444e593200198bca077c000601010a0000000100000000000000001327388102240913141915803959463300000000750800005e00fe06";
|
||||||
String msg82 = "44 4E 59 26 00 3B 37 AB 04 02 00 82 00 64 01 00 00 01 01 00 00 12 34 56 78 12 34 56 78 12 34 56 78 12 34 56 78 80 70 88 13 F8 08";
|
String msg82 = "44 4E 59 26 00 3B 37 AB 04 02 00 82 00 64 01 00 00 01 01 00 00 12 34 56 78 12 34 56 78 12 34 56 78 12 34 56 78 80 70 88 13 F8 08";
|
||||||
s = s.replace(" ", "");
|
s = s.replace(" ", "");
|
||||||
byte[] messageBytes = BytesUtil.hexStringToByteArray(s);
|
byte[] messageBytes = BytesUtil.hexStringToByteArray(s);
|
||||||
@@ -111,36 +111,25 @@ public class AbsEBikeMessage {
|
|||||||
String header = new String(headerBytes, StandardCharsets.UTF_8);
|
String header = new String(headerBytes, StandardCharsets.UTF_8);
|
||||||
System.out.println("header: " + header);
|
System.out.println("header: " + header);
|
||||||
|
|
||||||
// byte[] header2 = header.getBytes();
|
|
||||||
// System.out.println("反序列header: " + header2);
|
|
||||||
|
|
||||||
// 读取长度
|
// 读取长度
|
||||||
byte[] lengthBytes = Arrays.copyOfRange(messageBytes, 3, 5);
|
byte[] lengthBytes = Arrays.copyOfRange(messageBytes, 3, 5);
|
||||||
int length = BytesUtil.bytesToIntLittle(lengthBytes);
|
int length = BytesUtil.bytesToIntLittle(lengthBytes);
|
||||||
System.out.println("length: " + length);
|
System.out.println("length: " + length);
|
||||||
// byte[] length2 = BytesUtil.intToBytesLittle(length);
|
|
||||||
// System.out.println("反序列length: " + length2);
|
|
||||||
|
|
||||||
// 读取物理ID
|
// 读取物理ID
|
||||||
byte[] physicalIdBytes = Arrays.copyOfRange(messageBytes, 5, 9);
|
byte[] physicalIdBytes = Arrays.copyOfRange(messageBytes, 5, 9);
|
||||||
int physicalId = BytesUtil.bytesToIntLittle(physicalIdBytes);
|
int physicalId = BytesUtil.bytesToIntLittle(physicalIdBytes);
|
||||||
System.out.println("physicalId: " + physicalId);
|
System.out.println("physicalId: " + physicalId);
|
||||||
// byte[] physicalId2 = BytesUtil.intToBytesLittle(physicalId, 4);
|
|
||||||
// System.out.println("反序列physicalId: " + physicalId2);
|
|
||||||
|
|
||||||
// 读取消息ID
|
// 读取消息ID
|
||||||
byte[] messageIdBytes = Arrays.copyOfRange(messageBytes, 9, 11);
|
byte[] messageIdBytes = Arrays.copyOfRange(messageBytes, 9, 11);
|
||||||
int messageId = BytesUtil.bytesToIntLittle(messageIdBytes);
|
int messageId = BytesUtil.bytesToIntLittle(messageIdBytes);
|
||||||
System.out.println("messageId: " + messageId);
|
System.out.println("messageId: " + messageId);
|
||||||
// byte[] messageId2 = BytesUtil.intToBytesLittle(messageId);
|
|
||||||
// System.out.println("反序列messageId: " + messageId2);
|
|
||||||
|
|
||||||
// 读取命令
|
// 读取命令
|
||||||
byte commandByte = messageBytes[11];
|
byte commandByte = messageBytes[11];
|
||||||
String command = BytesUtil.bcd2StrLittle(new byte[]{commandByte});
|
String command = BytesUtil.bcd2StrLittle(new byte[]{commandByte});
|
||||||
System.out.println("command: " + command);
|
System.out.println("command: " + command);
|
||||||
// byte[] command2 = BytesUtil.str2Bcd(command);
|
|
||||||
// System.out.println("反序列command: " + command2);
|
|
||||||
|
|
||||||
// 读取数据
|
// 读取数据
|
||||||
byte[] dataBytes = Arrays.copyOfRange(messageBytes, 12, messageBytes.length - 2);
|
byte[] dataBytes = Arrays.copyOfRange(messageBytes, 12, messageBytes.length - 2);
|
||||||
@@ -152,8 +141,6 @@ public class AbsEBikeMessage {
|
|||||||
int checksum = BytesUtil.bytesToIntLittle(checksumBytes);
|
int checksum = BytesUtil.bytesToIntLittle(checksumBytes);
|
||||||
System.out.println("checksum: " + checksum);
|
System.out.println("checksum: " + checksum);
|
||||||
|
|
||||||
// byte[] concat = Bytes.concat(header2, length2, physicalId2, messageId2, command2);
|
|
||||||
// System.out.println("concat: " + BytesUtil.printHexBinary(concat));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,15 +10,17 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public enum EBikeCommandEnum {
|
public enum EBikeCommandEnum {
|
||||||
// HEARTBEAT("01", "设备心跳包"),
|
|
||||||
HOST_GET_SERVER_TIME(0x12, "主机获取服务器时间", EBikeMessageCmd12.class),
|
|
||||||
REGISTRATION(0x20, "设备注册包", EBikeMessageCmd20.class),
|
|
||||||
DEVICE_GET_SERVER_TIME(0x22, "设备获取服务器时间", EBikeMessageCmd22.class),
|
|
||||||
HEARTBEAT_2(0x21, "设备心跳包", EBikeMessageCmd21.class),
|
|
||||||
CARD_OPERATION(0x02, "刷卡操作", EBikeMessageCmd02.class),
|
CARD_OPERATION(0x02, "刷卡操作", EBikeMessageCmd02.class),
|
||||||
SETTLEMENT_UPLOAD(0x03, "结算消费信息上传", EBikeMessageCmd03.class),
|
SETTLEMENT_UPLOAD(0x03, "结算消费信息上传", EBikeMessageCmd03.class),
|
||||||
CHARGE_PORT_CONFIRMATION(0x04, "充电端口订单确认", EBikeMessageCmd04.class),
|
CHARGE_PORT_CONFIRMATION(0x04, "充电端口订单确认", EBikeMessageCmd04.class),
|
||||||
POWER_HEARTBEAT(0x06, "端口充电时功率心跳包", EBikeMessageCmd06.class),
|
POWER_HEARTBEAT(0x06, "端口充电时功率心跳包", EBikeMessageCmd06.class),
|
||||||
|
HOST_HEARTBEAT(0x11, "主机状态心跳包", EBikeMessageCmd11.class),
|
||||||
|
HOST_GET_SERVER_TIME(0x12, "主机获取服务器时间", EBikeMessageCmd12.class),
|
||||||
|
REGISTRATION(0x20, "设备注册包", EBikeMessageCmd20.class),
|
||||||
|
HEARTBEAT_2(0x21, "设备心跳包", EBikeMessageCmd21.class),
|
||||||
|
DEVICE_GET_SERVER_TIME(0x22, "设备获取服务器时间", EBikeMessageCmd22.class),
|
||||||
|
// 上传分机版本号与设备类型(0x35指令)
|
||||||
|
DEVICE_VERSION_UPLOAD(0x35, "设备版本号上传", EBikeMessageCmd35.class),
|
||||||
REMOTE_CONTROL_COMMAND(0x82, "服务器开始、停止充电操作", EBikeMessageCmd82.class),
|
REMOTE_CONTROL_COMMAND(0x82, "服务器开始、停止充电操作", EBikeMessageCmd82.class),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -139,53 +139,66 @@ public class EBikeMessageCmd06 extends AbsEBikeMessage {
|
|||||||
int i = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length));
|
int i = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length));
|
||||||
this.port = i + YouDianUtils.convertPortNumberToString(i);
|
this.port = i + YouDianUtils.convertPortNumberToString(i);
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 1;
|
length = 1;
|
||||||
this.portStatus = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
// this.portStatus = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||||
|
this.portStatus = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) + "";
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.chargingTime = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
this.chargingTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) + "";
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.totalUsedElectricity = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.01 + "";
|
this.totalUsedElectricity = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) * 0.01 + "";
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 1;
|
length = 1;
|
||||||
this.startMode = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
this.startMode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) + "";
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.realTimePower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.1 + "";
|
this.realTimePower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) * 0.1 + "";
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.maxPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.1 + "";
|
this.maxPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) * 0.1 + "";
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.minPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.1 + "";
|
this.minPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) * 0.1 + "";
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.avgPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.1 + "";
|
this.avgPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) * 0.1 + "";
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 16;
|
length = 16;
|
||||||
this.orderCode = BytesUtil.bcd2Str(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length));
|
this.orderCode = BytesUtil.bcd2Str(BytesUtil.copyBytes(dataBytes, startIndex, length));
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.peakPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
this.peakPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) + "";
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.voltage = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.1 + "";
|
this.voltage = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) * 0.1 + "";
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.current = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.0001 + "";
|
this.current = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) * 0.0001 + "";
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 1;
|
length = 1;
|
||||||
this.ambientTemperature = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
this.ambientTemperature = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) + "";
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 1;
|
length = 1;
|
||||||
this.portTemperature = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
this.portTemperature = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) + "";
|
||||||
|
|
||||||
// length = 4;
|
|
||||||
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.occupancyTime = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
this.occupancyTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) + "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||||
|
|
||||||
|
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
||||||
|
|
||||||
|
public class EBikeMessageCmd11 extends AbsEBikeMessage {
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||||
|
|
||||||
|
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
||||||
|
|
||||||
|
public class EBikeMessageCmd35 extends AbsEBikeMessage {
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user