Skip to content

Commit

Permalink
Merge branch 'main' into 706_new_save_load
Browse files Browse the repository at this point in the history
  • Loading branch information
olliesilvester authored Feb 5, 2025
2 parents 27fc769 + aa5f360 commit d872de1
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ def run_grid_detection_plan(
parameters.box_size_um,
)

if parameters.selected_aperture:
# Start moving the aperture/scatterguard into position without moving it in
yield from bps.prepare(
composite.aperture_scatterguard,
parameters.selected_aperture,
group=CONST.WAIT.GRID_READY_FOR_DC,
)

yield from run_grid_detection_plan(
oav_params,
snapshot_template,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,17 @@ def setup_beamline_for_OAV(
yield from bps.abs_set(smargon.omega.velocity, max_vel, group=group)
yield from bps.abs_set(backlight, BacklightPosition.IN, group=group)
yield from bps.abs_set(
aperture_scatterguard,
ApertureValue.ROBOT_LOAD,
group=group,
aperture_scatterguard, ApertureValue.OUT_OF_BEAM, group=group
)


def oav_snapshot_plan(
composite: OavSnapshotComposite,
parameters: WithSnapshot,
oav_parameters: OAVParameters,
wait: bool = True,
) -> MsgGenerator:
if not parameters.take_snapshots:
return
yield from bps.wait(group=CONST.WAIT.READY_FOR_OAV)
yield from _setup_oav(composite, parameters, oav_parameters)
for omega in parameters.snapshot_omegas_deg or []:
yield from _take_oav_snapshot(composite, omega)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ def prepare_for_robot_load(
aperture_scatterguard: ApertureScatterguard, smargon: Smargon
):
yield from bps.abs_set(
aperture_scatterguard,
ApertureValue.ROBOT_LOAD,
group="prepare_robot_load",
aperture_scatterguard, ApertureValue.OUT_OF_BEAM, group="prepare_robot_load"
)

yield from bps.mv(smargon.stub_offsets, StubPosition.RESET_TO_ROBOT_LOAD) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,13 @@ def _div_by_1000_if_not_none(num: float | None):
yield from setup_beamline_for_OAV(
composite.smargon, composite.backlight, composite.aperture_scatterguard
)
yield from bps.wait(group=CONST.WAIT.READY_FOR_OAV)
if params.selected_aperture:
yield from bps.prepare(
composite.aperture_scatterguard,
params.selected_aperture,
group=CONST.WAIT.ROTATION_READY_FOR_DC,
)
yield from oav_snapshot_plan(composite, params, oav_params)
yield from rotation_scan_plan(
composite,
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ async def aperture_scatterguard(RE):
scatterguard_y=14,
radius=20,
),
ApertureValue.ROBOT_LOAD: AperturePosition(
ApertureValue.OUT_OF_BEAM: AperturePosition(
aperture_x=15,
aperture_y=16,
aperture_z=2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[
(ApertureValue.SMALL),
(ApertureValue.MEDIUM),
(ApertureValue.ROBOT_LOAD),
(ApertureValue.OUT_OF_BEAM),
(ApertureValue.LARGE),
],
)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/hyperion/experiment_plans/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def make_event_doc(data, descriptor="abc123") -> Event:
}

BASIC_POST_SETUP_DOC = {
"aperture_scatterguard-selected_aperture": ApertureValue.ROBOT_LOAD,
"aperture_scatterguard-selected_aperture": ApertureValue.OUT_OF_BEAM,
"aperture_scatterguard-radius": None,
"aperture_scatterguard-aperture-x": 15,
"aperture_scatterguard-aperture-y": 16,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,6 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices(
)
# fmt: on

@patch(
"dodal.devices.aperturescatterguard.ApertureScatterguard._safe_move_within_datacollection_range",
return_value=NullStatus(),
)
@patch(
"mx_bluesky.hyperion.experiment_plans.flyscan_xray_centre_plan.run_gridscan",
autospec=True,
Expand All @@ -343,7 +339,6 @@ async def test_results_adjusted_and_event_raised(
self,
mock_panda_load: MagicMock,
run_gridscan: MagicMock,
move_aperture: MagicMock,
fgs_composite_with_panda_pcap: FlyScanXRayCentreComposite,
test_fgs_params_panda_zebra: HyperionSpecifiedThreeDGridScan,
feature_controlled: _FeatureControlled,
Expand Down Expand Up @@ -469,10 +464,6 @@ def test_results_passed_to_move_motors(
any_order=True,
)

@patch(
"dodal.devices.aperturescatterguard.ApertureScatterguard._safe_move_within_datacollection_range",
return_value=NullStatus(),
)
@patch(
"mx_bluesky.hyperion.experiment_plans.flyscan_xray_centre_plan.run_gridscan",
autospec=True,
Expand All @@ -492,7 +483,6 @@ def test_individual_plans_triggered_once_and_only_once_in_composite_run(
mock_zocalo_trigger: MagicMock,
move_xyz: MagicMock,
run_gridscan: MagicMock,
move_aperture: MagicMock,
RE_with_subs: ReWithSubs,
fgs_composite_with_panda_pcap: FlyScanXRayCentreComposite,
test_fgs_params_panda_zebra: HyperionSpecifiedThreeDGridScan,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def test_pin_centre_then_xray_centre_plan_sets_up_backlight_and_aperture(
msgs,
lambda msg: msg.command == "set"
and msg.obj.name == "aperture_scatterguard"
and msg.args == (ApertureValue.ROBOT_LOAD,)
and msg.args == (ApertureValue.OUT_OF_BEAM,)
and msg.kwargs["group"] == CONST.WAIT.READY_FOR_OAV,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async def test_when_prepare_for_robot_load_called_then_moves_as_expected(
assert await smargon.omega.user_setpoint.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(ApertureValue.ROBOT_LOAD) # type: ignore
aperture_scatterguard.set.assert_called_once_with(ApertureValue.OUT_OF_BEAM) # type: ignore


@patch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,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] == ApertureValue.ROBOT_LOAD
and msg.args[0] == ApertureValue.OUT_OF_BEAM
and msg.kwargs["group"] == CONST.WAIT.READY_FOR_OAV,
)
msgs = assert_message_and_return_remaining(
Expand Down

0 comments on commit d872de1

Please sign in to comment.