Skip to content
44 changes: 21 additions & 23 deletions src/dodal/beamlines/b01_1.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
from functools import cache
from pathlib import Path

from ophyd_async.core import StaticPathProvider, UUIDFilenameProvider
from ophyd_async.core import PathProvider, StaticPathProvider, UUIDFilenameProvider
from ophyd_async.epics.adaravis import AravisDetector
from ophyd_async.epics.adcore import NDROIStatIO
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.beamlines.device_helpers import CAM_SUFFIX, HDF5_SUFFIX
from dodal.device_manager import DeviceManager
from dodal.devices.motors import XYZStage
from dodal.devices.synchrotron import Synchrotron
from dodal.log import set_beamline as set_log_beamline
Expand All @@ -32,34 +29,35 @@
https://argocd.diamond.ac.uk/applications?showFavorites=false&proj=&sync=&autoSync=&health=&namespace=&cluster=&labels=
"""

# This should be removed when the DeviceManager is adopted
try:
get_path_provider()
except NameError:
# If one hasn't already been set, use a default to stop things crashing
set_path_provider(StaticPathProvider(UUIDFilenameProvider(), Path("/tmp")))
devices = DeviceManager()


@device_factory()
def panda() -> HDFPanda:
@devices.fixture
@cache
def path_provider() -> PathProvider:
return StaticPathProvider(UUIDFilenameProvider(), Path("/tmp"))


@devices.factory()
def panda(path_provider: PathProvider) -> HDFPanda:
"""Provides triggering of the detectors.

Returns:
HDFPanda: The HDF5-based detector trigger device.
"""
return HDFPanda(
f"{PREFIX.beamline_prefix}-MO-PPANDA-01:",
path_provider=get_path_provider(),
path_provider=path_provider,
)


@device_factory()
@devices.factory()
def synchrotron() -> Synchrotron:
return Synchrotron()


@device_factory()
def spectroscopy_detector() -> AravisDetector:
@devices.factory()
def spectroscopy_detector(path_provider: PathProvider) -> AravisDetector:
"""The Manta camera for the spectroscopy experiment.

Looks at the spectroscopy screen and visualises light
Expand All @@ -72,7 +70,7 @@ def spectroscopy_detector() -> AravisDetector:
pv_prefix = f"{PREFIX.beamline_prefix}-DI-DCAM-02:"
return AravisDetector(
pv_prefix,
path_provider=get_path_provider(),
path_provider=path_provider,
drv_suffix=CAM_SUFFIX,
fileio_suffix=HDF5_SUFFIX,
plugins={
Expand All @@ -81,8 +79,8 @@ def spectroscopy_detector() -> AravisDetector:
)


@device_factory()
def imaging_detector() -> AravisDetector:
@devices.factory()
def imaging_detector(path_provider: PathProvider) -> AravisDetector:
"""The Mako camera for the imaging experiment.

Looks at the on-axis viewing screen.
Expand All @@ -92,13 +90,13 @@ def imaging_detector() -> AravisDetector:
"""
return AravisDetector(
f"{PREFIX.beamline_prefix}-DI-DCAM-01:",
path_provider=get_path_provider(),
path_provider=path_provider,
drv_suffix=CAM_SUFFIX,
fileio_suffix=HDF5_SUFFIX,
)


@device_factory()
@devices.factory()
def sample_stage() -> XYZStage:
"""An XYZ stage holding the sample.

Expand Down
48 changes: 30 additions & 18 deletions src/dodal/beamlines/b16.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
from functools import cache
from pathlib import Path

from ophyd_async.core import PathProvider
from ophyd_async.epics.adcore import (
ADBaseIO,
ADTIFFWriter,
AreaDetector,
)
from ophyd_async.epics.motor import Motor

from dodal.common.beamlines.beamline_utils import (
device_factory,
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.devices.beamlines.b16.detector import (
software_triggered_tiff_area_detector,
from dodal.common.beamlines.device_helpers import CAM_SUFFIX, TIFF_SUFFIX
from dodal.common.visit import (
RemoteDirectoryServiceClient,
StaticVisitPathProvider,
)
from dodal.device_manager import DeviceManager
from dodal.devices.controllers import ConstantDeadTimeController
from dodal.devices.motors import XYZStage
from dodal.log import set_beamline as set_log_beamline
from dodal.utils import BeamlinePrefix, get_beamline_name
Expand All @@ -23,42 +26,51 @@
set_log_beamline(BL)
set_utils_beamline(BL)

set_path_provider(
StaticVisitPathProvider(
devices = DeviceManager()


@devices.fixture
@cache
def path_provider() -> PathProvider:
return StaticVisitPathProvider(
BL,
Path("/dls/b16/data/2025/cm40635-3/bluesky"),
client=RemoteDirectoryServiceClient("http://b16-control:8088/api"),
)
)


@device_factory()
@devices.factory()
def attol1() -> Motor:
return Motor(f"{PREFIX.beamline_prefix}-EA-ECC-03:ACT0")


@device_factory()
@devices.factory()
def attol2() -> Motor:
return Motor(f"{PREFIX.beamline_prefix}-EA-ECC-03:ACT1")


@device_factory()
@devices.factory()
def attol3() -> Motor:
return Motor(f"{PREFIX.beamline_prefix}-EA-ECC-03:ACT2")


@device_factory()
@devices.factory()
def attorot1() -> Motor:
return Motor(f"{PREFIX.beamline_prefix}-EA-ECC-02:ACT2")


@device_factory()
def fds2() -> AreaDetector:
@devices.factory()
def fds2(path_provider: PathProvider) -> AreaDetector:
prefix = f"{PREFIX.beamline_prefix}-EA-FDS-02:"
return software_triggered_tiff_area_detector(prefix)
return AreaDetector(
writer=ADTIFFWriter.with_io(prefix, path_provider, fileio_suffix=TIFF_SUFFIX),
controller=ConstantDeadTimeController(
driver=ADBaseIO(prefix + CAM_SUFFIX), deadtime=0.0
),
)


@device_factory()
@devices.factory()
def sim_stage() -> XYZStage:
return XYZStage(
f"{PREFIX.beamline_prefix}-MO-SIM-01:",
Expand Down
24 changes: 11 additions & 13 deletions src/dodal/beamlines/b18.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from functools import cache
from pathlib import Path

from dodal.common.beamlines.beamline_utils import (
device_factory,
set_path_provider,
)
from ophyd_async.core import PathProvider

from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.common.visit import (
LocalDirectoryServiceClient,
StaticVisitPathProvider,
)
from dodal.device_manager import DeviceManager
from dodal.devices.synchrotron import Synchrotron
from dodal.log import set_beamline as set_log_beamline
from dodal.utils import BeamlinePrefix, get_beamline_name
Expand All @@ -18,21 +18,19 @@
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/b18/data/2025/cm40637-3/bluesky"),
client=LocalDirectoryServiceClient(),
)
)


@device_factory()
@devices.factory()
def synchrotron() -> Synchrotron:
return Synchrotron()
35 changes: 19 additions & 16 deletions src/dodal/beamlines/i13_1.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from functools import cache
from pathlib import Path

from ophyd_async.core import PathProvider
from ophyd_async.epics.adaravis import AravisDetector

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 LocalDirectoryServiceClient, StaticVisitPathProvider
from dodal.device_manager import DeviceManager
from dodal.devices.beamlines.i13_1.merlin import Merlin
from dodal.devices.motors import XYZStage
from dodal.log import set_beamline as set_log_beamline
Expand All @@ -19,40 +17,45 @@
PREFIX = "BL13J"
set_log_beamline(BL)
set_utils_beamline(BL)
set_path_provider(
StaticVisitPathProvider(

devices = DeviceManager()


@devices.fixture
@cache
def path_provider() -> PathProvider:
return StaticVisitPathProvider(
BL,
Path("/dls/i13-1/data/2024/cm37257-5/tmp/"), # latest commissioning visit
client=LocalDirectoryServiceClient(),
)
)


@device_factory()
@devices.factory()
def sample_xyz_stage() -> XYZStage:
return XYZStage(prefix=f"{PREFIX}-MO-PI-02:")


@device_factory()
@devices.factory()
def sample_xyz_lab_fa_stage() -> XYZStage:
return XYZStage(prefix=f"{PREFIX}-MO-PI-02:FIXANG:")


@device_factory()
def side_camera() -> AravisDetector:
@devices.factory()
def side_camera(path_provider: PathProvider) -> AravisDetector:
return AravisDetector(
prefix=f"{PREFIX}-OP-FLOAT-03:",
drv_suffix="CAM:",
fileio_suffix="HDF5:",
path_provider=get_path_provider(),
path_provider=path_provider,
)


@device_factory()
def merlin() -> Merlin:
@devices.factory()
def merlin(path_provider: PathProvider) -> Merlin:
return Merlin(
prefix=f"{PREFIX}-EA-DET-04:",
drv_suffix="CAM:",
fileio_suffix="HDF5:",
path_provider=get_path_provider(),
path_provider=path_provider,
)
Loading