Skip to content
Open
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
48 changes: 23 additions & 25 deletions src/dodal/beamlines/p51.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
from functools import cache
from pathlib import Path

from ophyd_async.core import PathProvider
from ophyd_async.epics.motor import Motor
from ophyd_async.epics.pmac import PmacIO
from ophyd_async.fastcs.panda import HDFPanda

from dodal.common.beamlines.beamline_utils import (
device_factory,
get_path_provider,
set_path_provider,
)
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.common.visit import RemoteDirectoryServiceClient, StaticVisitPathProvider
from dodal.common.visit import LocalDirectoryServiceClient, StaticVisitPathProvider
from dodal.device_manager import DeviceManager
from dodal.devices.turbo_slit import TurboSlit
from dodal.devices.xspress3.xspress3 import Xspress3
from dodal.log import set_beamline as set_log_beamline
Expand All @@ -21,19 +19,18 @@
set_log_beamline(BL)
set_utils_beamline(BL)

devices = DeviceManager()

# Currently we must hard-code the visit, determining the visit at runtime requires
# infrastructure that is still WIP.
# Communication with GDA is also WIP so for now we determine an arbitrary scan number
# locally and write the commissioning directory. The scan number is not guaranteed to
# be unique and the data is at risk - this configuration is for testing only.
set_path_provider(
StaticVisitPathProvider(

@devices.fixture
@cache
def path_provider() -> PathProvider:
return StaticVisitPathProvider(
BL,
Path("/dls/p51/data/2026/cm44254-1/tmp"),
client=RemoteDirectoryServiceClient("http://i20-1-control:8088/api"),
Path("/dls/p51/data/2026/cm44254-1"),
client=LocalDirectoryServiceClient(),
)
)


"""
NOTE: Due to the CA gateway machine being switched off, PVs are not available remotely
Expand All @@ -43,19 +40,19 @@
"""


@device_factory()
@devices.factory()
def turbo_slit() -> TurboSlit:
"""Turboslit for selecting energy from the polychromator."""
return TurboSlit(f"{PREFIX.beamline_prefix}-OP-PCHRO-01:TS:")


@device_factory()
@devices.factory()
def turbo_slit_x() -> Motor:
"""Turbo slit x motor."""
return Motor(f"{PREFIX.beamline_prefix}-OP-PCHRO-01:TS:XFINE")


@device_factory()
@devices.factory()
def turbo_slit_pmac() -> PmacIO:
"""PMac controller using running fly scans with trajectory."""
motor = turbo_slit_x()
Expand All @@ -66,26 +63,27 @@ def turbo_slit_pmac() -> PmacIO:
)


@device_factory()
def panda() -> HDFPanda:
@devices.factory()
def panda(path_provider: PathProvider) -> HDFPanda:
return HDFPanda(
f"{PREFIX.beamline_prefix}-EA-PANDA-02:", path_provider=get_path_provider()
f"{PREFIX.beamline_prefix}-EA-PANDA-02:",
path_provider=path_provider,
)


# Use mock device until motors are reconnected on the beamline
@device_factory(mock=True)
@devices.factory(mock=True)
def alignment_x() -> Motor:
return Motor(f"{PREFIX.beamline_prefix}-MO-STAGE-01:X")


# Use mock device until motors are reconnected on the beamline
@device_factory(mock=True)
@devices.factory(mock=True)
def alignment_y() -> Motor:
return Motor(f"{PREFIX.beamline_prefix}-MO-STAGE-01:Y")


@device_factory(skip=True)
@devices.factory(skip=True)
def xspress3() -> Xspress3:
"""16 channels Xspress3 detector."""
return Xspress3(
Expand Down