AareBEC prototype
Prototype of a BEC-integrated replacement for AareDAQ, the Data Acquisition system for MX beamlines at PSI.
Running
In one terminal, run the aare_bec service prototype:
uv venv && source .venv/bin/activate
uv pip install -e .[test]
bec-server start
aare-bec-proto
In another, the client:
source .venv/bin/activate
bec --nogui
bec.config.update_session_with_file("/path/to/config.yaml")
The demo config can be found in src/aare_bec_proto/configs/mx_demo_config.yaml
Simulated MX beamline
src/aare_bec_proto/configs/mx_demo_config.yaml describes a fully simulated MX
endstation. It references simulated devices, from ophyd_devices.sim and from
aare_bec_proto.devices:
| Device | Class | What it is |
|---|---|---|
eiger |
ophyd_devices.SimCamera |
Area detector, software triggered |
aerotech |
aare_bec_proto.devices.SimAerotechStage |
x/y/z (mm) + unbounded omega (deg) |
gonio |
aare_bec_proto.devices.SimGoniometer |
Smargon head: x/y/z (mm), phi, chi |
robot |
aare_bec_proto.devices.SimSampleChanger |
mount(puck, position) / unmount() |
ring_current |
ophyd_devices.sim.sim_signals.SetableSignal |
Settable scalar, 400 mA by default |
fast_shutter |
ophyd_devices.sim.sim_signals.SetableSignal |
Settable 0/1 |
energy |
ophyd_devices.SimPositioner |
5–20 keV |
The package registers itself as a BEC plugin ([project.entry-points."bec"]),
which is what lets the device server resolve the aare_bec_proto.devices.*
classes. It therefore has to be installed in the device server's environment,
and BEC only tolerates one bec plugin per environment, so it's not compatible
with a beamline plugin such as pxiii_bec. We will migrate any devices to
mx_bec or beamline plugins in the future as necessary.
Beamline states and actors
The signals on the simulated devices are numeric on purpose, so they can be fed
straight into DeviceWithinLimitsState and then into actors such as the
builtin ScanInterlockActor:
from bec_lib.bl_states import DeviceWithinLimitsStateConfig
bec.beamline_states.add(
DeviceWithinLimitsStateConfig(name="beam_ok", device="ring_current", low_limit=300)
)
bec.beamline_states.add(
DeviceWithinLimitsStateConfig(name="robot_idle", device="robot", high_limit=0.5)
)
# Lock the primary scan queue whenever either state is not valid
interlock = bec.builtin_actors.scan_interlock
interlock.enabled = True
interlock.add_state_to_interlock("beam_ok", "valid")
interlock.add_state_to_interlock("robot_idle", "valid")
dev.ring_current.set(0) # -> beam_ok becomes invalid, queue is locked
dev.ring_current.set(400) # -> lock is released
dev.robot.mount(1, 3) # -> robot_idle is invalid for mount_time seconds
SimSampleChanger is the template for adding further MX logic: a PSIDeviceBase
subclass with integer status signals, verb-named methods exposed through
USER_ACCESS, and background work reported through a DeviceStatus.