fix: update Peak Vector Sum offset calculation and clarify event_count handling in device info

This commit is contained in:
Brian Harrison
2026-04-05 02:48:58 -04:00
parent 1c570b083a
commit ecb1147216
2 changed files with 12 additions and 4 deletions

View File

@@ -993,14 +993,22 @@ def _extract_peak_floats(data: bytes) -> Optional[PeakValues]:
if not vals:
return None
# ── Peak Vector Sum — fixed offset 87 (✅ confirmed 2026-04-01) ───────────
# ── Peak Vector Sum — label-relative offset ──────────────────────────────
# = √(Tran² + Vert² + Long²) at the sample instant of maximum combined geo
# motion, NOT the vector sum of the three per-channel peak values (which may
# occur at different times). Matches Blastware "Peak Vector Sum" exactly.
#
# PVS lives at tran_label_pos - 12 for both 0x10 and 0x03 record types.
# Confirmed from raw bytes of two events (2026-04-01 and 2026-04-03):
# 0x10: Tran at byte 98, PVS float at bytes 8689 (98 - 12 = 86) ✅
# 0x03: Tran at byte 104, PVS float at bytes 9295 (104 - 12 = 92) ✅
# Using a fixed absolute offset (87) breaks for 0x03 records because their
# timestamp header is 10 bytes instead of 9, shifting all subsequent fields.
pvs: Optional[float] = None
if len(data) > 91:
tran_pos = data.find(b"Tran")
if tran_pos >= 12:
try:
pvs = struct.unpack_from(">f", data, 87)[0]
pvs = struct.unpack_from(">f", data, tran_pos - 12)[0]
except struct.error:
pass