CI for mx_bec / e2e tests with pxi_bec (push) Failing after 1m4s
CI for mx_bec / e2e tests with pxii_bec (push) Failing after 1m17s
CI for mx_bec / e2e tests with pxiii_bec (push) Failing after 1m17s
CI for mx_bec / unit tests with pxiii_bec (push) Failing after 1m47s
CI for mx_bec / unit tests with pxii_bec (push) Failing after 1m55s
CI for mx_bec / unit tests with pxi_bec (push) Failing after 1m55s
# MX task architecture: AareBec service, tasks, queues and widgets Brings the AareBec task architecture into `mx_bec` ## Components - **AareBec service** (`service.py`, `main.py`): custom BEC client that owns the task queue, the actor manager and the external API clients. - **Task framework** (`tasks/core.py`): `@task` decorator and `TaskManager` with `Server` and `Client` roles. The server runs tasks one at a time and pauses the queue on failure; clients request tasks over Redis. `MxTaskQueue` works off the execution list. - **MX tasks** (`tasks/mx_tasks.py`): sample mount, optical centering, raster and multi-raster scans, X-ray centering, rotation data collection, beamline state change and cleanup. - **Automation actors** (`actors/`, `actor_manager.py`): actors that react to sequence milestones and queue the next task, each switchable through a Redis config value. - **External clients**: `AareDaq` REST client (Kerberos token, baton handling), `JFJoch` raster client, `OpticalPrediction` (AareLC). The `AareDaq` client is to be replaced with native BEC implementations. - **Devices** (`devices/`): Aerotech, Smargon (smargopolo), HTTP device base, simulated stages and sample changer, plus a demo config. - **Widgets** (`bec_widgets/widgets/aare_bec/`): actor config, task queue, task panel, sample queue and sample spreadsheet display - for development and admin use. - **Endpoints and messages** for task requests, the execution list, queue-change notifications and sequence state. ## Notes - BEC-driven optical centering was removed; it will be reimplemented from scratch. - The sample spreadsheet is copied between Redis instances by a hack in the service, to be replaced by the sample database connection module. - CI installs from the MX Gitea package index (`jfjoch_client` is pre-release only). --------- Co-authored-by: x10sa <x10sa@psi.ch> Reviewed-on: #2 Co-authored-by: David Perl <david.perl@psi.ch>
72 lines
2.2 KiB
Python
72 lines
2.2 KiB
Python
import pytest
|
|
from bec_server.device_server.tests.utils import DMMock
|
|
from ophyd_devices.interfaces.base_classes.psi_device_base import DeviceStoppedError
|
|
|
|
from mx_bec.devices import RobotState, SimAerotechStage, SimGoniometer, SimSampleChanger
|
|
|
|
|
|
@pytest.fixture
|
|
def robot():
|
|
dev = SimSampleChanger(name="robot", mount_time=0.05, device_manager=DMMock())
|
|
dev.on_connected()
|
|
yield dev
|
|
dev.destroy()
|
|
|
|
|
|
@pytest.mark.parametrize("cls", [SimAerotechStage, SimGoniometer])
|
|
def test_stage_reads_all_axes(cls):
|
|
stage = cls(name="stage")
|
|
readings = stage.read()
|
|
for axis in cls.component_names:
|
|
assert f"stage_{axis}" in readings
|
|
stage.destroy()
|
|
|
|
|
|
def test_rotation_axis_is_unbounded():
|
|
stage = SimAerotechStage(name="aerotech")
|
|
stage.u.delay = 0
|
|
stage.u.move(720).wait(timeout=1)
|
|
assert stage.u.position == pytest.approx(720, abs=stage.u.tolerance.get())
|
|
stage.destroy()
|
|
|
|
|
|
def test_robot_mount_and_unmount(robot):
|
|
assert robot.mount_time.get() == 0.05
|
|
robot.mount(puck=2, position=7).wait(timeout=1)
|
|
assert robot.read()["robot_sample_mounted"]["value"] == 1
|
|
assert robot.mounted_puck.get() == 2
|
|
assert robot.mounted_position.get() == 7
|
|
assert robot.state.get() == RobotState.IDLE
|
|
|
|
robot.unmount().wait(timeout=1)
|
|
assert robot.sample_mounted.get() == 0
|
|
assert robot.mounted_puck.get() == 0
|
|
|
|
|
|
def test_robot_is_busy_while_mounting(robot):
|
|
status = robot.mount(puck=1, position=1)
|
|
assert robot.state.get() == RobotState.BUSY
|
|
with pytest.raises(RuntimeError, match="not idle"):
|
|
robot.mount(puck=1, position=2)
|
|
status.wait(timeout=1)
|
|
assert robot.mounted_position.get() == 1
|
|
|
|
|
|
def test_robot_refuses_with_door_open(robot):
|
|
robot.door_closed.put(0)
|
|
with pytest.raises(RuntimeError, match="door"):
|
|
robot.mount(puck=1, position=1)
|
|
assert robot.state.get() == RobotState.ERROR
|
|
robot.reset()
|
|
assert robot.state.get() == RobotState.IDLE
|
|
|
|
|
|
def test_robot_stop_aborts_mount(robot):
|
|
robot.mount_time.put(5)
|
|
status = robot.mount(puck=1, position=1)
|
|
robot.stop()
|
|
with pytest.raises(DeviceStoppedError):
|
|
status.wait(timeout=1)
|
|
assert robot.sample_mounted.get() == 0
|
|
assert robot.state.get() == RobotState.IDLE
|