Skip to content

Commit e243681

Browse files
Updated P51 to use Device Manager (#1930)
* removed set_path_provider * modified Panda path provider * reverted device manager implementation * Revert "reverted device manager implementation" This reverts commit 92ebd74. * using path provider * static path provider trial I * Revert "static path provider trial I" This reverts commit d6d5e8f. * reverted path change * updated turbo_slit_pmac
1 parent b6927cc commit e243681

1 file changed

Lines changed: 23 additions & 26 deletions

File tree

src/dodal/beamlines/p51.py

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1+
from functools import cache
12
from pathlib import Path
23

4+
from ophyd_async.core import PathProvider
35
from ophyd_async.epics.motor import Motor
46
from ophyd_async.epics.pmac import PmacIO
57
from ophyd_async.fastcs.panda import HDFPanda
68

7-
from dodal.common.beamlines.beamline_utils import (
8-
device_factory,
9-
get_path_provider,
10-
set_path_provider,
11-
)
129
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
1310
from dodal.common.visit import RemoteDirectoryServiceClient, StaticVisitPathProvider
11+
from dodal.device_manager import DeviceManager
1412
from dodal.devices.turbo_slit import TurboSlit
1513
from dodal.devices.xspress3.xspress3 import Xspress3
1614
from dodal.log import set_beamline as set_log_beamline
@@ -21,19 +19,18 @@
2119
set_log_beamline(BL)
2220
set_utils_beamline(BL)
2321

22+
devices = DeviceManager()
2423

25-
# Currently we must hard-code the visit, determining the visit at runtime requires
26-
# infrastructure that is still WIP.
27-
# Communication with GDA is also WIP so for now we determine an arbitrary scan number
28-
# locally and write the commissioning directory. The scan number is not guaranteed to
29-
# be unique and the data is at risk - this configuration is for testing only.
30-
set_path_provider(
31-
StaticVisitPathProvider(
24+
25+
@devices.fixture
26+
@cache
27+
def path_provider() -> PathProvider:
28+
return StaticVisitPathProvider(
3229
BL,
33-
Path("/dls/p51/data/2026/cm44254-1/tmp"),
30+
Path("/dls/p51/data/2026/cm44254-1"),
3431
client=RemoteDirectoryServiceClient("http://i20-1-control:8088/api"),
3532
)
36-
)
33+
3734

3835
"""
3936
NOTE: Due to the CA gateway machine being switched off, PVs are not available remotely
@@ -43,49 +40,49 @@
4340
"""
4441

4542

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

5148

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

5754

58-
@device_factory()
59-
def turbo_slit_pmac() -> PmacIO:
55+
@devices.factory()
56+
def turbo_slit_pmac(turbo_slit_x: Motor) -> PmacIO:
6057
"""PMac controller using running fly scans with trajectory."""
61-
motor = turbo_slit_x()
6258
return PmacIO(
6359
prefix=f"{PREFIX.beamline_prefix}-MO-STEP-06:",
64-
raw_motors=[motor],
60+
raw_motors=[turbo_slit_x],
6561
coord_nums=[3],
6662
)
6763

6864

69-
@device_factory()
70-
def panda() -> HDFPanda:
65+
@devices.factory()
66+
def panda(path_provider: PathProvider) -> HDFPanda:
7167
return HDFPanda(
72-
f"{PREFIX.beamline_prefix}-EA-PANDA-02:", path_provider=get_path_provider()
68+
f"{PREFIX.beamline_prefix}-EA-PANDA-02:",
69+
path_provider=path_provider,
7370
)
7471

7572

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

8178

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

8784

88-
@device_factory(skip=True)
85+
@devices.factory(skip=True)
8986
def xspress3() -> Xspress3:
9087
"""16 channels Xspress3 detector."""
9188
return Xspress3(

0 commit comments

Comments
 (0)