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

Update hyperion to move just the aperture_scatterguard axes required #1544

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ install_requires =
bluesky >= 1.13.0a4
blueapi >= 0.4.3-rc1
mx-bluesky @ git+https://github.com/DiamondLightSource/mx-bluesky.git
dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git
dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@5d7ed608fa66d8937c62662633a309f1b345834d

[options.entry_points]
console_scripts =
Expand Down
3 changes: 2 additions & 1 deletion src/hyperion/device_setup_plans/manipulate_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import bluesky.plan_stubs as bps
from dodal.devices.aperturescatterguard import (
ApertureInOut,
AperturePositionGDANames,
ApertureScatterguard,
)
Expand Down Expand Up @@ -61,7 +62,7 @@ def move_aperture_if_required(
LOGGER.info(f"Setting aperture position to {aperture_position}")
yield from bps.abs_set(
aperture_scatterguard,
aperture_position,
(ApertureInOut.IN, aperture_position),
group=group,
)

Expand Down
5 changes: 4 additions & 1 deletion src/hyperion/experiment_plans/flyscan_xray_centre_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from attr import dataclass
from blueapi.core import BlueskyContext, MsgGenerator
from dodal.devices.aperturescatterguard import (
ApertureInOut,
AperturePosition,
ApertureScatterguard,
)
Expand Down Expand Up @@ -383,7 +384,9 @@ def set_aperture_for_bbox_size(
}
)
def set_aperture():
yield from bps.abs_set(aperture_device, new_selected_aperture)
yield from bps.abs_set(
aperture_device, (ApertureInOut.IN, new_selected_aperture)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe should be out as we're going to do OAV after this

)

yield from set_aperture()

Expand Down
7 changes: 5 additions & 2 deletions src/hyperion/experiment_plans/oav_snapshot_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

from blueapi.core import MsgGenerator
from bluesky import plan_stubs as bps
from dodal.devices.aperturescatterguard import AperturePosition, ApertureScatterguard
from dodal.devices.aperturescatterguard import (
ApertureInOut,
ApertureScatterguard,
)
from dodal.devices.backlight import Backlight, BacklightPosition
from dodal.devices.oav.oav_detector import OAV
from dodal.devices.oav.oav_parameters import OAVParameters
Expand Down Expand Up @@ -41,7 +44,7 @@ def setup_oav_snapshot_plan(
)
yield from bps.abs_set(
composite.aperture_scatterguard,
AperturePosition.ROBOT_LOAD,
(ApertureInOut.OUT, None),
group=OAV_SNAPSHOT_SETUP_GROUP,
)

Expand Down
4 changes: 2 additions & 2 deletions src/hyperion/experiment_plans/robot_load_then_centre_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import bluesky.plan_stubs as bps
import bluesky.preprocessors as bpp
from blueapi.core import BlueskyContext, MsgGenerator
from dodal.devices.aperturescatterguard import AperturePosition, ApertureScatterguard
from dodal.devices.aperturescatterguard import ApertureInOut, ApertureScatterguard
from dodal.devices.attenuator import Attenuator
from dodal.devices.backlight import Backlight
from dodal.devices.dcm import DCM
Expand Down Expand Up @@ -130,7 +130,7 @@ def take_robot_snapshots(oav: OAV, webcam: Webcam, directory: Path):
def prepare_for_robot_load(composite: RobotLoadThenCentreComposite):
yield from bps.abs_set(
composite.aperture_scatterguard,
AperturePosition.ROBOT_LOAD,
(ApertureInOut.OUT, None),
group="prepare_robot_load",
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We should do a set to (OUT, SMALL) small after this but will need to think about when to wait for it


Expand Down
5 changes: 2 additions & 3 deletions tests/unit_tests/device_setup_plans/test_manipulate_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from bluesky.run_engine import RunEngine
from dodal.devices.aperturescatterguard import (
ApertureInOut,
AperturePosition,
AperturePositionGDANames,
ApertureScatterguard,
Expand All @@ -19,9 +20,7 @@ async def test_move_aperture_goes_to_correct_position(
aperture_scatterguard, AperturePositionGDANames.LARGE_APERTURE
)
)
mock_set.assert_called_once_with(
AperturePosition.LARGE,
)
mock_set.assert_called_once_with((ApertureInOut.IN, AperturePosition.LARGE))


async def test_move_aperture_does_nothing_when_none_selected(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from bluesky.run_engine import RunEngine
from bluesky.simulators import RunEngineSimulator, assert_message_and_return_remaining
from dodal.beamlines import i03
from dodal.devices.aperturescatterguard import AperturePosition
from dodal.devices.aperturescatterguard import ApertureInOut, AperturePosition
from dodal.devices.backlight import BacklightPosition
from dodal.devices.eiger import EigerDetector
from dodal.devices.oav.oav_detector import OAVConfigParams
Expand Down Expand Up @@ -150,7 +150,9 @@ async def test_detect_grid_and_do_gridscan(
)

# Check aperture was changed to SMALL
mock_aperture_scatterguard.assert_called_once_with(AperturePosition.SMALL)
mock_aperture_scatterguard.assert_called_once_with(
(ApertureInOut.IN, AperturePosition.SMALL)
)

# Check we called out to underlying fast grid scan plan
mock_flyscan_xray_centre_plan.assert_called_once_with(ANY, ANY)
Expand Down
10 changes: 7 additions & 3 deletions tests/unit_tests/experiment_plans/test_rotation_scan_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
import pytest
from bluesky.run_engine import RunEngine
from bluesky.simulators import RunEngineSimulator, assert_message_and_return_remaining
from dodal.devices.aperturescatterguard import AperturePosition, ApertureScatterguard
from dodal.devices.aperturescatterguard import (
ApertureInOut,
AperturePosition,
ApertureScatterguard,
)
from dodal.devices.backlight import BacklightPosition
from dodal.devices.oav.oav_parameters import OAVParameters
from dodal.devices.smargon import Smargon
Expand Down Expand Up @@ -422,7 +426,7 @@ def test_rotation_scan_moves_aperture_in_backlight_out_after_snapshots_before_ro
msgs,
lambda msg: msg.command == "set"
and msg.obj.name == "aperture_scatterguard"
and msg.args[0] == AperturePosition.SMALL
and msg.args[0] == (ApertureInOut.IN, AperturePosition.SMALL)
and msg.kwargs["group"] == "setup_senv",
)
msgs = assert_message_and_return_remaining(
Expand Down Expand Up @@ -509,7 +513,7 @@ def test_rotation_snapshot_setup_called_to_move_backlight_in_aperture_out_before
msgs,
lambda msg: msg.command == "set"
and msg.obj.name == "aperture_scatterguard"
and msg.args[0] == AperturePosition.ROBOT_LOAD
and msg.args[0] == (ApertureInOut.OUT, None)
and msg.kwargs["group"] == OAV_SNAPSHOT_SETUP_GROUP,
)
msgs = assert_message_and_return_remaining(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from bluesky.run_engine import RunEngine
from bluesky.simulators import RunEngineSimulator, assert_message_and_return_remaining
from bluesky.utils import Msg
from dodal.devices.aperturescatterguard import AperturePosition
from dodal.devices.aperturescatterguard import ApertureInOut
from dodal.devices.oav.oav_detector import OAV
from dodal.devices.smargon import StubPosition
from dodal.devices.webcam import Webcam
Expand Down Expand Up @@ -286,7 +286,7 @@ async def test_when_prepare_for_robot_load_called_then_moves_as_expected(
assert await smargon.omega.user_readback.get_value() == 0

smargon.stub_offsets.set.assert_called_once_with(StubPosition.RESET_TO_ROBOT_LOAD) # type: ignore
aperture_scatterguard.set.assert_called_once_with(AperturePosition.ROBOT_LOAD) # type: ignore
aperture_scatterguard.set.assert_called_once_with((ApertureInOut.OUT, None)) # type: ignore


@patch(
Expand Down
Loading