feat(sfm): Series-3 events -- header list, one-event download, stale ids refused
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
c85244e0fe
commit
b79309eb72
3 files changed
+242
-11
No files matched your search
@@ -6,12 +6,13 @@ call pops one, if any, and raises it.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import datetime
|
||||
from pathlib import Path
|
||||
|
||||
from micromate.models import MicromateDeviceInfo, MicromateState
|
||||
from micromate.setup_block import decode_setup
|
||||
from minimateplus.models import ComplianceConfig, DeviceInfo, MonitorStatus
|
||||
from minimateplus.models import ComplianceConfig, DeviceInfo, Event, MonitorStatus, PeakValues, Timestamp
|
||||
|
||||
SETUP_FIXTURE = Path(__file__).parent / "fixtures" / "micromate-setup" / "um20147_baseline.bin"
|
||||
|
||||
@@ -41,8 +42,29 @@ class _Base:
|
||||
self._open = False
|
||||
|
||||
|
||||
def s3_event(index, key_hex, when, *, record_type="Waveform", pvs=0.12, frames=True):
|
||||
ev = Event(index=index)
|
||||
ev._waveform_key = bytes.fromhex(key_hex)
|
||||
ev.timestamp = Timestamp(raw=b"", flag=0x10, year=when.year, unknown_byte=0,
|
||||
month=when.month, day=when.day, hour=when.hour,
|
||||
minute=when.minute, second=when.second)
|
||||
ev.record_type = record_type
|
||||
ev.peak_values = PeakValues(tran=0.05, vert=0.08, long=0.03, micl=0.0001,
|
||||
peak_vector_sum=pvs)
|
||||
if frames:
|
||||
ev._a5_frames = ["frame"]
|
||||
return ev
|
||||
|
||||
|
||||
def default_s3_events():
|
||||
return [
|
||||
s3_event(0, "01110000", datetime.datetime(2026, 10, 1, 8, 0, 0)),
|
||||
s3_event(1, "0111245a", datetime.datetime(2026, 10, 2, 9, 30, 15), record_type="Histogram"),
|
||||
]
|
||||
|
||||
|
||||
class FakeMiniMateClient(_Base):
|
||||
def __init__(self, serial="BE18193", *, monitoring=False, compliance="default", **kw):
|
||||
def __init__(self, serial="BE18193", *, monitoring=False, compliance="default", events=None, **kw):
|
||||
super().__init__(**kw)
|
||||
self.serial = serial
|
||||
self.monitoring = monitoring
|
||||
@@ -54,6 +76,7 @@ class FakeMiniMateClient(_Base):
|
||||
operator="BH", sensor_location="Loc 1", notes=None,
|
||||
)
|
||||
self.compliance = compliance
|
||||
self.events = default_s3_events() if events is None else events
|
||||
|
||||
def connect(self) -> DeviceInfo:
|
||||
self._step("connect")
|
||||
@@ -74,6 +97,23 @@ class FakeMiniMateClient(_Base):
|
||||
)
|
||||
|
||||
|
||||
def list_event_headers(self):
|
||||
self._step("list_event_headers")
|
||||
out = []
|
||||
for ev in self.events:
|
||||
h = copy.copy(ev)
|
||||
h._a5_frames = None
|
||||
out.append(h)
|
||||
return out
|
||||
|
||||
def download_event_by_key(self, key4):
|
||||
self._step("download_event_by_key")
|
||||
for ev in self.events:
|
||||
if ev._waveform_key == key4:
|
||||
return ev
|
||||
return None
|
||||
|
||||
|
||||
class _FakeProtocol:
|
||||
def __init__(self, owner):
|
||||
self._owner = owner
|
||||
|
||||
Reference in new issue
Block a user