From 8d662de2fd262b3a485f16e197cb4d0ca2a61cdf Mon Sep 17 00:00:00 2001
From: zsh_root <979909237@qq.com>
Date: 星期三, 10 十二月 2025 17:03:47 +0800
Subject: [PATCH] 发布版V1.0
---
src/jiexi/Dell55AA02Parser.java | 38 ++++++++++++++++++--------------------
1 files changed, 18 insertions(+), 20 deletions(-)
diff --git a/src/jiexi/Dell55AA02Parser.java b/src/jiexi/Dell55AA02Parser.java
index 42d3f60..63ed798 100644
--- a/src/jiexi/Dell55AA02Parser.java
+++ b/src/jiexi/Dell55AA02Parser.java
@@ -1,52 +1,50 @@
package jiexi;
-import dell_system.MessageViewPanel;
-import dell_targets.Dell_BaseStation;
-import publicsWay.EfficientTimeFormatter;
+
public class Dell55AA02Parser {
- private static final int SYNC_STATUS_START = 12; // 同步状态起始位置(第5字节)
- private static final int PRESSURE_START = 14; // 气压值起始位置(第6字节)
- private static final int MIN_MESSAGE_LENGTH = 22; // 最小有效数据长度
+ private static final int SYNC_STATUS_START = 12; // 鍚屾鐘舵�佽捣濮嬩綅缃�(绗�5瀛楄妭)
+ private static final int PRESSURE_START = 14; // 姘斿帇鍊艰捣濮嬩綅缃�(绗�6瀛楄妭)
+ private static final int MIN_MESSAGE_LENGTH = 22; // 鏈�灏忔湁鏁堟暟鎹暱搴�
- // 重用StringBuilder减少内存分配
+ // 閲嶇敤StringBuilder鍑忓皯鍐呭瓨鍒嗛厤
private static final ThreadLocal<StringBuilder> hexDataBuilder =
ThreadLocal.withInitial(() -> new StringBuilder(64));
/**
- * 高效解析55AA02格式的基站数据
- * @param message 接收到的数据(十六进制字符串)
+ * 楂樻晥瑙f瀽55AA02鏍煎紡鐨勫熀绔欐暟鎹�
+ * @param message 鎺ユ敹鍒扮殑鏁版嵁锛堝崄鍏繘鍒跺瓧绗︿覆锛�
*/
public static void parse(String message, String ip, int port) {
- // 1. 基础校验
+ // 1. 鍩虹鏍¢獙
if (message == null || message.length() < MIN_MESSAGE_LENGTH) {
return;
}
- // 2. 解析标签ID (位置8-11, 小端序)
+ // 2. 瑙f瀽鏍囩ID (浣嶇疆8-11, 灏忕搴�)
char c8 = message.charAt(8);
char c9 = message.charAt(9);
char c10 = message.charAt(10);
char c11 = message.charAt(11);
- // 直接构建baseId字符串
+ // 鐩存帴鏋勫缓baseId瀛楃涓�
String baseId = new String(new char[]{c10, c11, c8, c9});
- // 3. 解析同步状态(1字节)
+ // 3. 瑙f瀽鍚屾鐘舵�侊紙1瀛楄妭锛�
char syncStatusChar = message.charAt(SYNC_STATUS_START + 1);
String syncStatus = (syncStatusChar == '0') ? "0" : "1";
- // 4. 高效解析气压值(4字节小端序)
+ // 4. 楂樻晥瑙f瀽姘斿帇鍊硷紙4瀛楄妭灏忕搴忥級
int pressure = 0;
for (int i = 0; i < 8; i += 2) {
int idx = PRESSURE_START + i;
- // 使用HexUtils的快速转换方法
+ // 浣跨敤HexUtils鐨勫揩閫熻浆鎹㈡柟娉�
int byteValue = HexUtils.fastHexToByte(message.charAt(idx), message.charAt(idx + 1));
- pressure |= (byteValue << (i * 4)); // 小端合并
+ pressure |= (byteValue << (i * 4)); // 灏忕鍚堝苟
}
- // 5. 更新基站数据
+ /*// 5. 鏇存柊鍩虹珯鏁版嵁
if (MessageViewPanel.isWindowVisible) {
StringBuilder sb = hexDataBuilder.get();
sb.setLength(0);
@@ -59,16 +57,16 @@
MessageViewPanel.showData(sb.toString(), ip, port, 0, "UDPA", "55AA02", baseId);
}
- // 延迟创建时间字符串直到必要时刻
+ // 寤惰繜鍒涘缓鏃堕棿瀛楃涓茬洿鍒板繀瑕佹椂鍒�
String time = EfficientTimeFormatter.getCurrentTimeFormatted();
- // 使用预分配字符串常量减少内存分配
+ // 浣跨敤棰勫垎閰嶅瓧绗︿覆甯搁噺鍑忓皯鍐呭瓨鍒嗛厤
Dell_BaseStation.updateBaseStationProperty(baseId, "ipAddress", ip);
Dell_BaseStation.updateBaseStationProperty(baseId, "port", Integer.toString(port));
Dell_BaseStation.updateBaseStationProperty(baseId, "status", "1");
Dell_BaseStation.updateBaseStationProperty(baseId, "onlineTime", time);
Dell_BaseStation.updateBaseStationProperty(baseId, "syncStatus", syncStatus);
- Dell_BaseStation.updateBaseStationProperty(baseId, "barometerReading", Integer.toString(pressure));
+ Dell_BaseStation.updateBaseStationProperty(baseId, "barometerReading", Integer.toString(pressure));*/
}
--
Gitblit v1.10.0