feat(sfm): SFM's MiniMate files carry the W/H type letter Blastware's direct downloads leave off
Blastware names a direct download K441LTON.900 and only its call-in copy K441LTON.900H, so a folder of directly downloaded events cannot be sorted by kind. SFM's own files now always carry the letter. It is read from the file's own record-type byte (STRT[18], #41) by the new with_type_letter() -- not from the recording mode: BE9441's K441LTOK.R10 is a waveform that triggered 2 s into histogram K441LTOK.QZ0 (Histogram+Continuous). A file whose type does not read keeps the plain name; a name never fails a download. All three paths that name a MiniMate file SFM builds: the device-access download (the page's event list), WaveformStore.save (the legacy route's store copy, the bench call-in server), and the legacy /device/event/{i}/blastware_file download. Verified on BE9441's recorded 5A walk: 0111f210 -> K441LTON.900H, 011106a0 -> K441LTOK.R10W, byte-identical to Blastware's files. find_event_by_blastware_name tightens with it: a lettered name matches itself and the letterless form, not the other letter (a waveform and a histogram in the same second are different events); a letterless name still matches all three. Store consequence: new downloads only; rows and files stored before keep their names, and 'already stored' still finds them. No schema change, no migration. The event list shows the plain name until the event is downloaded (the type is not known before the 5A). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
1 parent
50a0501147
commit
b6ed5f5bd5
10 files changed
+200
-21
No files matched your search
@@ -467,6 +467,9 @@ def blastware_filename(event: Event, serial: str, ach: bool = False) -> str:
|
||||
0 = always literal digit zero
|
||||
|
||||
T = 'W' or 'H' — ONLY appended for call-home (ACH) downloads (ach=True).
|
||||
⚠ ach=True guesses the letter from the recording mode, which is wrong for
|
||||
a waveform recorded in Histogram+Continuous; for a file in hand use
|
||||
`with_type_letter(name, bw_bytes)`, which reads the file's own type byte.
|
||||
Manual / direct downloads produce a 3-char extension (AB0) with no type char.
|
||||
Call-home downloads produce a 4-char extension (AB0W or AB0H).
|
||||
|
||||
@@ -531,6 +534,32 @@ def blastware_filename(event: Event, serial: str, ach: bool = False) -> str:
|
||||
return prefix + stem + ext
|
||||
|
||||
|
||||
_TYPE_LETTER = {"Waveform": "W", "Histogram": "H"}
|
||||
|
||||
|
||||
def with_type_letter(name: str, bw_bytes: bytes) -> str:
|
||||
"""`name` with the W/H type letter, for a Blastware file SFM built itself.
|
||||
|
||||
Blastware's own direct downloads leave the letter off (`K441LTON.900`) and
|
||||
only its call-in copies carry it (`K441LTON.900H`), which makes events hard
|
||||
to sort; SFM's files carry it (2026-10-30). The letter is read from the
|
||||
file's own record-type byte -- STRT[18], as `decode_blastware_bytes` reads it
|
||||
(#41) -- not from the recording mode, which in Histogram+Continuous records
|
||||
both kinds. A file whose type does not read keeps the plain name: a name is
|
||||
never a reason to fail a download. A name already carrying a letter, or
|
||||
not of the `<stem>.<AB>0` form, is returned unchanged.
|
||||
"""
|
||||
if blastware_filename_time(name) is None or len(name.rsplit(".", 1)[-1]) != 3:
|
||||
return name
|
||||
try:
|
||||
from .event_file_io import decode_blastware_bytes # lazy: event_file_io imports this module
|
||||
letter = _TYPE_LETTER.get(decode_blastware_bytes(bw_bytes).record_type)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
log.warning("with_type_letter: %s: the record type did not read (%s) -- plain name kept", name, exc)
|
||||
letter = None
|
||||
return name + letter if letter else name
|
||||
|
||||
|
||||
# ── A5 frame classifier ───────────────────────────────────────────────────────────
|
||||
|
||||
# ASCII markers that identify a compliance-config / metadata frame.
|
||||
|
||||
Reference in new issue
Block a user