Write Devices for Blueapi#

See also

Home of Plans and Devices for information about where device code usually lives.

Format#

See also

Dodal for many more examples

Devices are made using the dodal style available through factory functions like this:

from dodal.common.beamlines.beamline_utils import device_factory
from dodal.devices.bimorph_mirror import BimorphMirror


@device_factory()
def oav() -> BimorphMirror:
    return BimorphMirror("BLXXI-BMRPH-01:", number_of_channels=8)

The return type annotation -> MyTypeOfDetector is required as blueapi uses it to determine that this function creates a device. Meaning you can have a Python file where only some functions create devices, and they will be automatically picked up. Similarly, these functions can be organized per-preference into files.

The device is created via a function rather than a global to preserve side-effect-free imports. Each device must have its own factory function.

See also

Numtracker integration for how to configure where detectors write files.