Skip to content

Commit 8d51b8a

Browse files
committed
1.修复dlt645规约,界面上显示报文长度为0的bug。2.优化前端报文显示16进制换行问题
1 parent ce12e28 commit 8d51b8a

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 更新日志
2+
## [1.0.0] - 2026-2-21
3+
- 初始版本发布

front/src/components/device/MessageViewDialog.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ onUnmounted(() => {
217217
.hex-data {
218218
font-family: 'Consolas', 'Monaco', monospace;
219219
font-size: 13px;
220-
word-break: break-all;
220+
word-break: break-word;
221+
overflow-wrap: break-word;
222+
white-space: normal;
221223
color: var(--text-primary, #333);
222224
}
223225

src/device/core/message/message_formatter.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,23 @@ def get_messages(self, limit: Optional[int] = None) -> List[dict]:
138138
elif is_iec104 and raw_hex:
139139
description = IEC104MessageParser.parse(raw_hex)
140140

141+
# 原始16进制数据和长度
142+
hex_data = msg.get("hex_string", msg.get("data", ""))
143+
length = msg.get("length", 0)
144+
if not length and hex_data:
145+
# 从hex_data计算字节长度
146+
length = len(hex_data.replace(" ", "")) // 2
147+
141148
result.append({
142149
"sequence_id": msg.get("sequence_id", 0),
143150
"timestamp": msg.get("timestamp", 0),
144151
"formatted_time": msg.get("time", msg.get("formatted_time", "")),
145152
"direction": direction,
146153
"msg_type": msg_type,
147-
"hex_data": msg.get("hex_string", msg.get("data", "")),
154+
"hex_data": hex_data,
148155
"raw_hex": raw_hex,
149156
"description": description,
150-
"length": msg.get("length", 0),
157+
"length": length,
151158
})
152159

153160
# 按序号正序排列

0 commit comments

Comments
 (0)