Skip to content

Commit 483b93d

Browse files
docs: Add ADR for suggested device creation flow (#1230)
* docs: Add ADR for suggested device creation flow * docs: Move instructions into and tidy docs * Update create-device.md
1 parent a239aaa commit 483b93d

File tree

3 files changed

+49
-67
lines changed

3 files changed

+49
-67
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 5. Encourage aliasing at EPICS level
2+
3+
Date: 2025-05-13
4+
5+
## Status
6+
7+
Proposed
8+
9+
## Context
10+
11+
Many devices have the same functional set of PVs with differing addresses, requiring that either device classes in dodal are generic to support them or duplicate classes are created and must be maintained.
12+
13+
## Decision
14+
15+
Dodal device classes should be made generic before duplicate classes are created, to ensure that upgrades and benefits are shared. Prior to making a device class generic a reasonable attempt should be made to unify the devices at the epics level.
16+
17+
When a new device is onboarded into dodal, there should be clear guidance for the support and controls engineers to use to determine whether an alias should be added to the support module or configurability should be added to the device class.
18+
19+
## Consequences
20+
21+
Documentation on making new devices has been updated and the commitment to trying to standardise devices has been codified.

docs/how-to/create-device.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Creating a new device
2+
---------------------
3+
4+
Devices are written using the ophyd-async framework, the hardware abstraction library at Diamond.
5+
6+
Reusing an existing class
7+
=========================
8+
9+
When creating a new device, first check if there is a device class that claims to support the device: e.g. all EPICS Motor records should use the [Motor](https://github.com/bluesky/ophyd-async/blob/main/src/ophyd_async/epics/motor.py) type; for reading or monitoring signals from the storage ring the [Synchrotron](https://github.com/DiamondLightSource/dodal/blob/main/src/dodal/devices/synchrotron.py) device should be used; AreaDetectors should use the [StandardDetector](https://github.com/bluesky/ophyd-async/blob/main/src/ophyd_async/core/_detector.py) type- of which there are examples in ophyd_async and in dodal.
10+
11+
If there is a compatible device class it should be used- adding it to the [the beamline](./create-beamline.rst)- this prevents reimplementing the device, and allows improvements to be shared. Improving the device to meet your use case is better than starting again.
12+
13+
If a device class is incompatible due to differences in PV address only, first request that an alias is added to the EPICS support module for the IOC - or request support in making that change. Only if it is not possible to add an alias, for example the support module is proprietary, add configurability to the dodal device class, taking care not to break existing devices- e.g. make new fields have a default that matches the existing pattern, and ensure that `dodal connect` is still able to connect to the device for the existing instances.
14+
15+
If the device class is sufficiently different (or you cannot find a similar device), create a device that connects to the required signals and can be tested for your desired behaviour. During the review process, attempts to bring it closer in line with existing devices may allow to deduplicate some parts, through inheritance or composition of the device from existing components.
16+
17+
18+
Writing a device class
19+
======================
20+
21+
The aim should be to get a new device ready for testing it on the beamline as soon as possible, to ensure fast iteration: write a device against your assumptions of how it should work, write tests against those assumptions then test your assumptions on the beamline. Write issues from beamline testing, to resolve offline to reserve as much time for testing that requires the beamline as possible.
22+
23+
Dodal's CLI `dodal connect <beamline>` is a useful way to verify that PV addresses are correct, together with `cainfo <PV address>` to find the datatype of signals.
24+
25+
If you're not sure how to represent a PV as a Signal: ask! Seek feedback early (e.g. by opening a draft PR) and merge with other devices where it makes sense to. The test suite should provide confidence to do so without breaking existing code.
26+
27+
28+
.. _ophyd-async: https://blueskyproject.io/ophyd-async/main/how-to/choose-interfaces-for-devices.html

docs/how-to/make-new-ophyd-async-device.rst

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)