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

Add panda support for writing positions #1337

Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -33,7 +33,7 @@ install_requires =
xarray
doct
databroker
dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@7ecd49eb11060a8528ed8b6d31e6c94179bdc2a3
dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@aac89a96686218add67bbbcc80118f6e94f0bdc9
pydantic<2.0 # See https://github.com/DiamondLightSource/hyperion/issues/774
scipy
pyzmq<25 # See https://github.com/DiamondLightSource/hyperion/issues/1103
Expand Down
8 changes: 4 additions & 4 deletions src/hyperion/device_setup_plans/setup_panda.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dodal.devices.panda_fast_grid_scan import PandAGridScanParams
from ophyd_async.core import load_device
from ophyd_async.panda import (
PandA,
HDFPanda,
SeqTable,
SeqTableRow,
SeqTrigger,
Expand Down Expand Up @@ -109,7 +109,7 @@ def get_seq_table(


def setup_panda_for_flyscan(
panda: PandA,
panda: HDFPanda,
config_yaml_path: str,
parameters: PandAGridScanParams,
initial_x: float,
Expand All @@ -123,7 +123,7 @@ def setup_panda_for_flyscan(
created using ophyd_async.core.save_device()

Args:
panda (PandA): The PandA Ophyd device
panda (HDFPanda): The PandA Ophyd device
config_yaml_path (str): Path to the yaml file containing the desired PandA PVs
parameters (PandAGridScanParams): Grid parameters
initial_x (float): Motor positions at time of PandA setup
Expand Down Expand Up @@ -177,7 +177,7 @@ def setup_panda_for_flyscan(
yield from arm_panda_for_gridscan(panda)


def arm_panda_for_gridscan(panda: PandA, group="arm_panda_gridscan"):
def arm_panda_for_gridscan(panda: HDFPanda, group="arm_panda_gridscan"):
yield from bps.abs_set(panda.seq[1].enable, Enabled.ENABLED.value, group=group) # type: ignore
yield from bps.abs_set(panda.pulse[1].enable, Enabled.ENABLED.value, group=group) # type: ignore
yield from bps.abs_set(panda.counter[1].enable, Enabled.ENABLED.value, group=group) # type: ignore
Expand Down
4 changes: 2 additions & 2 deletions src/hyperion/experiment_plans/flyscan_xray_centre_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
get_processing_result,
)
from dodal.plans.check_topup import check_topup_and_wait_if_necessary
from ophyd_async.panda import PandA
from ophyd_async.panda import HDFPanda

from hyperion.device_setup_plans.manipulate_sample import move_x_y_z
from hyperion.device_setup_plans.read_hardware_for_setup import (
Expand Down Expand Up @@ -85,7 +85,7 @@ class FlyScanXRayCentreComposite:
xbpm_feedback: XBPMFeedback
zebra: Zebra
zocalo: ZocaloResults
panda: PandA
panda: HDFPanda
panda_fast_grid_scan: PandAFastGridScan
robot: BartRobot

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from dodal.devices.xbpm_feedback import XBPMFeedback
from dodal.devices.zebra import Zebra
from dodal.devices.zocalo import ZocaloResults
from ophyd_async.panda import PandA
from ophyd_async.panda import HDFPanda

from hyperion.device_setup_plans.utils import (
start_preparing_data_collection_then_do_plan,
Expand Down Expand Up @@ -88,7 +88,7 @@ class GridDetectThenXRayCentreComposite:
xbpm_feedback: XBPMFeedback
zebra: Zebra
zocalo: ZocaloResults
panda: PandA
panda: HDFPanda
panda_fast_grid_scan: PandAFastGridScan
robot: BartRobot

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING, Any, Union

import bluesky.plan_stubs as bps
import bluesky.preprocessors as bpp
import numpy as np
from blueapi.core import BlueskyContext, MsgGenerator
from dodal.common import udc_directory_provider
from dodal.devices.panda_fast_grid_scan import (
set_fast_grid_scan_params as set_flyscan_params,
)
Expand Down Expand Up @@ -194,6 +196,9 @@ def run_gridscan_and_move(
time_between_x_steps_ms,
)

udc_directory_provider.set_directory(
Path(parameters.hyperion_params.detector_params.directory)
)
yield from setup_panda_for_flyscan(
fgs_composite.panda,
PANDA_SETUP_PATH,
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 @@ -31,7 +31,7 @@
from dodal.devices.xbpm_feedback import XBPMFeedback
from dodal.devices.zebra import Zebra
from dodal.devices.zocalo import ZocaloResults
from ophyd_async.panda import PandA
from ophyd_async.panda import HDFPanda

from hyperion.device_setup_plans.utils import (
start_preparing_data_collection_then_do_plan,
Expand Down Expand Up @@ -79,7 +79,7 @@ class RobotLoadThenCentreComposite:
undulator: Undulator
zebra: Zebra
zocalo: ZocaloResults
panda: PandA
panda: HDFPanda
panda_fast_grid_scan: PandAFastGridScan

# SetEnergyComposite fields
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import random
import types
from pathlib import Path
from typing import Any, Tuple
from unittest.mock import DEFAULT, MagicMock, call, patch

Expand Down Expand Up @@ -470,6 +471,40 @@ def wrapped_run_gridscan_and_move():
call = app_to_comment.call_args_list[0]
assert "Crystal 1: Strength 999999" in call.args[1]

@patch(
"dodal.devices.aperturescatterguard.ApertureScatterguard.set",
new=MagicMock(return_value=Status(done=True, success=True)),
)
@patch(
"hyperion.experiment_plans.panda_flyscan_xray_centre_plan.move_x_y_z",
new=MagicMock(autospec=True),
)
@patch(
"hyperion.experiment_plans.panda_flyscan_xray_centre_plan.setup_panda_for_flyscan",
new=MagicMock(autospec=True),
)
@patch(
"hyperion.experiment_plans.panda_flyscan_xray_centre_plan.run_gridscan",
new=MagicMock(return_value=iter([])),
)
@patch(
"hyperion.experiment_plans.panda_flyscan_xray_centre_plan.udc_directory_provider.set_directory",
autospec=True,
)
def test_when_gridscan_run_panda_directory_applied(
self,
set_directory,
RE_with_subs: tuple[RunEngine, Any],
test_panda_fgs_params: PandAGridscanInternalParameters,
fake_fgs_composite: FlyScanXRayCentreComposite,
):
RE_with_subs[0].subscribe(VerbosePlanExecutionLoggingCallback())
RE_with_subs[0](
run_gridscan_and_move(fake_fgs_composite, test_panda_fgs_params)
)
expected_path = Path("/dls/i03/data/2023/cm33866-5/test_hyperion")
set_directory.assert_called_once_with(expected_path)

@patch(
"hyperion.experiment_plans.panda_flyscan_xray_centre_plan.run_gridscan",
autospec=True,
Expand Down
Loading