Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Thaw for a set time straight after robot load (#1440)
Browse files Browse the repository at this point in the history
* Thaw for a set time straight after robot load

* Added test to confirm thawing is turned on for robot_load
  • Loading branch information
DominicOram authored Jun 26, 2024
1 parent 39c3e73 commit 9271fa7
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 5 deletions.
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
3 changes: 3 additions & 0 deletions src/hyperion/experiment_plans/robot_load_then_centre_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -73,6 +74,7 @@ class RobotLoadThenCentreComposite:
zocalo: ZocaloResults
panda: HDFPanda
panda_fast_grid_scan: PandAFastGridScan
thawer: Thawer

# SetEnergyComposite fields
vfm: FocusingMirrorWithStripes
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/hyperion/parameters/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions src/hyperion/parameters/gridscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down Expand Up @@ -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,
)

0 comments on commit 9271fa7

Please sign in to comment.