mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-15 07:18:31 +08:00
update 电单车
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.jsowell.pile.domain.ebike;
|
package com.jsowell.pile.domain.ebike;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.jsowell.common.YouDianUtils;
|
import com.jsowell.common.YouDianUtils;
|
||||||
import com.jsowell.common.util.BytesUtil;
|
import com.jsowell.common.util.BytesUtil;
|
||||||
import com.jsowell.pile.domain.ebike.deviceupload.*;
|
import com.jsowell.pile.domain.ebike.deviceupload.*;
|
||||||
@@ -102,44 +103,12 @@ public class AbsEBikeMessage {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String s = "444e593200198bca077c000601010a0000000100000000000000001327388102240913141915803959463300000000750800005e00fe06";
|
String s = "444e593200198bca0782000600018e030700015a0b6b0b190b480b1327388101240913141035606593918397006e0b73083f055f002d0b";
|
||||||
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);
|
||||||
// 读取包头
|
AbsEBikeMessage absEBikeMessage = parseMessage(messageBytes);
|
||||||
byte[] headerBytes = Arrays.copyOfRange(messageBytes, 0, 3);
|
System.out.println(JSON.toJSONString(absEBikeMessage));
|
||||||
String header = new String(headerBytes, StandardCharsets.UTF_8);
|
|
||||||
System.out.println("header: " + header);
|
|
||||||
|
|
||||||
// 读取长度
|
|
||||||
byte[] lengthBytes = Arrays.copyOfRange(messageBytes, 3, 5);
|
|
||||||
int length = BytesUtil.bytesToIntLittle(lengthBytes);
|
|
||||||
System.out.println("length: " + length);
|
|
||||||
|
|
||||||
// 读取物理ID
|
|
||||||
byte[] physicalIdBytes = Arrays.copyOfRange(messageBytes, 5, 9);
|
|
||||||
int physicalId = BytesUtil.bytesToIntLittle(physicalIdBytes);
|
|
||||||
System.out.println("physicalId: " + physicalId);
|
|
||||||
|
|
||||||
// 读取消息ID
|
|
||||||
byte[] messageIdBytes = Arrays.copyOfRange(messageBytes, 9, 11);
|
|
||||||
int messageId = BytesUtil.bytesToIntLittle(messageIdBytes);
|
|
||||||
System.out.println("messageId: " + messageId);
|
|
||||||
|
|
||||||
// 读取命令
|
|
||||||
byte commandByte = messageBytes[11];
|
|
||||||
String command = BytesUtil.bcd2StrLittle(new byte[]{commandByte});
|
|
||||||
System.out.println("command: " + command);
|
|
||||||
|
|
||||||
// 读取数据
|
|
||||||
byte[] dataBytes = Arrays.copyOfRange(messageBytes, 12, messageBytes.length - 2);
|
|
||||||
String data = BytesUtil.bytesToIntLittle(dataBytes) + "";
|
|
||||||
System.out.println("data: " + data);
|
|
||||||
|
|
||||||
// 读取校验
|
|
||||||
byte[] checksumBytes = Arrays.copyOfRange(messageBytes, messageBytes.length - 2, messageBytes.length);
|
|
||||||
int checksum = BytesUtil.bytesToIntLittle(checksumBytes);
|
|
||||||
System.out.println("checksum: " + checksum);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 端口充电时功率心跳包(06指令)
|
* 端口充电时功率心跳包(06指令)
|
||||||
@@ -95,7 +95,7 @@ public class EBikeMessageCmd06 extends AbsEBikeMessage {
|
|||||||
/**
|
/**
|
||||||
* 该时间段内消耗电量:此数据需除以4800后才是真实的电量,该字段属于调试使用,服务器无需关心此字段
|
* 该时间段内消耗电量:此数据需除以4800后才是真实的电量,该字段属于调试使用,服务器无需关心此字段
|
||||||
*/
|
*/
|
||||||
// private String timePeriodElectricity;
|
private String timePeriodElectricity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 峰值功率:整个充电过程中出现过的最大功率,有些版本无此字段
|
* 峰值功率:整个充电过程中出现过的最大功率,有些版本无此字段
|
||||||
@@ -136,8 +136,8 @@ public class EBikeMessageCmd06 extends AbsEBikeMessage {
|
|||||||
public PowerHeartbeat(byte[] dataBytes) {
|
public PowerHeartbeat(byte[] dataBytes) {
|
||||||
int startIndex = 0;
|
int startIndex = 0;
|
||||||
int length = 1;
|
int length = 1;
|
||||||
int i = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length));
|
int i = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
|
||||||
this.port = i + YouDianUtils.convertPortNumberToString(i);
|
this.port = YouDianUtils.convertPortNumberToString(i);
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 1;
|
length = 1;
|
||||||
@@ -176,17 +176,23 @@ public class EBikeMessageCmd06 extends AbsEBikeMessage {
|
|||||||
length = 16;
|
length = 16;
|
||||||
this.orderCode = BytesUtil.bcd2Str(BytesUtil.copyBytes(dataBytes, startIndex, length));
|
this.orderCode = BytesUtil.bcd2Str(BytesUtil.copyBytes(dataBytes, startIndex, length));
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
|
length = 2;
|
||||||
|
this.timePeriodElectricity = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) + "";
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.peakPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) + "";
|
this.peakPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) + "";
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.voltage = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) * 0.1 + "";
|
this.voltage = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)))
|
||||||
|
.multiply(new BigDecimal("0.1")).toString();
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 2;
|
length = 2;
|
||||||
this.current = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)) * 0.0001 + "";
|
this.current = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)))
|
||||||
|
.multiply(new BigDecimal("0.001")).toString();
|
||||||
|
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
length = 1;
|
length = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user