fix: update timestamp decoding for Waveform and Continuous records in models and client

This commit is contained in:
Brian Harrison
2026-04-04 00:09:55 -04:00
parent 2286d2ccf8
commit 1c570b083a
3 changed files with 77 additions and 12 deletions

View File

@@ -625,14 +625,18 @@ def _decode_waveform_record_into(data: bytes, event: Event) -> None:
# ── Timestamp ─────────────────────────────────────────────────────────────
# 9-byte format for sub_code=0x10 Waveform records:
# [day][sub_code][month][year:2 BE][unknown][hour][min][sec]
# MonitorLog (sub_code=0x03) records have a different byte layout — applying
# the waveform layout produces garbage (year=1031, month=16). Leave timestamp
# None for non-Waveform records until the correct layout is confirmed.
# sub_code=0x10 and sub_code=0x03 have different timestamp byte layouts.
# Both confirmed against Blastware event reports (BE11529, 2026-04-01 and 2026-04-03).
if event.record_type == "Waveform":
try:
event.timestamp = Timestamp.from_waveform_record(data)
except Exception as exc:
log.warning("waveform record timestamp decode failed: %s", exc)
elif event.record_type == "Waveform (Continuous)":
try:
event.timestamp = Timestamp.from_continuous_record(data)
except Exception as exc:
log.warning("continuous record timestamp decode failed: %s", exc)
# ── Peak values (per-channel PPV + Peak Vector Sum) ───────────────────────
try:
@@ -936,11 +940,11 @@ def _extract_record_type(data: bytes) -> Optional[str]:
if code == 0x10:
return "Waveform"
if code == 0x03:
# Monitor log record — Instantel's periodic time-weighted average record.
# Appears in BW's event list but NOT on the physical device display.
# The byte layout differs from 0x10 waveform records: the timestamp fields
# decode as garbage under the waveform layout and should not be trusted.
return "MonitorLog"
# Continuous mode waveform record (confirmed by user — NOT a monitor log).
# The byte layout differs from 0x10 single-shot records: the timestamp
# fields decode as garbage under the 0x10 waveform layout.
# TODO: confirm correct timestamp layout for 0x03 records from a known-time event.
return "Waveform (Continuous)"
log.warning("_extract_record_type: unknown sub_code=0x%02X", code)
return f"Unknown(0x{code:02X})"