fix: update Peak Vector Sum offset calculation and clarify event_count handling in device info
This commit is contained in:
@@ -993,14 +993,22 @@ def _extract_peak_floats(data: bytes) -> Optional[PeakValues]:
|
|||||||
if not vals:
|
if not vals:
|
||||||
return None
|
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
|
# = √(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
|
# motion, NOT the vector sum of the three per-channel peak values (which may
|
||||||
# occur at different times). Matches Blastware "Peak Vector Sum" exactly.
|
# 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 86–89 (98 - 12 = 86) ✅
|
||||||
|
# 0x03: Tran at byte 104, PVS float at bytes 92–95 (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
|
pvs: Optional[float] = None
|
||||||
if len(data) > 91:
|
tran_pos = data.find(b"Tran")
|
||||||
|
if tran_pos >= 12:
|
||||||
try:
|
try:
|
||||||
pvs = struct.unpack_from(">f", data, 87)[0]
|
pvs = struct.unpack_from(">f", data, tran_pos - 12)[0]
|
||||||
except struct.error:
|
except struct.error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ def _serialise_device_info(info: DeviceInfo) -> dict:
|
|||||||
"dsp_version": info.dsp_version,
|
"dsp_version": info.dsp_version,
|
||||||
"manufacturer": info.manufacturer,
|
"manufacturer": info.manufacturer,
|
||||||
"model": info.model,
|
"model": info.model,
|
||||||
"event_count": info.event_count,
|
"event_count_sub08": info.event_count, # unreliable — SUB 08 always returns 1
|
||||||
"compliance_config": _serialise_compliance_config(info.compliance_config),
|
"compliance_config": _serialise_compliance_config(info.compliance_config),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user