Skip to content

Commit a6b6a3f

Browse files
committed
Update beamline howto docs
1 parent 7caa827 commit a6b6a3f

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

docs/how-to/create-beamline.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,39 @@ The following example creates a fictitious beamline ``w41``, with a simulated tw
2323

2424
```python
2525

26+
from functools import cache
27+
from pathlib import Path
28+
from ophyd_async.core import PathProvider
2629
from ophyd_async.epics.adaravis import AravisDetector
2730

28-
from dodal.common.beamlines.beamline_utils import (
29-
device_factory,
30-
get_path_provider,
31-
set_path_provider,
32-
)
3331
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
3432
from dodal.common.beamlines.device_helpers import CAM_SUFFIX, HDF5_SUFFIX
35-
from dodal.common.visit import LocalDirectoryServiceClient, StaticVisitPathProvider
33+
from dodal.common.visit import RemoteDirectoryServiceClient, StaticVisitPathProvider
34+
from dodal.device_manager import DeviceManager
3635
from dodal.devices.synchrotron import Synchrotron
3736
from dodal.log import set_beamline as set_log_beamline
38-
from dodal.utils import BeamlinePrefix
37+
from dodal.utils import BeamlinePrefix, get_beamline_name
3938

4039
BL = get_beamline_name("s41") # Default used when not on a live beamline
4140
PREFIX = BeamlinePrefix(BL)
4241
set_log_beamline(BL) # Configure logging and util functions
4342
set_utils_beamline(BL)
4443

45-
# Currently we must hard-code the visit, determining the visit is WIP.
46-
set_path_provider(
47-
StaticVisitPathProvider(
44+
devices = DeviceManager()
45+
46+
@devices.fixture
47+
@cache
48+
def path_provider() -> PathProvider:
49+
# Currently we must hard-code the visit, determining the visit is WIP.
50+
return StaticVisitPathProvider(
4851
BL,
4952
# Root directory for all detectors
5053
Path("/dls/w41/data/YYYY/cm12345-1"),
5154
# Uses an existing GDA server to ensure filename uniqueness
5255
client=RemoteDirectoryServiceClient("http://s41-control:8088/api"),
5356
# Else if no GDA server use a LocalDirectoryServiceClient(),
5457
)
55-
)
58+
5659

5760
"""
5861
Define device factory functions below this point.
@@ -63,23 +66,22 @@ The following example creates a fictitious beamline ``w41``, with a simulated tw
6366
"""
6467
This decorator gives extra desirable behaviour to this factory function:
6568
- it may be instantiated automatically, selectively on live beamline
66-
- caching and re-using the result for subsequent calls
6769
- it automatically names the device if no name is explicitly set
6870
- it may be skipped when make_all_devices is called on this module
6971
- it must be explicitly connected (which may be automated by tools)
7072
- when connected it may connect to a simulated backend
7173
- it may be connected concurrently (when automated by tools)
72-
""""
73-
@device_factory(skip = BL == "s41")
74+
"""
75+
@devices.factory(skip = BL == "s41")
7476
def synchrotron() -> Synchrotron:
7577
return Synchrotron()
7678

7779

78-
@device_factory()
79-
def d11() -> AravisDetector:
80+
@devices.factory()
81+
def d11(path_provider: PathProvider) -> AravisDetector:
8082
return AravisDetector(
8183
f"{PREFIX.beamline_prefix}-DI-DCAM-01:",
82-
path_provider=get_path_provider(),
84+
path_provider=path_provider,
8385
drv_suffix=CAM_SUFFIX,
8486
fileio_suffix=HDF5_SUFFIX,
8587
)

0 commit comments

Comments
 (0)