diff --git a/setup.cfg b/setup.cfg index 3c9867146..6c7c9dd80 100644 --- a/setup.cfg +++ b/setup.cfg @@ -46,8 +46,7 @@ install_requires = ophyd-async >= 0.3a5 bluesky >= 1.13.0a3 blueapi >= 0.4.3-rc1 - # needed for CI while xpress is broken, remove on merging - dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git + dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@a9a116d289abc9e67ce8db08f978ff502705b464 [options.entry_points] console_scripts = diff --git a/src/hyperion/experiment_plans/robot_load_then_centre_plan.py b/src/hyperion/experiment_plans/robot_load_then_centre_plan.py index f2bad7a07..3f0ed83c4 100644 --- a/src/hyperion/experiment_plans/robot_load_then_centre_plan.py +++ b/src/hyperion/experiment_plans/robot_load_then_centre_plan.py @@ -23,6 +23,7 @@ from dodal.devices.s4_slit_gaps import S4SlitGaps from dodal.devices.smargon import Smargon, StubPosition from dodal.devices.synchrotron import Synchrotron +from dodal.devices.thawer import Thawer from dodal.devices.undulator import Undulator from dodal.devices.undulator_dcm import UndulatorDCM from dodal.devices.webcam import Webcam @@ -73,6 +74,7 @@ class RobotLoadThenCentreComposite: zocalo: ZocaloResults panda: HDFPanda panda_fast_grid_scan: PandAFastGridScan + thawer: Thawer # SetEnergyComposite fields vfm: FocusingMirrorWithStripes @@ -182,6 +184,7 @@ def robot_load(): yield from bps.wait("robot_load") + yield from bps.abs_set(composite.thawer.thaw_for_time_s, params.thawing_time) yield from wait_for_smargon_not_disabled(composite.smargon) yield from take_robot_snapshots( diff --git a/src/hyperion/parameters/constants.py b/src/hyperion/parameters/constants.py index 78f0d1cac..4f8ebc89e 100644 --- a/src/hyperion/parameters/constants.py +++ b/src/hyperion/parameters/constants.py @@ -97,6 +97,7 @@ class I03Constants: SHUTTER_TIME_S = 0.06 USE_PANDA_FOR_GRIDSCAN = False USE_GPU_FOR_GRIDSCAN_ANALYSIS = False + THAWING_TIME = 20 @dataclass(frozen=True) diff --git a/src/hyperion/parameters/gridscan.py b/src/hyperion/parameters/gridscan.py index 1ea635434..bdf9a6c06 100644 --- a/src/hyperion/parameters/gridscan.py +++ b/src/hyperion/parameters/gridscan.py @@ -102,9 +102,12 @@ class PinTipCentreThenXrayCentre(GridCommon): class RobotLoadThenCentre(GridCommon): + thawing_time: float = Field(default=CONST.I03.THAWING_TIME) + def pin_centre_then_xray_centre_params(self): - params = PinTipCentreThenXrayCentre(**self.dict()) - return params + my_params = self.dict() + del my_params["thawing_time"] + return PinTipCentreThenXrayCentre(**my_params) class SpecifiedGridScan(GridCommon, XyzStarts, WithScan): diff --git a/tests/conftest.py b/tests/conftest.py index 22627daf0..29909bc84 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -36,6 +36,7 @@ from dodal.devices.s4_slit_gaps import S4SlitGaps from dodal.devices.smargon import Smargon from dodal.devices.synchrotron import Synchrotron, SynchrotronMode +from dodal.devices.thawer import Thawer from dodal.devices.undulator import Undulator from dodal.devices.webcam import Webcam from dodal.devices.zebra import Zebra @@ -444,6 +445,11 @@ def webcam(RE) -> Generator[Webcam, Any, Any]: yield webcam +@pytest.fixture +def thawer(RE) -> Generator[Thawer, Any, Any]: + yield i03.thawer(fake_with_ophyd_sim=True) + + @pytest.fixture def aperture_scatterguard(RE): AperturePositions.LARGE = SingleAperturePosition( diff --git a/tests/unit_tests/experiment_plans/test_wait_for_robot_load_then_centre.py b/tests/unit_tests/experiment_plans/test_wait_for_robot_load_then_centre.py index e82df7ea0..606aa7fec 100644 --- a/tests/unit_tests/experiment_plans/test_wait_for_robot_load_then_centre.py +++ b/tests/unit_tests/experiment_plans/test_wait_for_robot_load_then_centre.py @@ -28,7 +28,7 @@ @pytest.fixture def robot_load_composite( - smargon, dcm, robot, aperture_scatterguard, oav, webcam + smargon, dcm, robot, aperture_scatterguard, oav, webcam, thawer ) -> RobotLoadThenCentreComposite: composite: RobotLoadThenCentreComposite = MagicMock() composite.smargon = smargon @@ -40,6 +40,7 @@ def robot_load_composite( composite.aperture_scatterguard.set = MagicMock(return_value=NullStatus()) composite.oav = oav composite.webcam = webcam + composite.thawer = thawer return composite @@ -353,3 +354,39 @@ async def test_when_take_snapshots_called_then_filename_and_directory_set_and_de webcam.trigger.assert_called_once() assert (await webcam.filename.get_value()) == "TIME_webcam_after_load" assert (await webcam.directory.get_value()) == TEST_DIRECTORY + + +@patch( + "hyperion.experiment_plans.robot_load_then_centre_plan.pin_centre_then_xray_centre_plan" +) +@patch( + "hyperion.experiment_plans.robot_load_then_centre_plan.set_energy_plan", + MagicMock(return_value=iter([])), +) +def test_when_plan_run_then_thawing_turned_on_for_expected_time( + mock_centring_plan: MagicMock, + robot_load_composite: RobotLoadThenCentreComposite, + robot_load_then_centre_params_no_energy: RobotLoadThenCentre, + sim_run_engine, +): + robot_load_then_centre_params_no_energy.thawing_time = (thaw_time := 50) + + sim_run_engine.add_handler( + "read", + "dcm-energy_in_kev", + lambda msg: {"dcm-energy_in_kev": {"value": 11.105}}, + ) + + messages = sim_run_engine.simulate_plan( + robot_load_then_centre( + robot_load_composite, + robot_load_then_centre_params_no_energy, + ) + ) + + sim_run_engine.assert_message_and_return_remaining( + messages, + lambda msg: msg.command == "set" + and msg.obj.name == "thawer-thaw_for_time_s" + and msg.args[0] == thaw_time, + )