fix: correct Event and PeakValues field names in ach_server serialization
Event model uses peak_values (not peaks) and project_info (not direct fields). PeakValues fields are tran/vert/long/micl/peak_vector_sum (not transverse etc). ProjectInfo fields accessed via ev.project_info.project etc. Also fix ev.timestamp serialization: use str() instead of .isoformat() since Timestamp is a custom dataclass, not datetime. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+22
-17
@@ -279,14 +279,17 @@ class AchSession:
|
||||
log.info(" (skipped %d already-seen event(s))", last_count)
|
||||
|
||||
for i, ev in enumerate(new_events):
|
||||
pv = ev.peak_values
|
||||
pi = ev.project_info
|
||||
log.info(
|
||||
" NEW Event %d: %s Tran=%.4f Vert=%.4f Long=%.4f VS=%.4f",
|
||||
" NEW Event %d: %s Tran=%.4f Vert=%.4f Long=%.4f VS=%.4f project=%r",
|
||||
last_count + i,
|
||||
ev.timestamp.isoformat() if ev.timestamp else "?",
|
||||
ev.peaks.transverse if ev.peaks else 0,
|
||||
ev.peaks.vertical if ev.peaks else 0,
|
||||
ev.peaks.longitudinal if ev.peaks else 0,
|
||||
ev.peaks.vector_sum if ev.peaks else 0,
|
||||
str(ev.timestamp) if ev.timestamp else "?",
|
||||
pv.tran if pv else 0,
|
||||
pv.vert if pv else 0,
|
||||
pv.long if pv else 0,
|
||||
pv.peak_vector_sum if pv else 0,
|
||||
pi.project if pi else "",
|
||||
)
|
||||
|
||||
# Update high-water mark
|
||||
@@ -342,14 +345,16 @@ def _device_info_to_dict(d: DeviceInfo) -> dict:
|
||||
|
||||
|
||||
def _event_to_dict(e: Event) -> dict:
|
||||
pv = e.peak_values
|
||||
pi = e.project_info
|
||||
peaks = {}
|
||||
if e.peaks:
|
||||
if pv:
|
||||
peaks = {
|
||||
"transverse": e.peaks.transverse,
|
||||
"vertical": e.peaks.vertical,
|
||||
"longitudinal": e.peaks.longitudinal,
|
||||
"vector_sum": e.peaks.vector_sum,
|
||||
"mic": e.peaks.mic,
|
||||
"transverse": pv.tran,
|
||||
"vertical": pv.vert,
|
||||
"longitudinal": pv.long,
|
||||
"vector_sum": pv.peak_vector_sum,
|
||||
"mic": pv.micl,
|
||||
}
|
||||
samples = {}
|
||||
if e.raw_samples:
|
||||
@@ -359,11 +364,11 @@ def _event_to_dict(e: Event) -> dict:
|
||||
}
|
||||
samples["__note__"] = "first 20 sample-sets only; see raw_rx.bin for full waveform"
|
||||
return {
|
||||
"timestamp": e.timestamp.isoformat() if e.timestamp else None,
|
||||
"project": e.project,
|
||||
"client": e.client,
|
||||
"operator": e.operator,
|
||||
"sensor_location": e.sensor_location,
|
||||
"timestamp": str(e.timestamp) if e.timestamp else None,
|
||||
"project": pi.project if pi else None,
|
||||
"client": pi.client if pi else None,
|
||||
"operator": pi.operator if pi else None,
|
||||
"sensor_location": pi.sensor_location if pi else None,
|
||||
"peaks": peaks,
|
||||
"raw_samples_preview": samples,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user