Skip to content

Commit

Permalink
Merge branch 'main' into 461_tidy_parameter_version
Browse files Browse the repository at this point in the history
  • Loading branch information
olliesilvester authored Oct 21, 2024
2 parents d9aa0cc + 7b3fe0a commit 538c65a
Show file tree
Hide file tree
Showing 11 changed files with 156 additions and 251 deletions.
22 changes: 12 additions & 10 deletions src/mx_bluesky/beamlines/i04/thawing_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import bluesky.preprocessors as bpp
from bluesky.preprocessors import run_decorator, subs_decorator
from dls_bluesky_core.core import MsgGenerator
from dodal.beamlines import i04
from dodal.beamlines.i04 import MURKO_REDIS_DB, REDIS_HOST, REDIS_PASSWORD
from dodal.common import inject
from dodal.devices.oav.oav_detector import OAV
from dodal.devices.oav.oav_to_redis_forwarder import OAVToRedisForwarder, Source
from dodal.devices.robot import BartRobot
Expand All @@ -18,11 +18,13 @@
def thaw_and_stream_to_redis(
time_to_thaw: float,
rotation: float = 360,
robot: BartRobot = inject("robot"),
thawer: Thawer = inject("thawer"),
smargon: Smargon = inject("smargon"),
oav: OAV = inject("oav"),
oav_to_redis_forwarder: OAVToRedisForwarder = inject("oav_to_redis_forwarder"),
robot: BartRobot = i04.robot(wait_for_connection=False),
thawer: Thawer = i04.thawer(wait_for_connection=False),
smargon: Smargon = i04.smargon(wait_for_connection=False),
oav: OAV = i04.oav(wait_for_connection=False),
oav_to_redis_forwarder: OAVToRedisForwarder = i04.oav_to_redis_forwarder(
wait_for_connection=False
),
) -> MsgGenerator:
zoom_percentage = yield from bps.rd(oav.zoom_controller.percentage) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
sample_id = yield from bps.rd(robot.sample_id)
Expand Down Expand Up @@ -75,8 +77,8 @@ def cleanup():
def thaw(
time_to_thaw: float,
rotation: float = 360,
thawer: Thawer = inject("thawer"),
smargon: Smargon = inject("smargon"),
thawer: Thawer = i04.thawer(wait_for_connection=False),
smargon: Smargon = i04.smargon(wait_for_connection=False),
plan_between_rotations: Callable[[], MsgGenerator] | None = None,
) -> MsgGenerator:
"""Rotates the sample and thaws it at the same time.
Expand All @@ -85,9 +87,9 @@ def thaw(
time_to_thaw (float): Time to thaw for, in seconds.
rotation (float, optional): How much to rotate by whilst thawing, in degrees.
Defaults to 360.
thawer (Thawer, optional): The thawing device. Defaults to inject("thawer").
thawer (Thawer, optional): The thawing device. Defaults to i04.thawer(wait_for_connection=False).
smargon (Smargon, optional): The smargon used to rotate.
Defaults to inject("smargon")
Defaults to i04.smargon(wait_for_connection=False)
plan_between_rotations (MsgGenerator, optional): A plan to run between rotations
of the smargon. Defaults to no plan.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import bluesky.plan_stubs as bps
import bluesky.preprocessors as bpp
from blueapi.core import MsgGenerator
from dodal.common import inject
from dodal.beamlines import i24
from dodal.devices.hutch_shutter import HutchShutter, ShutterDemand
from dodal.devices.i24.aperture import Aperture
from dodal.devices.i24.beamstop import Beamstop
Expand Down Expand Up @@ -72,7 +72,7 @@ def flush_print(text):

@log.log_on_entry
def initialise_extruder(
detector_stage: DetectorMotion = inject("detector_motion"),
detector_stage: DetectorMotion = i24.detector_motion(wait_for_connection=False),
) -> MsgGenerator:
setup_logging()
logger.info("Initialise Parameters for extruder data collection on I24.")
Expand Down Expand Up @@ -100,8 +100,8 @@ def initialise_extruder(
@log.log_on_entry
def laser_check(
mode: str,
zebra: Zebra = inject("zebra"),
detector_stage: DetectorMotion = inject("detector_motion"),
zebra: Zebra = i24.zebra(wait_for_connection=False),
detector_stage: DetectorMotion = i24.detector_motion(wait_for_connection=False),
) -> MsgGenerator:
"""Plan to open the shutter and check the laser beam from the viewer by pressing \
'Laser On' and 'Laser Off' buttons on the edm.
Expand Down Expand Up @@ -133,7 +133,7 @@ def laser_check(

@log.log_on_entry
def enter_hutch(
detector_stage: DetectorMotion = inject("detector_motion"),
detector_stage: DetectorMotion = i24.detector_motion(wait_for_connection=False),
) -> MsgGenerator:
"""Move the detector stage before entering hutch."""
setup_logging()
Expand Down Expand Up @@ -466,13 +466,13 @@ def collection_complete_plan(


def run_extruder_plan(
zebra: Zebra = inject("zebra"),
aperture: Aperture = inject("aperture"),
backlight: DualBacklight = inject("backlight"),
beamstop: Beamstop = inject("beamstop"),
detector_stage: DetectorMotion = inject("detector_motion"),
shutter: HutchShutter = inject("shutter"),
dcm: DCM = inject("dcm"),
zebra: Zebra = i24.zebra(wait_for_connection=False),
aperture: Aperture = i24.aperture(wait_for_connection=False),
backlight: DualBacklight = i24.backlight(wait_for_connection=False),
beamstop: Beamstop = i24.beamstop(wait_for_connection=False),
detector_stage: DetectorMotion = i24.detector_motion(wait_for_connection=False),
shutter: HutchShutter = i24.shutter(wait_for_connection=False),
dcm: DCM = i24.dcm(wait_for_connection=False),
) -> MsgGenerator:
setup_logging()
start_time = datetime.now()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import bluesky.preprocessors as bpp
import numpy as np
from blueapi.core import MsgGenerator
from dodal.common import inject
from dodal.beamlines import i24
from dodal.devices.hutch_shutter import HutchShutter, ShutterDemand
from dodal.devices.i24.aperture import Aperture
from dodal.devices.i24.beamstop import Beamstop
Expand Down Expand Up @@ -743,14 +743,14 @@ def tidy_up_after_collection_plan(


def run_fixed_target_plan(
zebra: Zebra = inject("zebra"),
pmac: PMAC = inject("pmac"),
aperture: Aperture = inject("aperture"),
backlight: DualBacklight = inject("backlight"),
beamstop: Beamstop = inject("beamstop"),
detector_stage: DetectorMotion = inject("detector_motion"),
shutter: HutchShutter = inject("shutter"),
dcm: DCM = inject("dcm"),
zebra: Zebra = i24.zebra(wait_for_connection=False),
pmac: PMAC = i24.pmac(wait_for_connection=False),
aperture: Aperture = i24.aperture(wait_for_connection=False),
backlight: DualBacklight = i24.backlight(wait_for_connection=False),
beamstop: Beamstop = i24.beamstop(wait_for_connection=False),
detector_stage: DetectorMotion = i24.detector_motion(wait_for_connection=False),
shutter: HutchShutter = i24.shutter(wait_for_connection=False),
dcm: DCM = i24.dcm(wait_for_connection=False),
) -> MsgGenerator:
setup_logging()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import numpy as np
from blueapi.core import MsgGenerator
from dodal.beamlines import i24
from dodal.common import inject
from dodal.devices.i24.beamstop import Beamstop, BeamstopPositions
from dodal.devices.i24.dual_backlight import BacklightPositions, DualBacklight
from dodal.devices.i24.i24_detector_motion import DetectorMotion
Expand Down Expand Up @@ -73,7 +72,7 @@ def setup_logging():

@log.log_on_entry
def initialise_stages(
pmac: PMAC = inject("pmac"),
pmac: PMAC = i24.pmac(wait_for_connection=False),
) -> MsgGenerator:
"""Initialise the portable stages PVs, usually used only once right after setting \
up the stages either after use at different facility.
Expand Down Expand Up @@ -210,7 +209,7 @@ def scrape_pvar_file(fid: str, pvar_dir: Path = PVAR_FILE_PATH):
@log.log_on_entry
def define_current_chip(
chipid: str = "oxford",
pmac: PMAC = inject("pmac"),
pmac: PMAC = i24.pmac(wait_for_connection=False),
) -> MsgGenerator:
setup_logging()
logger.debug("Run load stock map for just the first block")
Expand Down Expand Up @@ -255,7 +254,7 @@ def save_screen_map() -> MsgGenerator:


@log.log_on_entry
def upload_parameters(pmac: PMAC = inject("pmac")) -> MsgGenerator:
def upload_parameters(pmac: PMAC = i24.pmac(wait_for_connection=False)) -> MsgGenerator:
setup_logging()
logger.info("Uploading Parameters for Oxford Chip to the GeoBrick")
caput(CHIPTYPE_PV, 0)
Expand Down Expand Up @@ -606,7 +605,9 @@ def load_full_map() -> MsgGenerator:


@log.log_on_entry
def moveto(place: str = "origin", pmac: PMAC = inject("pmac")) -> MsgGenerator:
def moveto(
place: str = "origin", pmac: PMAC = i24.pmac(wait_for_connection=False)
) -> MsgGenerator:
setup_logging()
logger.info(f"Move to: {place}")
if place == Fiducials.zero:
Expand Down Expand Up @@ -634,10 +635,10 @@ def moveto(place: str = "origin", pmac: PMAC = inject("pmac")) -> MsgGenerator:
@log.log_on_entry
def moveto_preset(
place: str,
pmac: PMAC = inject("pmac"),
beamstop: Beamstop = inject("beamstop"),
backlight: DualBacklight = inject("backlight"),
det_stage: DetectorMotion = inject("detector_motion"),
pmac: PMAC = i24.pmac(wait_for_connection=False),
beamstop: Beamstop = i24.beamstop(wait_for_connection=False),
backlight: DualBacklight = i24.backlight(wait_for_connection=False),
det_stage: DetectorMotion = i24.detector_motion(wait_for_connection=False),
) -> MsgGenerator:
setup_logging()

Expand Down Expand Up @@ -671,7 +672,9 @@ def moveto_preset(


@log.log_on_entry
def laser_control(laser_setting: str, pmac: PMAC = inject("pmac")) -> MsgGenerator:
def laser_control(
laser_setting: str, pmac: PMAC = i24.pmac(wait_for_connection=False)
) -> MsgGenerator:
setup_logging()
logger.info(f"Move to: {laser_setting}")
if laser_setting == "laser1on": # these are in laser edm
Expand Down Expand Up @@ -731,7 +734,9 @@ def scrape_mtr_directions(motor_file_path: Path = CS_FILES_PATH):


@log.log_on_entry
def fiducial(point: int = 1, pmac: PMAC = inject("pmac")) -> MsgGenerator:
def fiducial(
point: int = 1, pmac: PMAC = i24.pmac(wait_for_connection=False)
) -> MsgGenerator:
setup_logging()
scale = 10000.0 # noqa: F841

Expand Down Expand Up @@ -770,7 +775,7 @@ def scrape_mtr_fiducials(


@log.log_on_entry
def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
def cs_maker(pmac: PMAC = i24.pmac(wait_for_connection=False)) -> MsgGenerator:
"""
Coordinate system.
Expand Down Expand Up @@ -930,7 +935,7 @@ def check_dir(val):
yield from bps.null()


def cs_reset(pmac: PMAC = inject("pmac")) -> MsgGenerator:
def cs_reset(pmac: PMAC = i24.pmac(wait_for_connection=False)) -> MsgGenerator:
"""Used to clear CS when using Custom Chip"""
setup_logging()
cs1 = "#1->10000X+0Y+0Z"
Expand Down Expand Up @@ -994,7 +999,7 @@ def pumpprobe_calc() -> MsgGenerator:


@log.log_on_entry
def block_check(pmac: PMAC = inject("pmac")) -> MsgGenerator:
def block_check(pmac: PMAC = i24.pmac(wait_for_connection=False)) -> MsgGenerator:
setup_logging()
# TODO See https://github.com/DiamondLightSource/mx_bluesky/issues/117
caput(pv.me14e_gp9, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import bluesky.plan_stubs as bps
from blueapi.core import MsgGenerator
from bluesky.utils import Msg
from dodal.common import inject
from dodal.beamlines import i24
from dodal.devices.i24.i24_detector_motion import DetectorMotion

from mx_bluesky.beamlines.i24.serial import log
Expand Down Expand Up @@ -92,7 +92,8 @@ def _get_requested_detector(det_type_pv: str) -> str:


def setup_detector_stage(
expt_type: SSXType, detector_stage: DetectorMotion = inject("detector_motion")
expt_type: SSXType,
detector_stage: DetectorMotion = i24.detector_motion(wait_for_connection=False),
) -> MsgGenerator:
setup_logging()
# Grab the correct PV depending on experiment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def flyscan_xray_centre(
parameters.features.update_self_from_server()
composite.eiger.set_detector_parameters(parameters.detector_params)
composite.zocalo.zocalo_environment = parameters.zocalo_environment
composite.zocalo.use_cpu_and_gpu = parameters.use_cpu_and_gpu_zocalo
composite.zocalo.use_cpu_and_gpu = parameters.compare_cpu_and_gpu_results

feature_controlled = _get_feature_controlled(composite, parameters)

Expand Down
6 changes: 4 additions & 2 deletions src/mx_bluesky/hyperion/parameters/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ class I03Constants:
OAV_CENTRING_FILE = _test_oav_file if TEST_MODE else _live_oav_file
SHUTTER_TIME_S = 0.06
USE_PANDA_FOR_GRIDSCAN = False
USE_GPU_FOR_GRIDSCAN_ANALYSIS = False
THAWING_TIME = 20
USE_CPU_AND_GPU_ZOCALO = False

# Turns on GPU processing for zocalo and logs a comparison between GPU and CPU-
# processed results. GPU results never used in analysis for now
COMPARE_CPU_AND_GPU_ZOCALO = False


@dataclass(frozen=True)
Expand Down
7 changes: 4 additions & 3 deletions src/mx_bluesky/hyperion/parameters/gridscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ class GridCommon(
default=CONST.HARDWARE.PANDA_FGS_RUN_UP_DEFAULT
)
use_panda: bool = Field(default=CONST.I03.USE_PANDA_FOR_GRIDSCAN)
use_gpu: bool = Field(default=CONST.I03.USE_GPU_FOR_GRIDSCAN_ANALYSIS)
use_cpu_and_gpu_zocalo: bool = Field(default=CONST.I03.USE_CPU_AND_GPU_ZOCALO)
compare_cpu_and_gpu_results: bool = Field(
default=CONST.I03.COMPARE_CPU_AND_GPU_ZOCALO
)
ispyb_experiment_type: IspybExperimentType = Field(
default=IspybExperimentType.GRIDSCAN_3D
)
Expand Down Expand Up @@ -72,7 +73,7 @@ def detector_params(self):
use_roi_mode=self.use_roi_mode,
det_dist_to_beam_converter_path=self.det_dist_to_beam_converter_path,
trigger_mode=self.trigger_mode,
enable_dev_shm=self.use_gpu,
enable_dev_shm=self.compare_cpu_and_gpu_results,
**optional_args,
)

Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ def mock_side(*args, **kwargs):

@pytest.fixture
def backlight():
backlight = i03.backlight(fake_with_ophyd_sim=True)
backlight.TIME_TO_MOVE_S = 0.001
return i03.backlight(fake_with_ophyd_sim=True)


Expand Down
Loading

0 comments on commit 538c65a

Please sign in to comment.