LamNI feedback_enable_with_reset: move lsamx and lsamy at the same time
CI for csaxs_bec / test (push) Failing after 1s
CI for csaxs_bec / test (push) Failing after 1s
The coarse stages went to their centers one after the other (move(wait=True) each). Both moves are now started with wait=False and then waited for; Ctrl-C stops both axes; J1 only after both are done. The same parallel move on this Galil is already used by umv(dev.lsamx, ..., dev.lsamy, ...) in x_ray_eye_align. Requested by Mirko 2026-11-19. Test: tests/tests_devices/test_rt_lamni_reset.py (order of moves / waits / J1, Ctrl-C). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M8zoDygkWk6LupmHh3tyET
This commit is contained in:
1 parent
ea0ade0715
commit
ba4e78e263
2 files changed
+93
-2
No files matched your search
@@ -361,8 +361,19 @@ class RtLamniController(Controller):
|
||||
raise RuntimeError("lsamy center is not defined")
|
||||
lsamx_center = lsamx_user_params.get("center")
|
||||
lsamy_center = lsamy_user_params.get("center")
|
||||
self.device_manager.devices.lsamx.obj.move(lsamx_center, wait=True)
|
||||
self.device_manager.devices.lsamy.obj.move(lsamy_center, wait=True)
|
||||
# lsamx and lsamy move at the same time (was one after the other; Mirko 2026-11-19).
|
||||
# The same parallel move is used by umv(dev.lsamx, ..., dev.lsamy, ...) in x_ray_eye_align.
|
||||
lsamx = self.device_manager.devices.lsamx.obj
|
||||
lsamy = self.device_manager.devices.lsamy.obj
|
||||
status_x = lsamx.move(lsamx_center, wait=False)
|
||||
status_y = lsamy.move(lsamy_center, wait=False)
|
||||
try:
|
||||
status_x.wait()
|
||||
status_y.wait()
|
||||
except KeyboardInterrupt:
|
||||
lsamx.stop()
|
||||
lsamy.stop()
|
||||
raise
|
||||
self.socket_put("J1")
|
||||
|
||||
_waitforfeedbackctr = 0
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
from ophyd_devices.tests.utils import SocketMock
|
||||
|
||||
from csaxs_bec.devices.omny.rt.rt_lamni_ophyd import RtLamniController
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def rt_lamni():
|
||||
RtLamniController._reset_controller()
|
||||
rt = RtLamniController(
|
||||
name="rt_lamni",
|
||||
socket_cls=SocketMock,
|
||||
socket_host="localhost",
|
||||
socket_port=3333,
|
||||
device_manager=mock.MagicMock(),
|
||||
)
|
||||
yield rt
|
||||
RtLamniController._reset_controller()
|
||||
|
||||
|
||||
def _prepare(rt):
|
||||
"""Coarse stages with a center, lsamrot at 0, Galil ready; returns a mock recording the call order."""
|
||||
devices = rt.device_manager.devices
|
||||
devices.lsamrot.obj.readback.get.return_value = 0.0
|
||||
devices.lsamx.user_parameter = {"center": 1.5}
|
||||
devices.lsamy.user_parameter = {"center": -2.5}
|
||||
devices.lsamx.obj.controller.lgalil_is_air_off_and_orchestra_enabled.return_value = 1
|
||||
order = mock.MagicMock()
|
||||
status_x, status_y = mock.MagicMock(name="status_x"), mock.MagicMock(name="status_y")
|
||||
devices.lsamx.obj.move.return_value = status_x
|
||||
devices.lsamy.obj.move.return_value = status_y
|
||||
order.attach_mock(devices.lsamx.obj.move, "move_x")
|
||||
order.attach_mock(devices.lsamy.obj.move, "move_y")
|
||||
order.attach_mock(status_x.wait, "wait_x")
|
||||
order.attach_mock(status_y.wait, "wait_y")
|
||||
return order
|
||||
|
||||
|
||||
def test_feedback_enable_with_reset_moves_lsamx_lsamy_together(rt_lamni):
|
||||
order = _prepare(rt_lamni)
|
||||
with (
|
||||
mock.patch.object(rt_lamni, "feedback_status_angle_lamni", return_value=True),
|
||||
mock.patch.object(rt_lamni, "feedback_disable"),
|
||||
mock.patch.object(rt_lamni, "clear_trajectory_generator"),
|
||||
mock.patch.object(rt_lamni, "get_axis_by_name"),
|
||||
mock.patch.object(rt_lamni, "set_device_read_write"),
|
||||
mock.patch.object(rt_lamni, "socket_put_and_receive", return_value="0,0,0"),
|
||||
mock.patch.object(rt_lamni, "socket_put") as socket_put,
|
||||
mock.patch("time.sleep"),
|
||||
):
|
||||
order.attach_mock(socket_put, "socket_put")
|
||||
rt_lamni.feedback_enable_with_reset()
|
||||
|
||||
names = [c[0] for c in order.mock_calls if c[0] in ("move_x", "move_y", "wait_x", "wait_y")
|
||||
or (c[0] == "socket_put" and c.args == ("J1",))]
|
||||
# both moves are started (without waiting) before the first wait; J1 only after both are done
|
||||
assert names == ["move_x", "move_y", "wait_x", "wait_y", "socket_put"]
|
||||
assert order.move_x.call_args == mock.call(1.5, wait=False)
|
||||
assert order.move_y.call_args == mock.call(-2.5, wait=False)
|
||||
|
||||
|
||||
def test_feedback_enable_with_reset_ctrl_c_stops_both_axes(rt_lamni):
|
||||
_prepare(rt_lamni)
|
||||
devices = rt_lamni.device_manager.devices
|
||||
devices.lsamx.obj.move.return_value.wait.side_effect = KeyboardInterrupt
|
||||
with (
|
||||
mock.patch.object(rt_lamni, "feedback_status_angle_lamni", return_value=True),
|
||||
mock.patch.object(rt_lamni, "feedback_disable"),
|
||||
mock.patch.object(rt_lamni, "clear_trajectory_generator"),
|
||||
mock.patch.object(rt_lamni, "get_axis_by_name"),
|
||||
mock.patch.object(rt_lamni, "socket_put") as socket_put,
|
||||
mock.patch("time.sleep"),
|
||||
pytest.raises(KeyboardInterrupt),
|
||||
):
|
||||
rt_lamni.feedback_enable_with_reset()
|
||||
devices.lsamx.obj.stop.assert_called_once()
|
||||
devices.lsamy.obj.stop.assert_called_once()
|
||||
assert mock.call("J1") not in socket_put.mock_calls
|
||||
Reference in new issue
Block a user