Skip to content

Commit

Permalink
Clear error 40 before robot load (#722)
Browse files Browse the repository at this point in the history
* feat: Add conditional robot reset if error 40 and unit test

* refactor: Remove unused fixtures

* Change dodal commit for tests

* Refactor variable names and assert condition

---------

Co-authored-by: Shihab Suliman <rye74444@ws557.diamond.ac.uk>
  • Loading branch information
shihab-dls and Shihab Suliman authored Dec 20, 2024
1 parent a9b4e3c commit 2c85352
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"
)
Expand Down

0 comments on commit 2c85352

Please sign in to comment.