diff --git a/pyproject.toml b/pyproject.toml index c46287b53..bc6e0dc41 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ dependencies = [ "ophyd == 1.9.0", "ophyd-async >= 0.8a5", "bluesky >= 1.13.0a4", - "dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@main", + "dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@fcd581d6e5cda2bb78c67893c856ec672581b8ff", ] diff --git a/src/mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py b/src/mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py index dbdcd6b19..ac0d24509 100644 --- a/src/mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py +++ b/src/mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py @@ -144,6 +144,14 @@ def run_grid_detection_plan( parameters.box_size_um, ) + if parameters.selected_aperture: + # Start moving the aperture/scatterguard into position without moving it in + yield from bps.abs_set( + composite.aperture_scatterguard.aperture_outside_beam, + parameters.selected_aperture, + group=CONST.WAIT.GRID_READY_FOR_DC, + ) + yield from run_grid_detection_plan( oav_params, snapshot_template, diff --git a/src/mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py b/src/mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py index e214f6ee5..bf1aea872 100644 --- a/src/mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py +++ b/src/mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py @@ -3,7 +3,7 @@ from bluesky import plan_stubs as bps from bluesky.utils import MsgGenerator -from dodal.devices.aperturescatterguard import ApertureScatterguard, ApertureValue +from dodal.devices.aperturescatterguard import ApertureScatterguard from dodal.devices.backlight import Backlight, BacklightPosition from dodal.devices.oav.oav_detector import OAV from dodal.devices.oav.oav_parameters import OAVParameters @@ -33,22 +33,16 @@ def setup_beamline_for_OAV( max_vel = yield from bps.rd(smargon.omega.max_velocity) yield from bps.abs_set(smargon.omega.velocity, max_vel, group=group) yield from bps.abs_set(backlight, BacklightPosition.IN, group=group) - yield from bps.abs_set( - aperture_scatterguard, - ApertureValue.ROBOT_LOAD, - group=group, - ) + yield from bps.trigger(aperture_scatterguard.move_out, group=group) def oav_snapshot_plan( composite: OavSnapshotComposite, parameters: WithSnapshot, oav_parameters: OAVParameters, - wait: bool = True, ) -> MsgGenerator: if not parameters.take_snapshots: return - yield from bps.wait(group=CONST.WAIT.READY_FOR_OAV) yield from _setup_oav(composite, parameters, oav_parameters) for omega in parameters.snapshot_omegas_deg or []: yield from _take_oav_snapshot(composite, omega) diff --git a/src/mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py b/src/mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py index 74423743d..e5448eea7 100644 --- a/src/mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py +++ b/src/mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py @@ -10,7 +10,7 @@ import pydantic from blueapi.core import BlueskyContext from bluesky.utils import Msg -from dodal.devices.aperturescatterguard import ApertureScatterguard, ApertureValue +from dodal.devices.aperturescatterguard import ApertureScatterguard from dodal.devices.attenuator import Attenuator from dodal.devices.dcm import DCM from dodal.devices.focusing_mirror import FocusingMirrorWithStripes, MirrorVoltages @@ -94,11 +94,7 @@ def take_robot_snapshots(oav: OAV, webcam: Webcam, directory: Path): def prepare_for_robot_load( aperture_scatterguard: ApertureScatterguard, smargon: Smargon ): - yield from bps.abs_set( - aperture_scatterguard, - ApertureValue.ROBOT_LOAD, - group="prepare_robot_load", - ) + yield from bps.trigger(aperture_scatterguard.move_out, group="prepare_robot_load") yield from bps.mv(smargon.stub_offsets, StubPosition.RESET_TO_ROBOT_LOAD) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809 diff --git a/src/mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py b/src/mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py index 9887847c4..de4aa5dce 100644 --- a/src/mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py +++ b/src/mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py @@ -331,6 +331,13 @@ def _div_by_1000_if_not_none(num: float | None): yield from setup_beamline_for_OAV( composite.smargon, composite.backlight, composite.aperture_scatterguard ) + yield from bps.wait(group=CONST.WAIT.READY_FOR_OAV) + if params.selected_aperture: + yield from bps.abs_set( + composite.aperture_scatterguard.aperture_outside_beam, + params.selected_aperture, + group=CONST.WAIT.ROTATION_READY_FOR_DC, + ) yield from oav_snapshot_plan(composite, params, oav_params) yield from rotation_scan_plan( composite, diff --git a/tests/conftest.py b/tests/conftest.py index 702e507c9..b26c35464 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -559,15 +559,15 @@ def aperture_scatterguard(RE): ): ap_sg = i03.aperture_scatterguard(fake_with_ophyd_sim=True) with ( - patch_async_motor(ap_sg.aperture.x), - patch_async_motor(ap_sg.aperture.y), - patch_async_motor(ap_sg.aperture.z, 2), - patch_async_motor(ap_sg.scatterguard.x), - patch_async_motor(ap_sg.scatterguard.y), + patch_async_motor(ap_sg._aperture.x), + patch_async_motor(ap_sg._aperture.y), + patch_async_motor(ap_sg._aperture.z, 2), + patch_async_motor(ap_sg._scatterguard.x), + patch_async_motor(ap_sg._scatterguard.y), ): RE(bps.abs_set(ap_sg, ApertureValue.SMALL)) - set_mock_value(ap_sg.aperture.small, 1) + set_mock_value(ap_sg._aperture.small, 1) yield ap_sg diff --git a/tests/system_tests/hyperion/external_interaction/conftest.py b/tests/system_tests/hyperion/external_interaction/conftest.py index c7104ea00..e96235b2e 100644 --- a/tests/system_tests/hyperion/external_interaction/conftest.py +++ b/tests/system_tests/hyperion/external_interaction/conftest.py @@ -321,7 +321,9 @@ def fgs_composite_for_fake_zocalo( zocalo_for_fake_zocalo: ZocaloResults, done_status: NullStatus, ) -> FlyScanXRayCentreComposite: - set_mock_value(fake_fgs_composite.aperture_scatterguard.aperture.z.user_setpoint, 2) + set_mock_value( + fake_fgs_composite.aperture_scatterguard._aperture.z.user_setpoint, 2 + ) fake_fgs_composite.eiger.unstage = MagicMock(return_value=done_status) # type: ignore fake_fgs_composite.smargon.stub_offsets.set = MagicMock(return_value=done_status) # type: ignore callback_on_mock_put( diff --git a/tests/unit_tests/hyperion/experiment_plans/test_flyscan_xray_centre_plan.py b/tests/unit_tests/hyperion/experiment_plans/test_flyscan_xray_centre_plan.py index 640f81189..0be8604c6 100644 --- a/tests/unit_tests/hyperion/experiment_plans/test_flyscan_xray_centre_plan.py +++ b/tests/unit_tests/hyperion/experiment_plans/test_flyscan_xray_centre_plan.py @@ -315,7 +315,7 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices( # fmt: on @patch( - "dodal.devices.aperturescatterguard.ApertureScatterguard._safe_move_within_datacollection_range", + "dodal.devices.aperturescatterguard._safe_move_whilst_in_beam", return_value=NullStatus(), ) @patch( @@ -452,7 +452,7 @@ def test_results_passed_to_move_motors( ) @patch( - "dodal.devices.aperturescatterguard.ApertureScatterguard._safe_move_within_datacollection_range", + "dodal.devices.aperturescatterguard._safe_move_whilst_in_beam", return_value=NullStatus(), ) @patch( diff --git a/tests/unit_tests/hyperion/experiment_plans/test_pin_centre_then_xray_centre_plan.py b/tests/unit_tests/hyperion/experiment_plans/test_pin_centre_then_xray_centre_plan.py index 1e823779e..17ce2024c 100644 --- a/tests/unit_tests/hyperion/experiment_plans/test_pin_centre_then_xray_centre_plan.py +++ b/tests/unit_tests/hyperion/experiment_plans/test_pin_centre_then_xray_centre_plan.py @@ -4,7 +4,6 @@ from bluesky.run_engine import RunEngine from bluesky.simulators import RunEngineSimulator, assert_message_and_return_remaining from bluesky.utils import Msg -from dodal.devices.aperturescatterguard import ApertureValue from dodal.devices.backlight import BacklightPosition from dodal.devices.detector.detector_motion import ShutterState from dodal.devices.smargon import Smargon @@ -292,9 +291,8 @@ def test_pin_centre_then_xray_centre_plan_sets_up_backlight_and_aperture( ) msgs = assert_message_and_return_remaining( msgs, - lambda msg: msg.command == "set" - and msg.obj.name == "aperture_scatterguard" - and msg.args == (ApertureValue.ROBOT_LOAD,) + lambda msg: msg.command == "trigger" + and msg.obj.name == "aperture_scatterguard-move_out" and msg.kwargs["group"] == CONST.WAIT.READY_FOR_OAV, ) diff --git a/tests/unit_tests/hyperion/experiment_plans/test_robot_load_and_change_energy.py b/tests/unit_tests/hyperion/experiment_plans/test_robot_load_and_change_energy.py index c688a99a5..25596abd2 100644 --- a/tests/unit_tests/hyperion/experiment_plans/test_robot_load_and_change_energy.py +++ b/tests/unit_tests/hyperion/experiment_plans/test_robot_load_and_change_energy.py @@ -6,7 +6,7 @@ from bluesky.run_engine import RunEngine from bluesky.simulators import RunEngineSimulator, assert_message_and_return_remaining from bluesky.utils import Msg -from dodal.devices.aperturescatterguard import ApertureScatterguard, ApertureValue +from dodal.devices.aperturescatterguard import ApertureScatterguard from dodal.devices.oav.oav_detector import OAV from dodal.devices.smargon import Smargon, StubPosition from dodal.devices.webcam import Webcam @@ -171,7 +171,7 @@ async def test_when_prepare_for_robot_load_called_then_moves_as_expected( aperture_scatterguard: ApertureScatterguard, smargon: Smargon, done_status ): smargon.stub_offsets.set = MagicMock(return_value=done_status) - aperture_scatterguard.set = MagicMock(return_value=done_status) + aperture_scatterguard.move_out.trigger = MagicMock(return_value=done_status) set_mock_value(smargon.x.user_readback, 10) set_mock_value(smargon.z.user_readback, 5) @@ -185,7 +185,7 @@ async def test_when_prepare_for_robot_load_called_then_moves_as_expected( assert await smargon.omega.user_readback.get_value() == 0 smargon.stub_offsets.set.assert_called_once_with(StubPosition.RESET_TO_ROBOT_LOAD) # type: ignore - aperture_scatterguard.set.assert_called_once_with(ApertureValue.ROBOT_LOAD) # type: ignore + aperture_scatterguard.move_out.trigger.assert_called_once_with() # type: ignore @patch( diff --git a/tests/unit_tests/hyperion/experiment_plans/test_rotation_scan_plan.py b/tests/unit_tests/hyperion/experiment_plans/test_rotation_scan_plan.py index f39e57a9d..253b26f2e 100644 --- a/tests/unit_tests/hyperion/experiment_plans/test_rotation_scan_plan.py +++ b/tests/unit_tests/hyperion/experiment_plans/test_rotation_scan_plan.py @@ -507,9 +507,8 @@ def test_rotation_snapshot_setup_called_to_move_backlight_in_aperture_out_before ) msgs = assert_message_and_return_remaining( msgs, - lambda msg: msg.command == "set" - and msg.obj.name == "aperture_scatterguard" - and msg.args[0] == ApertureValue.ROBOT_LOAD + lambda msg: msg.command == "trigger" + and msg.obj.name == "aperture_scatterguard-move_out" and msg.kwargs["group"] == CONST.WAIT.READY_FOR_OAV, ) msgs = assert_message_and_return_remaining(