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:
serversdownandClaude Opus 5.5 committed 2026-10-30 00:36:26 -04:00
1 parent 50a0501147
commit b6ed5f5bd5
10 files changed
+200 -21

No files matched your search

+6 -4
View File
@@ -71,7 +71,7 @@ from minimateplus import MiniMateClient
from minimateplus.protocol import ProtocolError
from minimateplus.models import CallHomeConfig, ComplianceConfig, DeviceInfo, Event, PeakValues, ProjectInfo, Timestamp
from minimateplus.transport import TcpTransport, DEFAULT_TCP_PORT
from minimateplus.blastware_file import write_blastware_file, blastware_filename
from minimateplus.blastware_file import blastware_file_bytes, blastware_filename, with_type_letter
from minimateplus.client import _decode_a5_metadata_into, _decode_a5_waveform, _decode_event_count
from minimateplus.framing import build_bw_write_frame, SESSION_RESET, POLL_PROBE, POLL_DATA
from minimateplus.protocol import SUB_STOP_MONITORING
@@ -1025,8 +1025,10 @@ def device_event_blastware_file(
# Determine serial number from device info
serial = getattr(info, "serial", None) or "UNKNOWN"
# Build filename using the same algorithm Blastware uses
filename = blastware_filename(ev, serial)
# Build filename using the same algorithm Blastware uses, plus the W/H type
# letter its direct downloads leave off (read from the file's own bytes).
bw_bytes = blastware_file_bytes(ev, a5_frames)
filename = with_type_letter(blastware_filename(ev, serial), bw_bytes)
# Write to OS temp dir (cross-platform: /tmp on Linux/macOS,
# %TEMP% on Windows) so FastAPI can stream it back via FileResponse.
@@ -1040,7 +1042,7 @@ def device_event_blastware_file(
out_path.unlink()
except FileNotFoundError:
pass
write_blastware_file(ev, a5_frames, out_path)
out_path.write_bytes(bw_bytes)
log.info(
"blastware_file: wrote %s (%d A5 frames, serial=%s)",
out_path, len(a5_frames), serial,