feat(flomni): split omny_panda into two devices, fix free-running completion check
CI for csaxs_bec / test (push) Successful in 2m13s
CI for csaxs_bec / test (push) Successful in 2m13s
Mode A (per-gate aggregate) and Mode B (continuous raw-sample) need different PandA hardware layouts and can't run simultaneously, so omny_panda is now two device config entries in ptycho_flomni.yaml: omny_panda (legacy, kept commented as the restore reference) and omny_panda_continuous (raw_stream_mode: true, enabled). Also fixes on_complete for the continuous case. PCAP.CAPTURED can't be used to detect end-of-acquisition on this layout: CLOCK1 drives PCAP.gate/trig continuously, so the captured count never naturally stops increasing while armed -- the previous settle-based wait would have just run out its timeout. COUNTER1 (frame_counter) instead counts completed exposures directly (triggered on the detector-trigger's falling edge), so PandaBoxOMNY now waits for it to reach the exact expected num_points * frames_per_trigger, mirroring the legacy exact-count check instead of guessing when capture has "settled". Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TsfqLcPWspjJ6vedMyCxco
This commit is contained in:
1 parent
3012cd3154
commit
f93e591227
7 files changed
+131
-92
No files matched your search
@@ -646,40 +646,68 @@ calculated_signal:
|
||||
############################################################
|
||||
#################### OMNY Pandabox #########################
|
||||
############################################################
|
||||
omny_panda:
|
||||
# Mode A (legacy per-gate aggregate acquisition). The PandA layout has to match the
|
||||
# selected mode (see docs/developer/panda_box_free_running_setup.md, "Open question") -
|
||||
# it currently has the Mode B layout loaded (see omny_panda_continuous below), so this
|
||||
# block is kept commented as the reference/restore point for Mode A rather than enabled
|
||||
# alongside it. To go back to Mode A: disable/remove omny_panda_continuous below, restore
|
||||
# the PandA layout for per-gate aggregate capture, and uncomment this block.
|
||||
# omny_panda:
|
||||
# readoutPriority: async
|
||||
# deviceClass: csaxs_bec.devices.panda_box.panda_box_omny.PandaBoxOMNY
|
||||
# deviceConfig:
|
||||
# host: omny-panda.psi.ch
|
||||
# signal_alias:
|
||||
# FMC_IN.VAL1.Min: cap_voltage_fzp_y_min
|
||||
# FMC_IN.VAL1.Max: cap_voltage_fzp_y_max
|
||||
# FMC_IN.VAL1.Mean: cap_voltage_fzp_y_mean
|
||||
# FMC_IN.VAL2.Min: cap_voltage_fzp_x_min
|
||||
# FMC_IN.VAL2.Max: cap_voltage_fzp_x_max
|
||||
# FMC_IN.VAL2.Mean: cap_voltage_fzp_x_mean
|
||||
# INENC1.VAL.Max: interf_st_fzp_y_max
|
||||
# INENC1.VAL.Mean: interf_st_fzp_y_mean
|
||||
# INENC1.VAL.Min: interf_st_fzp_y_min
|
||||
# INENC2.VAL.Max: interf_st_fzp_x_max
|
||||
# INENC2.VAL.Mean: interf_st_fzp_x_mean
|
||||
# INENC2.VAL.Min: interf_st_fzp_x_min
|
||||
# INENC3.VAL.Max: interf_st_rotz_max
|
||||
# INENC3.VAL.Mean: interf_st_rotz_mean
|
||||
# INENC3.VAL.Min: interf_st_rotz_min
|
||||
# INENC4.VAL.Max: interf_st_rotx_max
|
||||
# INENC4.VAL.Mean: interf_st_rotx_mean
|
||||
# INENC4.VAL.Min: interf_st_rotx_min
|
||||
# PCAP.GATE_DURATION.Value: pcap_gate_duration_value
|
||||
# enabled: true
|
||||
# readOnly: false
|
||||
# softwareTrigger: false
|
||||
# deviceTags:
|
||||
# - ptycho_flomni
|
||||
|
||||
# Mode B (continuous free-running raw-sample acquisition), see
|
||||
# docs/developer/panda_box_free_running_setup.md. Requires the matching PandA layout to be
|
||||
# loaded (TTLIN1 = detector trigger -> COUNTER1 falling-edge count = frame_counter and
|
||||
# PCAP.BITS0 bit 0 = gate bit; CLOCK1 driving PCAP.gate/trig continuously; all six
|
||||
# analog/encoder channels on raw Value capture) - confirmed against the omny-panda hardware
|
||||
# 2026-09-15, currently running at 100 Hz for initial testing.
|
||||
omny_panda_continuous:
|
||||
readoutPriority: async
|
||||
deviceClass: csaxs_bec.devices.panda_box.panda_box_omny.PandaBoxOMNY
|
||||
deviceConfig:
|
||||
host: omny-panda.psi.ch
|
||||
# raw_stream_mode selects the free-running raw-sample acquisition mode described in
|
||||
# docs/developer/panda_box_free_running_setup.md. Defaults to false (legacy per-gate
|
||||
# aggregate capture, as configured below) - do not enable until the PandaBox layout has
|
||||
# been reconfigured for continuous capture per that document.
|
||||
raw_stream_mode: false
|
||||
raw_stream_mode: true
|
||||
signal_alias:
|
||||
FMC_IN.VAL1.Min: cap_voltage_fzp_y_min
|
||||
FMC_IN.VAL1.Max: cap_voltage_fzp_y_max
|
||||
FMC_IN.VAL1.Mean: cap_voltage_fzp_y_mean
|
||||
FMC_IN.VAL2.Min: cap_voltage_fzp_x_min
|
||||
FMC_IN.VAL2.Max: cap_voltage_fzp_x_max
|
||||
FMC_IN.VAL2.Mean: cap_voltage_fzp_x_mean
|
||||
INENC1.VAL.Max: interf_st_fzp_y_max
|
||||
INENC1.VAL.Mean: interf_st_fzp_y_mean
|
||||
INENC1.VAL.Min: interf_st_fzp_y_min
|
||||
INENC2.VAL.Max: interf_st_fzp_x_max
|
||||
INENC2.VAL.Mean: interf_st_fzp_x_mean
|
||||
INENC2.VAL.Min: interf_st_fzp_x_min
|
||||
INENC3.VAL.Max: interf_st_rotz_max
|
||||
INENC3.VAL.Mean: interf_st_rotz_mean
|
||||
INENC3.VAL.Min: interf_st_rotz_min
|
||||
INENC4.VAL.Max: interf_st_rotx_max
|
||||
INENC4.VAL.Mean: interf_st_rotx_mean
|
||||
INENC4.VAL.Min: interf_st_rotx_min
|
||||
FMC_IN.VAL1.Value: cap_voltage_fzp_y
|
||||
FMC_IN.VAL2.Value: cap_voltage_fzp_x
|
||||
INENC1.VAL.Value: interf_st_fzp_y
|
||||
INENC2.VAL.Value: interf_st_fzp_x
|
||||
INENC3.VAL.Value: interf_st_rotz
|
||||
INENC4.VAL.Value: interf_st_rotx
|
||||
PCAP.GATE_DURATION.Value: pcap_gate_duration_value
|
||||
# Free-running mode (raw_stream_mode: true) signals. TTLIN1 (detector trigger) feeds
|
||||
# both blocks below - confirmed 2026-09-15 against the omny-panda hardware, see
|
||||
# docs/developer/panda_box_free_running_setup.md. PCAP.BITS0 is a shared 32-bit word;
|
||||
# PandaBoxOMNY masks it to bit 0 (TTLIN1.VAL) before publishing gate_detector_active.
|
||||
# TTLIN1 (detector trigger) feeds both blocks below - confirmed 2026-09-15 against the
|
||||
# omny-panda hardware, see docs/developer/panda_box_free_running_setup.md. PCAP.BITS0
|
||||
# is a shared 32-bit word; PandaBoxOMNY masks it to bit 0 (TTLIN1.VAL) before
|
||||
# publishing gate_detector_active. COUNTER1 counts TTLIN1's falling edge, i.e. one
|
||||
# increment per completed exposure; it also doubles as the on_complete signal.
|
||||
PCAP.BITS0.Value: gate_detector_active
|
||||
COUNTER1.OUT.Value: frame_counter
|
||||
enabled: true
|
||||
|
||||
@@ -31,9 +31,12 @@ class PandaBoxOMNY(PandaBox):
|
||||
Incoming samples are coalesced client-side (by row count or time, whichever comes
|
||||
first) before being published, to keep the message rate to the BEC message bus
|
||||
bounded regardless of how the PandaBox itself batches network frames. Completion is
|
||||
checked by waiting for the hardware-reported captured-frame count to stop increasing,
|
||||
since an exact expected sample count can't be predicted client-side for continuous
|
||||
capture.
|
||||
checked against the frame counter (COUNTER1, aliased to ``frame_counter``), which
|
||||
increments on the detector-trigger's falling edge, reaching the expected
|
||||
``num_points * frames_per_trigger`` count once the last exposure finishes.
|
||||
``*PCAP.CAPTURED?`` can't be used for this: on this layout PCAP's gate/trig are driven
|
||||
continuously by an internal clock, so it never naturally stops incrementing while
|
||||
armed.
|
||||
"""
|
||||
|
||||
# PCAP.BITS0 is a shared 32-bit capture word; other captured bit_out signals (e.g. other
|
||||
@@ -84,7 +87,6 @@ class PandaBoxOMNY(PandaBox):
|
||||
super().on_init()
|
||||
self._acquisition_group = "burst"
|
||||
self._timeout_on_completed = 10
|
||||
self._settle_timeout_in_s = 0.2
|
||||
self.scan_parameters: ScanServerScanInfo | None = None
|
||||
|
||||
def on_stage(self):
|
||||
@@ -152,38 +154,45 @@ class PandaBoxOMNY(PandaBox):
|
||||
return status_captured
|
||||
|
||||
def _on_complete_free_running(self):
|
||||
"""Completion check for continuous free-running capture: wait until the
|
||||
hardware-reported captured-frame count stops increasing (settles), since the exact
|
||||
expected sample count can't be predicted client-side for continuous capture at an
|
||||
arbitrary rate. The frame_counter signal remains the authoritative record of total
|
||||
frames captured for later completeness verification.
|
||||
"""Completion check for continuous free-running capture: wait for the frame counter
|
||||
(COUNTER1, aliased to frame_counter) to reach the exact expected number of frames.
|
||||
|
||||
*PCAP.CAPTURED? can't be used here, unlike _on_complete_burst: on this layout PCAP's
|
||||
gate/trig are driven continuously by an internal clock (CLOCK1), so the captured
|
||||
count never naturally stops increasing while PCAP stays armed -- there's nothing to
|
||||
settle. COUNTER1 instead increments on the detector-trigger's falling edge, i.e. once
|
||||
per completed exposure, so it reaches num_points * frames_per_trigger -- the same
|
||||
target _on_complete_burst waits for -- exactly when the last exposure finishes. See
|
||||
docs/developer/panda_box_free_running_setup.md.
|
||||
"""
|
||||
|
||||
def _check_capture_settled():
|
||||
captured = -1
|
||||
last_change = time.monotonic()
|
||||
def _check_frame_count_complete():
|
||||
counted = 0
|
||||
start_time = time.monotonic()
|
||||
try:
|
||||
while True:
|
||||
ret = self.send_raw("*PCAP.CAPTURED?")
|
||||
new_captured = int(ret[0].split("=")[-1])
|
||||
now = time.monotonic()
|
||||
if new_captured != captured:
|
||||
captured = new_captured
|
||||
last_change = now
|
||||
elif now - last_change > self._settle_timeout_in_s:
|
||||
break
|
||||
if now - start_time > self._timeout_on_completed:
|
||||
raise TimeoutError(
|
||||
f"Pandabox {self.name} capture did not settle after {self._timeout_on_completed}s, "
|
||||
f"last captured count: {captured}."
|
||||
)
|
||||
expected_frames = int(
|
||||
self.scan_parameters.num_points * self.scan_parameters.frames_per_trigger
|
||||
)
|
||||
while counted < expected_frames:
|
||||
ret = self.send_raw("COUNTER1.OUT?")
|
||||
counted = int(float(ret[0].split("=")[-1]))
|
||||
time.sleep(0.01)
|
||||
if (time.monotonic() - start_time) > self._timeout_on_completed / 2:
|
||||
logger.info(
|
||||
f"Waiting for frame_counter on device {self.name} to complete: "
|
||||
f"counted {counted}/{expected_frames} frames."
|
||||
)
|
||||
if (time.monotonic() - start_time) > self._timeout_on_completed:
|
||||
raise TimeoutError(
|
||||
f"Pandabox {self.name} did not complete after "
|
||||
f"{self._timeout_on_completed}s with frames counted "
|
||||
f"{counted}/{expected_frames}"
|
||||
)
|
||||
finally:
|
||||
self._flush_raw_stream_buffer()
|
||||
self._disarm()
|
||||
|
||||
status_captured = self.task_handler.submit_task(_check_capture_settled, run=True)
|
||||
status_captured = self.task_handler.submit_task(_check_frame_count_complete, run=True)
|
||||
self.cancel_on_stop(status_captured)
|
||||
return status_captured
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ initial testing on 2026-09-15, see the setup doc for the current rate):
|
||||
|---|---|---|
|
||||
| `cap_voltage_fzp_y`/`cap_voltage_fzp_x` etc. (raw analog/encoder value) | `FMC_IN.VAL1.Value` / `FMC_IN.VAL2.Value` / `INENC1`-`4.VAL.Value` | The instantaneous raw sample at this capture tick, replacing the Mode A aggregate (Mean/Min/Max). All six channels (both FMC analog inputs and all four encoders) are switched to raw capture together on this layout — not a subset. |
|
||||
| `gate_detector_active` | `PCAP.BITS0.Value`, bit 0 (`TTLIN1.VAL`), masked in software — see setup doc | The detector-trigger signal, sampled at this same tick: `1` while a detector trigger is active, `0` otherwise. `PCAP.BITS0` is a shared 32-bit word; `PandaBoxOMNY` masks it down to bit 0 before this reaches the HDF5 file (see `_GATE_BIT_OFFSET` in `panda_box_omny.py`) — the raw word itself is not a clean 0/1. This is what a future reconstruction step would use to delimit which raw samples belong to which detector-gate window. |
|
||||
| `frame_counter` | `COUNTER1.OUT.Value`, free-running off `TTLIN1.VAL` (i.e. increments once per detector trigger pulse, not once per PCAP capture tick as originally guessed here) | Monotonically incrementing hardware counter. Used to verify data completeness after acquisition: a gap-free, strictly increasing sequence means no detector triggers were missed between the PandA and the HDF5 file; a gap indicates lost data (e.g. from the Redis stream's `MAXLEN` trimming if the file writer fell behind — see the acquisition plan's data-path notes). Because it counts detector triggers rather than capture ticks, it verifies detector-frame completeness directly rather than raw-sample completeness. |
|
||||
| `frame_counter` | `COUNTER1.OUT.Value`, triggered off `TTLIN1.VAL`'s falling edge (i.e. increments once per *completed* detector exposure, not once per PCAP capture tick as originally guessed here) | Monotonically incrementing hardware counter. Doubles as the completion signal for `on_complete` (`PandaBoxOMNY._on_complete_free_running`, `panda_box_omny.py`) — waits for it to reach `num_points * frames_per_trigger`, since `*PCAP.CAPTURED?` free-runs continuously and never naturally stops while armed. Also the post-hoc data-completeness record: a gap-free, strictly increasing sequence means no detector exposures were missed between the PandA and the HDF5 file; a gap indicates lost data (e.g. from the Redis stream's `MAXLEN` trimming if the file writer fell behind — see the acquisition plan's data-path notes). Because it counts completed exposures rather than capture ticks, it verifies detector-frame completeness directly rather than raw-sample completeness. |
|
||||
| `PCAP.TS_TRIG.Value` (existing) | `PCAP.TS_TRIG` | Absolute/relative timestamp already captured today; usable for time-alignment against other detectors' data during future reconstruction. |
|
||||
| `PCAP.GATE_DURATION.Value` (existing, aliased as `pcap_gate_duration_value`) | `PCAP.GATE_DURATION` | Existing field, retained; less meaningful once the gate is held open continuously for the whole burst window rather than pulsed per point (see setup doc, Mode B gate/arm row) — re-evaluate whether this still needs to be captured now that real hardware testing has started. |
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ the end) before that mode can be used.
|
||||
| Gate/arm timing | Pulsed per point / sub-frame (rate = scan rate × `frames_per_trigger`) | PCAP held open continuously for the burst window, free-running at `CLOCK1`'s configured rate (started at **100 Hz** for initial testing on 2026-09-15; will be ramped up as testing progresses) |
|
||||
| `_acquisition_group` (BEC async metadata) | `fly` / `monitored` / `burst`, chosen from `scan_type`/`frames_per_trigger` | `free_running` |
|
||||
| Message publishing | One `.data.put()` per PandA network frame, unchanged | Coalesced client-side: flushed every `raw_stream_flush_row_count` rows or `raw_stream_flush_interval` seconds, whichever comes first (mitigates Redis/HDF5 message-rate risk — see the acquisition plan's data-path notes) |
|
||||
| Completion check (`on_complete`) | Exact count: waits for `*PCAP.CAPTURED?` to reach `num_points * frames_per_trigger` | Settle-based: waits for `*PCAP.CAPTURED?` to stop changing for `_settle_timeout_in_s`, since an exact expected sample count can't be predicted client-side for continuous capture |
|
||||
| Data completeness verification | Implicit in the exact-count completion check | The `frame_counter` signal (Mode B only) — a monotonically incrementing hardware counter — is the record to check for gaps/drops after the fact |
|
||||
| Completion check (`on_complete`) | Exact count: waits for `*PCAP.CAPTURED?` to reach `num_points * frames_per_trigger` | Exact count: waits for `COUNTER1.OUT?` (`frame_counter`) to reach `num_points * frames_per_trigger`. `*PCAP.CAPTURED?` can't be used here — `CLOCK1` drives `PCAP.gate`/`PCAP.trig` continuously (see "Continuous gate/arm" below), so the captured count never naturally stops increasing while armed; `COUNTER1` instead counts completed detector exposures directly (it's clocked off the detector-trigger's falling edge), so it reaches the expected total exactly when the last exposure finishes |
|
||||
| Data completeness verification | Implicit in the exact-count completion check | Same mechanism as Mode A: `frame_counter` (`COUNTER1`) is both the completion signal and the post-hoc completeness record — a gap in an otherwise-monotonic sequence in the HDF5 data means dropped rows even though the expected total was reached |
|
||||
|
||||
Both modes are implemented in the same `PandaBoxOMNY` class; `raw_stream_mode`
|
||||
defaults to `false` so any device config that doesn't set it keeps today's
|
||||
@@ -82,11 +82,14 @@ layout can be restored unambiguously (see `ptycho_flomni.yaml`):
|
||||
shares `BITS0`. Re-run the query above (read-only, safe against live
|
||||
hardware) if the PandA layout is ever rebuilt, since bit assignment is
|
||||
fixed by the FPGA build and not guaranteed stable across rebuilds.
|
||||
- **Frame counter**: `COUNTER1`, free-running off `TTLIN1.VAL` as its
|
||||
`trig` input (see layout below) — i.e. it increments once per detector
|
||||
trigger pulse, not once per PCAP capture tick as originally guessed here.
|
||||
Captured with `CAPTURE=Value`; this is the data-completeness signal
|
||||
(`frame_counter` in `signal_alias`, see below).
|
||||
- **Frame counter**: `COUNTER1`, triggered off `TTLIN1.VAL`'s **falling
|
||||
edge** (see layout below) — i.e. it increments once per *completed*
|
||||
detector exposure, not once per PCAP capture tick as originally guessed
|
||||
here. Captured with `CAPTURE=Value`; this is both the data-completeness
|
||||
signal and the completion-detection signal (`frame_counter` in
|
||||
`signal_alias`, see below, and "Completion check" in the mode-comparison
|
||||
table above) — once the last expected exposure's trigger pulse has fallen,
|
||||
`COUNTER1.OUT` reaches `num_points * frames_per_trigger` exactly.
|
||||
- **Raw analog/position capture**: `FMC_IN.VAL1`, `FMC_IN.VAL2` and all four
|
||||
`INENC1`-`4.VAL` are switched from aggregate capture to `CAPTURE=Value`
|
||||
on this layout (confirmed 2026-09-15) — i.e. every analog/encoder channel
|
||||
@@ -102,7 +105,8 @@ layout can be restored unambiguously (see `ptycho_flomni.yaml`):
|
||||
|
||||
```
|
||||
TTLIN1 (TTL input 1, detector trigger)
|
||||
├──▶ COUNTER1.trig (Up/Down pulse counter) ──▶ COUNTER1.OUT = frame_counter (CAPTURE=Value)
|
||||
├──▶ COUNTER1.trig, falling edge (Up/Down pulse counter) ──▶ COUNTER1.OUT = frame_counter (CAPTURE=Value)
|
||||
│ = completion signal too: reaches num_points * frames_per_trigger when the last exposure finishes
|
||||
└──▶ captured into PCAP.BITS0 bit 0 ──▶ masked in software = gate_detector_active
|
||||
|
||||
CLOCK1 (enabled by constant ONE) ──▶ PCAP.gate, PCAP.trig (continuous arm/capture)
|
||||
|
||||
@@ -234,12 +234,13 @@ Example:
|
||||
`scans.flomni_fermat_scan(fovx=20, fovy=25, cenx=0.02, ceny=0, zshift=0, angle=0, step=0.5, exp_time=0.01, frames_per_trigger=1)`
|
||||
|
||||
`frames_per_trigger` controls burst acquisition for detectors generally.
|
||||
Separately, the `omny_panda` PandABox device has its own `raw_stream_mode`
|
||||
device-config flag (`csaxs_bec/device_configs/ptycho_flomni.yaml`) that
|
||||
switches it between the default per-gate averaged acquisition and a
|
||||
continuous, high-rate raw-sample acquisition mode — see
|
||||
`docs/developer/panda_box_free_running_setup.md` for what each mode captures
|
||||
and how to enable it.
|
||||
Separately, the OMNY PandABox is configured as one of two distinct devices in
|
||||
`csaxs_bec/device_configs/ptycho_flomni.yaml` — `omny_panda` (per-gate
|
||||
averaged acquisition, currently kept as a commented reference) or
|
||||
`omny_panda_continuous` (continuous, high-rate raw-sample acquisition) —
|
||||
because the two modes require different PandA hardware layouts and can't run
|
||||
simultaneously. See `docs/developer/panda_box_free_running_setup.md` for what
|
||||
each mode captures and how to switch between them.
|
||||
|
||||
#### Overview of the alignment steps
|
||||
|
||||
|
||||
@@ -339,12 +339,13 @@ Example:
|
||||
`scans.omny_fermat_scan(fovx=20, fovy=25, cenx=0.02, ceny=0, zshift=0, angle=0, step=0.5, exp_time=0.01, frames_per_trigger=1, readout_time=0)`
|
||||
|
||||
`frames_per_trigger` controls burst acquisition for detectors generally.
|
||||
Separately, the `omny_panda` PandABox device has its own `raw_stream_mode`
|
||||
device-config flag (`csaxs_bec/device_configs/ptycho_flomni.yaml`) that
|
||||
switches it between the default per-gate averaged acquisition and a
|
||||
continuous, high-rate raw-sample acquisition mode — see
|
||||
`docs/developer/panda_box_free_running_setup.md` for what each mode captures
|
||||
and how to enable it.
|
||||
Separately, the OMNY PandABox is configured as one of two distinct devices in
|
||||
`csaxs_bec/device_configs/ptycho_flomni.yaml` — `omny_panda` (per-gate
|
||||
averaged acquisition, currently kept as a commented reference) or
|
||||
`omny_panda_continuous` (continuous, high-rate raw-sample acquisition) —
|
||||
because the two modes require different PandA hardware layouts and can't run
|
||||
simultaneously. See `docs/developer/panda_box_free_running_setup.md` for what
|
||||
each mode captures and how to switch between them.
|
||||
|
||||
#### Overview of the alignment steps
|
||||
|
||||
|
||||
@@ -247,27 +247,20 @@ def test_panda_omny_unstage_flushes_pending_raw_stream_data(panda_omny_raw_strea
|
||||
mock_put.assert_called_once()
|
||||
|
||||
|
||||
def test_panda_omny_complete_free_running_settles(panda_omny_raw_stream):
|
||||
"""Completion in free-running mode waits for the captured count to stop increasing,
|
||||
rather than an exact expected count."""
|
||||
def test_panda_omny_complete_free_running_waits_for_frame_counter(panda_omny_raw_stream):
|
||||
"""Completion in free-running mode waits for COUNTER1 (frame_counter) to reach the exact
|
||||
expected frame count -- PCAP.CAPTURED can't be used since it free-runs continuously off
|
||||
CLOCK1 and never naturally stops increasing while armed."""
|
||||
dev = panda_omny_raw_stream
|
||||
dev.scan_info.msg.info["num_points"] = 1
|
||||
dev.scan_info.msg.info["frames_per_trigger"] = 1
|
||||
dev.scan_parameters = fetch_scan_info(dev.scan_info)
|
||||
dev._timeout_on_completed = 5
|
||||
dev._settle_timeout_in_s = 0.1
|
||||
|
||||
call_count = {"n": 0}
|
||||
|
||||
def _send_raw(*args, **kwargs):
|
||||
# Ramp up for the first 3 calls, then plateau indefinitely at "=2" so the
|
||||
# settle-timeout branch (rather than running out of a fixed side_effect list) is
|
||||
# what ends the loop.
|
||||
call_count["n"] += 1
|
||||
return [f"={min(call_count['n'] - 1, 2)}"]
|
||||
|
||||
with (
|
||||
mock.patch.object(dev, "send_raw", side_effect=_send_raw),
|
||||
mock.patch.object(
|
||||
dev, "send_raw", side_effect=[["=0"], ["=0"], ["=1"]]
|
||||
) as mock_send_raw,
|
||||
mock.patch.object(dev, "_disarm", return_value=None) as mock_disarm,
|
||||
mock.patch.object(dev, "_flush_raw_stream_buffer") as mock_flush,
|
||||
):
|
||||
@@ -277,25 +270,28 @@ def test_panda_omny_complete_free_running_settles(panda_omny_raw_stream):
|
||||
assert status.success is True
|
||||
mock_disarm.assert_called_once()
|
||||
mock_flush.assert_called_once()
|
||||
assert mock_send_raw.call_args.args[0] == "COUNTER1.OUT?"
|
||||
|
||||
|
||||
def test_panda_omny_complete_free_running_timeout(panda_omny_raw_stream):
|
||||
"""If the captured count never settles, the overall timeout must still fire."""
|
||||
"""If the frame count never reaches the expected total, the overall timeout must still
|
||||
fire."""
|
||||
dev = panda_omny_raw_stream
|
||||
dev.scan_info.msg.info["num_points"] = 1
|
||||
dev.scan_info.msg.info["frames_per_trigger"] = 1
|
||||
dev.scan_parameters = fetch_scan_info(dev.scan_info)
|
||||
dev._timeout_on_completed = 0.3
|
||||
dev._settle_timeout_in_s = 10 # never settles within the overall timeout
|
||||
|
||||
with (
|
||||
mock.patch.object(dev, "send_raw", side_effect=lambda *a, **k: ["=0"]),
|
||||
mock.patch.object(dev, "_disarm", return_value=None) as mock_disarm,
|
||||
mock.patch.object(dev, "_flush_raw_stream_buffer") as mock_flush,
|
||||
):
|
||||
status = dev.on_complete()
|
||||
with pytest.raises(TimeoutError):
|
||||
status.wait(timeout=4)
|
||||
mock_disarm.assert_called_once()
|
||||
mock_flush.assert_called_once()
|
||||
|
||||
|
||||
def test_panda_omny_raw_stream_signal_alias(panda_omny_raw_stream):
|
||||
|
||||
Reference in new issue
Block a user