Skip to content

Commit

Permalink
Move to chi and phi start before centring
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicOram committed Sep 14, 2024
1 parent 8aad275 commit a6adc84
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from dodal.devices.eiger import EigerDetector
from dodal.devices.oav.oav_parameters import OAV_CONFIG_JSON, OAVParameters

from mx_bluesky.hyperion.device_setup_plans.manipulate_sample import move_phi_chi_omega
from mx_bluesky.hyperion.device_setup_plans.utils import (
start_preparing_data_collection_then_do_plan,
)
Expand Down Expand Up @@ -72,6 +73,13 @@ def _pin_centre_then_xray_centre_plan():
composite.smargon, composite.backlight, composite.aperture_scatterguard
)

yield from move_phi_chi_omega(
composite.smargon,
parameters.phi_start_deg,
parameters.chi_start_deg,
group=CONST.WAIT.READY_FOR_OAV,
)

yield from pin_tip_centre_plan(
pin_tip_centring_composite,
parameters.tip_offset_um,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from dodal.devices.aperturescatterguard import ApertureScatterguard, ApertureValue
from dodal.devices.backlight import Backlight, BacklightPosition
from dodal.devices.detector.detector_motion import ShutterState
from dodal.devices.smargon import Smargon
from dodal.devices.synchrotron import SynchrotronMode

from mx_bluesky.hyperion.experiment_plans.pin_centre_then_xray_centre_plan import (
Expand Down Expand Up @@ -241,3 +242,62 @@ def test_pin_centre_then_xray_centre_plan_sets_up_backlight_and_aperture(
and msg.args == (ApertureValue.ROBOT_LOAD,)
and msg.kwargs["group"] == CONST.WAIT.READY_FOR_OAV,
)

msgs = assert_message_and_return_remaining(
msgs, lambda msg: msg.command == "pin_tip_centre_plan"
)


@patch(
"mx_bluesky.hyperion.experiment_plans.pin_centre_then_xray_centre_plan.pin_tip_centre_plan",
autospec=True,
)
@patch(
"mx_bluesky.hyperion.experiment_plans.pin_centre_then_xray_centre_plan.detect_grid_and_do_gridscan",
autospec=True,
)
def test_pin_centre_then_xray_centre_plan_goes_to_the_starting_chi_and_phi(
mock_detect_grid_and_do_gridscan,
mock_pin_tip_centre_plan,
smargon: Smargon,
sim_run_engine: RunEngineSimulator,
test_pin_centre_then_xray_centre_params: PinTipCentreThenXrayCentre,
test_config_files,
):
mock_detect_grid_and_do_gridscan.return_value = iter(
[Msg("detect_grid_and_do_gridscan")]
)
mock_pin_tip_centre_plan.return_value = iter([Msg("pin_tip_centre_plan")])

mock_composite = MagicMock()
mock_composite.smargon = smargon

test_pin_centre_then_xray_centre_params.phi_start_deg = 30
test_pin_centre_then_xray_centre_params.chi_start_deg = 50

msgs = sim_run_engine.simulate_plan(
pin_centre_then_xray_centre_plan(
mock_composite,
test_pin_centre_then_xray_centre_params,
test_config_files["oav_config_json"],
)
)

msgs = assert_message_and_return_remaining(
msgs,
lambda msg: msg.command == "set"
and msg.obj.name == "smargon-phi"
and msg.args == (test_pin_centre_then_xray_centre_params.phi_start_deg,)
and msg.kwargs["group"] == CONST.WAIT.READY_FOR_OAV,
)
msgs = assert_message_and_return_remaining(
msgs,
lambda msg: msg.command == "set"
and msg.obj.name == "smargon-chi"
and msg.args == (test_pin_centre_then_xray_centre_params.chi_start_deg,)
and msg.kwargs["group"] == CONST.WAIT.READY_FOR_OAV,
)

msgs = assert_message_and_return_remaining(
msgs, lambda msg: msg.command == "pin_tip_centre_plan"
)

0 comments on commit a6adc84

Please sign in to comment.