|
| 1 | +from functools import cache |
1 | 2 | from pathlib import Path |
2 | 3 |
|
| 4 | +from ophyd_async.core import PathProvider |
3 | 5 | from ophyd_async.epics.motor import Motor |
4 | 6 | from ophyd_async.epics.pmac import PmacIO |
5 | 7 | from ophyd_async.fastcs.panda import HDFPanda |
6 | 8 |
|
7 | | -from dodal.common.beamlines.beamline_utils import ( |
8 | | - device_factory, |
9 | | - get_path_provider, |
10 | | - set_path_provider, |
11 | | -) |
12 | 9 | from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline |
13 | 10 | from dodal.common.visit import RemoteDirectoryServiceClient, StaticVisitPathProvider |
| 11 | +from dodal.device_manager import DeviceManager |
14 | 12 | from dodal.devices.turbo_slit import TurboSlit |
15 | 13 | from dodal.devices.xspress3.xspress3 import Xspress3 |
16 | 14 | from dodal.log import set_beamline as set_log_beamline |
|
21 | 19 | set_log_beamline(BL) |
22 | 20 | set_utils_beamline(BL) |
23 | 21 |
|
| 22 | +devices = DeviceManager() |
24 | 23 |
|
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( |
32 | 29 | BL, |
33 | | - Path("/dls/p51/data/2026/cm44254-1/tmp"), |
| 30 | + Path("/dls/p51/data/2026/cm44254-1"), |
34 | 31 | client=RemoteDirectoryServiceClient("http://i20-1-control:8088/api"), |
35 | 32 | ) |
36 | | -) |
| 33 | + |
37 | 34 |
|
38 | 35 | """ |
39 | 36 | NOTE: Due to the CA gateway machine being switched off, PVs are not available remotely |
|
43 | 40 | """ |
44 | 41 |
|
45 | 42 |
|
46 | | -@device_factory() |
| 43 | +@devices.factory() |
47 | 44 | def turbo_slit() -> TurboSlit: |
48 | 45 | """Turboslit for selecting energy from the polychromator.""" |
49 | 46 | return TurboSlit(f"{PREFIX.beamline_prefix}-OP-PCHRO-01:TS:") |
50 | 47 |
|
51 | 48 |
|
52 | | -@device_factory() |
| 49 | +@devices.factory() |
53 | 50 | def turbo_slit_x() -> Motor: |
54 | 51 | """Turbo slit x motor.""" |
55 | 52 | return Motor(f"{PREFIX.beamline_prefix}-OP-PCHRO-01:TS:XFINE") |
56 | 53 |
|
57 | 54 |
|
58 | | -@device_factory() |
59 | | -def turbo_slit_pmac() -> PmacIO: |
| 55 | +@devices.factory() |
| 56 | +def turbo_slit_pmac(turbo_slit_x: Motor) -> PmacIO: |
60 | 57 | """PMac controller using running fly scans with trajectory.""" |
61 | | - motor = turbo_slit_x() |
62 | 58 | return PmacIO( |
63 | 59 | prefix=f"{PREFIX.beamline_prefix}-MO-STEP-06:", |
64 | | - raw_motors=[motor], |
| 60 | + raw_motors=[turbo_slit_x], |
65 | 61 | coord_nums=[3], |
66 | 62 | ) |
67 | 63 |
|
68 | 64 |
|
69 | | -@device_factory() |
70 | | -def panda() -> HDFPanda: |
| 65 | +@devices.factory() |
| 66 | +def panda(path_provider: PathProvider) -> HDFPanda: |
71 | 67 | 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, |
73 | 70 | ) |
74 | 71 |
|
75 | 72 |
|
76 | 73 | # Use mock device until motors are reconnected on the beamline |
77 | | -@device_factory(mock=True) |
| 74 | +@devices.factory(mock=True) |
78 | 75 | def alignment_x() -> Motor: |
79 | 76 | return Motor(f"{PREFIX.beamline_prefix}-MO-STAGE-01:X") |
80 | 77 |
|
81 | 78 |
|
82 | 79 | # Use mock device until motors are reconnected on the beamline |
83 | | -@device_factory(mock=True) |
| 80 | +@devices.factory(mock=True) |
84 | 81 | def alignment_y() -> Motor: |
85 | 82 | return Motor(f"{PREFIX.beamline_prefix}-MO-STAGE-01:Y") |
86 | 83 |
|
87 | 84 |
|
88 | | -@device_factory(skip=True) |
| 85 | +@devices.factory(skip=True) |
89 | 86 | def xspress3() -> Xspress3: |
90 | 87 | """16 channels Xspress3 detector.""" |
91 | 88 | return Xspress3( |
|
0 commit comments