fix: SerialMate v0.1.1 接收路径修复——时间戳改 link 线程到达时刻打戳、接收日志批量插入+5000行上限+积压折叠、通道配置缓存;自测扩至 selftest_gui 69 项,新增 ISSUE 报告与 _sim_periodic 复现脚本;重打包
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
用法: python selftest_gui.py (全部通过退出码 0)
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
os.environ['QT_QPA_PLATFORM'] = 'offscreen'
|
||||
@@ -94,6 +95,13 @@ p.add(0, 43.0)
|
||||
check('暂停期间丢弃', p.is_paused() and len(p._times[0]) == n1, True)
|
||||
p.set_paused(False)
|
||||
|
||||
# 0e) 时间戳: 纯格式化函数, 传入到达时刻得确定字符串, 不传兜底当前时刻
|
||||
t_fix = 1759474800 + 0.456
|
||||
check('时间戳格式化(到达时刻)', m._timestamp(t_fix),
|
||||
_time.strftime('%H:%M:%S', _time.localtime(t_fix)) + '.456')
|
||||
check('时间戳格式化(现在兜底)',
|
||||
re.match(r'\d{2}:\d{2}:\d{2}\.\d{3}$', m._timestamp()) is not None, True)
|
||||
|
||||
# 1) 组帧预览: 多条 '/' 分隔
|
||||
win.ed_tx.setText('M1/M731S0T1000')
|
||||
check('多条预览', win.lb_preview.text(),
|
||||
@@ -116,9 +124,10 @@ check('帧构成非法详情', 'PAYLOAD 必须恰好出现一次' in win.lb_prot
|
||||
win.ed_layout.setText(d.DEFAULT_LAYOUT)
|
||||
check('帧构成还原预览', win.lb_preview.text(), 'D5 01 02 4D 31 81')
|
||||
|
||||
# 2) TX 回显行
|
||||
# 2) TX 回显行(直接驱动处理函数, 断言前 flush 批量日志缓冲)
|
||||
cfg = win._proto_from_ui()
|
||||
win._on_tx('M1', cfg.build_frame(b'M1'))
|
||||
win._flush_rx()
|
||||
check('TX日志行', 'M1 [D5 01 02 4D 31 81]' in win.text_rx.toPlainText(), True)
|
||||
|
||||
# 3) 帧事件: 日志 + 通道提取(文本数字×0.1)
|
||||
@@ -130,14 +139,22 @@ win._ch_ui[0]['mode'].setCurrentIndex(1) # 文本数字
|
||||
win._ch_ui[0]['idx'].setValue(1)
|
||||
win._ch_ui[0]['scale'].setValue(0.1)
|
||||
win._on_frame(fr)
|
||||
win._flush_rx()
|
||||
last = win.text_rx.toPlainText().splitlines()[-1]
|
||||
check('帧日志含 TYPE 名', 'B=0xF0 成功' in last and 'LEN=8' in last
|
||||
and 'okTL:246' in last, True)
|
||||
check('通道最新值', win._ch_ui[0]['val'].text(), '24.6')
|
||||
# 时间戳用 link 后台线程打的到达时刻, 而非 GUI 消费时刻
|
||||
ft = _time.time() - 3.456
|
||||
win._on_frame(fr, ft)
|
||||
win._flush_rx()
|
||||
check('帧日志用到达时刻', m._timestamp(ft)
|
||||
in win.text_rx.toPlainText().splitlines()[-1], True)
|
||||
|
||||
# 4) HEX 显示切换 + 原始帧
|
||||
win.combo_display.setCurrentIndex(1)
|
||||
win._on_frame(fr)
|
||||
win._flush_rx()
|
||||
last = win.text_rx.toPlainText().splitlines()[-1]
|
||||
check('HEX显示+原始帧', '6F 6B 54 4C 3A 32 34 36' in last
|
||||
and '[B5 F0 08 6F 6B 54 4C 3A 32 34 36 48]' in last, True)
|
||||
@@ -145,6 +162,7 @@ check('HEX显示+原始帧', '6F 6B 54 4C 3A 32 34 36' in last
|
||||
# 5) 透传行
|
||||
win.combo_display.setCurrentIndex(1)
|
||||
win._on_raw(b'\x11\x22')
|
||||
win._flush_rx()
|
||||
check('透传HEX行', win.text_rx.toPlainText().splitlines()[-1].endswith('11 22'), True)
|
||||
|
||||
# 6) 未连接发送丢弃
|
||||
@@ -152,6 +170,28 @@ win._send()
|
||||
win._drain_events()
|
||||
check('未连接发送提示', '未连接串口, 命令被丢弃' in win.text_rx.toPlainText(), True)
|
||||
|
||||
# 6b) 通道配置缓存: 帧路径读 _ch_cfg, 用户改配置时重建
|
||||
win._ch_ui[1]['chk'].setChecked(True)
|
||||
win._ch_ui[1]['name'].setText('乙')
|
||||
check('通道缓存随配置重建', win._ch_cfg[1]['enabled']
|
||||
and win._ch_cfg[1]['name'] == '乙', True)
|
||||
win._ch_ui[1]['chk'].setChecked(False)
|
||||
check('通道缓存关闭同步', not win._ch_cfg[1]['enabled'], True)
|
||||
|
||||
# 6c) 积压折叠: 队列积压超阈值时帧日志折叠为计数摘要(带首尾到达时刻), 曲线照常入库
|
||||
rx_n0, plot_n0 = win._rx_n, len(p._vals[0])
|
||||
now = _time.time()
|
||||
for k in range(250): # 100ms 间隔的到达时刻, 模拟高频上报
|
||||
win.events.put(('frame', fr, now - (250 - k) / 10.0))
|
||||
win._drain_events()
|
||||
log = win.text_rx.toPlainText()
|
||||
check('积压折叠摘要行', '折叠 250 帧' in log, True)
|
||||
check('折叠显示到达跨度', m._timestamp(now - 25.0) in log
|
||||
and m._timestamp(now - 0.1) in log, True)
|
||||
check('折叠保曲线', len(p._vals[0]) == plot_n0 + 250, True)
|
||||
check('折叠计数器照常', win._rx_n == rx_n0 + 250, True)
|
||||
check('折叠摘要含帧描述', 'B=0xF0 成功 ×250' in log, True)
|
||||
|
||||
# 7) 配置往返
|
||||
store = win._store_from_ui()
|
||||
check('配置 proto', (store['proto']['tx_hdr'], store['proto']['crc_algo']),
|
||||
|
||||
Reference in New Issue
Block a user