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

Thaw for a set time straight after robot load #1440

Merged
merged 9 commits into from
Jun 26, 2024
Merged
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ install_requires =
ophyd-async >= 0.3a5
bluesky >= 1.13.0a3
blueapi >= 0.4.3-rc1
dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git
dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@aea730cbf97bda5ef1d4b4fe9266c3ac472fdcdc

[options.entry_points]
console_scripts =
Expand Down
4 changes: 4 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,8 @@ def robot_load():

yield from bps.wait("robot_load")

yield from bps.abs_set(composite.thawer.thaw_for_time_s, params.thawing_time)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some point in this plan where we need to check that the thawer is off before continuing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. I will double check with Neil

Copy link
Collaborator Author

@DominicOram DominicOram Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact @neil-i03 do we need to wait at some point for the thawing to have stopped or we just fire and forget? It's ok to be thawing whilst collecting potentially?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fire and forget. We can collect while thawing (and may have to).


yield from take_robot_snapshots(
composite.oav, composite.webcam, params.snapshot_directory
)
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,
)
Loading