- lamni/omny fermat scan: default exp_time 0.1, drop unused readout_time (devices already fall back to their own configured readout time) - sim_lamni: refuse the sd scan start and abort a running scan while the interferometer feedback loop is off; add tests - simulated_lamni.yaml: lsamrot sim_velocity 48 (4x hw) - lamni_optics_mixin / ptycho_lamni.yaml: commented-out draft for moving the fttrz flight tube in leye_out/leye_in, pending commissioned positions Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016gUjUT2xCNpnBQkThn3CqP
62 lines
1.7 KiB
Python
62 lines
1.7 KiB
Python
"""The simulated LamNI RT server must not run scans while the feedback loop is off."""
|
|
|
|
import time
|
|
|
|
import pytest
|
|
|
|
from csaxs_bec.devices.sim.sim_lamni import SimRtLamniSocket, SimRtLamniState
|
|
|
|
N_POSITIONS = 10
|
|
|
|
|
|
@pytest.fixture
|
|
def state():
|
|
state = SimRtLamniState()
|
|
state.point_dwell_s = 0.02
|
|
for ii in range(N_POSITIONS):
|
|
state.add_scan_position([float(ii), float(ii)])
|
|
yield state
|
|
state.clear_scan()
|
|
|
|
|
|
def _wait_for_scan_end(state, timeout=5):
|
|
deadline = time.time() + timeout
|
|
while state.scan_mode != 0 and time.time() < deadline:
|
|
time.sleep(0.005)
|
|
assert state.scan_mode == 0
|
|
|
|
|
|
def test_scan_not_started_without_feedback(state):
|
|
state.feedback_running = False
|
|
assert state.start_scan() == N_POSITIONS
|
|
assert state.scan_mode == 0
|
|
assert state.scan_current == 0
|
|
assert state._scan_thread is None
|
|
|
|
|
|
def test_scan_runs_with_feedback(state):
|
|
state.feedback_running = True
|
|
state.start_scan()
|
|
_wait_for_scan_end(state)
|
|
assert state.scan_current == N_POSITIONS
|
|
|
|
|
|
def test_scan_aborts_when_feedback_drops(state):
|
|
state.feedback_running = True
|
|
state.start_scan()
|
|
time.sleep(3.5 * state.point_dwell_s)
|
|
state.feedback_running = False
|
|
_wait_for_scan_end(state)
|
|
assert 0 < state.scan_current < N_POSITIONS
|
|
|
|
|
|
def test_sd_command_reply_without_feedback(state):
|
|
socket = SimRtLamniSocket.__new__(SimRtLamniSocket)
|
|
socket.state = state
|
|
state.feedback_running = False
|
|
assert "not started" in socket.handle_command("sd")
|
|
assert state.scan_mode == 0
|
|
state.feedback_running = True
|
|
assert "Scan mode started" in socket.handle_command("sd")
|
|
_wait_for_scan_end(state)
|