|
| 1 | +""" |
| 2 | +This module contains the bluesky plan entry points for use with hyperion-blueapi. |
| 3 | +The json schema and documentation therein generated by the blueapi /plans endpoint |
| 4 | +from this file constitutes the hyperion-blueapi interface to the hyperion supervisor |
| 5 | +process. |
| 6 | +""" |
| 7 | + |
| 8 | +from bluesky.utils import MsgGenerator |
| 9 | +from dodal.common import inject |
| 10 | +from dodal.devices.aperturescatterguard import ApertureScatterguard |
| 11 | +from dodal.devices.motors import XYZStage |
| 12 | +from dodal.devices.robot import BartRobot |
| 13 | +from dodal.devices.smargon import Smargon |
| 14 | + |
| 15 | +from mx_bluesky.common.device_setup_plans.robot_load_unload import ( |
| 16 | + robot_unload as _robot_unload, |
| 17 | +) |
| 18 | +from mx_bluesky.hyperion.experiment_plans.load_centre_collect_full_plan import ( |
| 19 | + LoadCentreCollectComposite, |
| 20 | +) |
| 21 | +from mx_bluesky.hyperion.experiment_plans.load_centre_collect_full_plan import ( |
| 22 | + load_centre_collect_full as _load_centre_collect_full, |
| 23 | +) |
| 24 | +from mx_bluesky.hyperion.experiment_plans.udc_default_state import ( |
| 25 | + UDCDefaultDevices, |
| 26 | +) |
| 27 | +from mx_bluesky.hyperion.experiment_plans.udc_default_state import ( |
| 28 | + move_to_udc_default_state as _move_to_udc_default_state, |
| 29 | +) |
| 30 | +from mx_bluesky.hyperion.parameters.load_centre_collect import LoadCentreCollect |
| 31 | + |
| 32 | +__all__ = [ |
| 33 | + "LoadCentreCollectComposite", |
| 34 | + "LoadCentreCollect", |
| 35 | + "UDCDefaultDevices", |
| 36 | + "load_centre_collect", |
| 37 | + "move_to_udc_default_state", |
| 38 | + "robot_unload", |
| 39 | +] |
| 40 | + |
| 41 | + |
| 42 | +def load_centre_collect( |
| 43 | + parameters: LoadCentreCollect, composite: LoadCentreCollectComposite = inject() |
| 44 | +) -> MsgGenerator: |
| 45 | + """ |
| 46 | + Attempt a complete data collection experiment, consisting of the following: |
| 47 | + * Load the sample if necessary |
| 48 | + * Move to the specified goniometer start angles |
| 49 | + * Perform optical centring, then X-ray centring |
| 50 | + * If X-ray centring finds one or more diffracting centres then for each centre |
| 51 | + that satisfies the chosen selection function, |
| 52 | + move to that centre and do a collection with the specified parameters. |
| 53 | + """ |
| 54 | + yield from _load_centre_collect_full(composite, parameters) |
| 55 | + |
| 56 | + |
| 57 | +def robot_unload( |
| 58 | + visit: str, |
| 59 | + robot: BartRobot = inject("robot"), |
| 60 | + smargon: Smargon = inject("smargon"), |
| 61 | + aperture_scatterguard: ApertureScatterguard = inject("aperture_scatterguard"), |
| 62 | + lower_gonio: XYZStage = inject("lower_gonio"), |
| 63 | +) -> MsgGenerator: |
| 64 | + """ |
| 65 | + Unload the currently mounted pin into the location that it was loaded from. |
| 66 | + This is to be invoked as the final step upon successful completion of the UDC queue. |
| 67 | + """ |
| 68 | + yield from _robot_unload(robot, smargon, aperture_scatterguard, lower_gonio, visit) |
| 69 | + |
| 70 | + |
| 71 | +def move_to_udc_default_state( |
| 72 | + composite: UDCDefaultDevices = inject(), |
| 73 | +) -> MsgGenerator: |
| 74 | + """ |
| 75 | + Move beamline hardware to known positions prior to UDC start. |
| 76 | + """ |
| 77 | + yield from _move_to_udc_default_state(composite) |
0 commit comments