diff --git a/pyproject.toml b/pyproject.toml index d315aca09..145f69785 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@987bc78925685dfa7237c58fd36e74060d73dbd4", + "dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@00858ea059bb147c04fdc51a478bd2674ca4ea00", ] 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 036de74ad..2898880a3 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 @@ -122,6 +122,11 @@ def do_robot_load( demand_energy_ev: float | None, thawing_time: float, ): + error_code = yield from bps.rd(composite.robot.error_code) + # Reset robot if light curtains were tripped + if error_code == 40: + yield from bps.trigger(composite.robot.reset, wait=True) + yield from bps.abs_set( composite.robot, sample_location, 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 df67eaf5d..325e8b09f 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 @@ -16,6 +16,8 @@ from mx_bluesky.common.parameters.robot_load import RobotLoadAndEnergyChange from mx_bluesky.hyperion.experiment_plans.robot_load_and_change_energy import ( RobotLoadAndEnergyChangeComposite, + SampleLocation, + do_robot_load, prepare_for_robot_load, robot_load_and_change_energy_plan, take_robot_snapshots, @@ -165,6 +167,41 @@ async def test_when_prepare_for_robot_load_called_then_moves_as_expected( aperture_scatterguard.set.assert_called_once_with(ApertureValue.ROBOT_LOAD) # type: ignore +@patch( + "mx_bluesky.hyperion.experiment_plans.robot_load_and_change_energy.set_energy_plan", + MagicMock(return_value=iter([])), +) +@patch( + "mx_bluesky.hyperion.experiment_plans.robot_load_and_change_energy.bps.trigger", +) +async def test_when_error_40_reset_robot_before_load( + mock_reset_error: MagicMock, + robot_load_and_energy_change_composite: RobotLoadAndEnergyChangeComposite, + robot_load_and_energy_change_params: RobotLoadAndEnergyChange, +): + assert robot_load_and_energy_change_params.sample_puck is not None + assert robot_load_and_energy_change_params.sample_pin is not None + + sample_location = SampleLocation( + robot_load_and_energy_change_params.sample_puck, + robot_load_and_energy_change_params.sample_pin, + ) + + demand_energy_ev = robot_load_and_energy_change_params.demand_energy_ev + + set_mock_value(robot_load_and_energy_change_composite.robot.error_code, 40) + + RE = RunEngine() + RE( + # Thawing time set to arbitrary value + do_robot_load( + robot_load_and_energy_change_composite, sample_location, demand_energy_ev, 0 + ) + ) + + mock_reset_error.assert_called_once() + + @patch( "mx_bluesky.hyperion.external_interaction.callbacks.robot_load.ispyb_callback.ExpeyeInteraction" )