id3c.devices.interlocked_motor#
EpicsMotor with a Bluesky-session interlock.
Provides:
MotionInterlock– exception raised when a move is blocked.InterlockedEpicsMotor–ophyd.EpicsMotorsubclass that consults a caller-suppliedinterlock()callable both before starting a motion (pre-flight) and during the motion (mid-flight, via subscriptions on caller-supplied signals).
Scope and limitations#
This interlock lives entirely in the running Bluesky/Python session.
It does not write to any EPICS protection field (no DISP,
no SPMG Stop, no sequencer record). If this Python process
crashes, exits, or is bypassed (MEDM jog, caput, a different
Bluesky session, SPEC, etc.), the underlying EPICS motor is
unaffected by anything in this module.
For session-independent, hardware-grade protection (e.g. preventing
collisions regardless of which client commands the move), implement
the interlock in the IOC: a CALC/SCALC record, a state-notation
sequencer, or a soft record driving the motor’s DISP field.
Wiring pattern#
InterlockedEpicsMotor does not know about any particular other
device. The interlock condition is supplied late, typically in
startup.py after all devices have been created, e.g.:
omega = sample_stage.omega
omega.interlock = lambda: laser_optics.is_out
omega.interlock_description = "laser_optics OUT"
omega.interlock_watch = (
laser_optics.us.user_readback,
laser_optics.ds.user_readback,
)
This keeps the class reusable and avoids import cycles between mutually-interlocked devices.
Attributes#
Exceptions#
Raised when an |
Classes#
EpicsMotor that consults a callable interlock before and during moves. |
Module Contents#
- exception id3c.devices.interlocked_motor.MotionInterlock[source]#
Bases:
RuntimeErrorRaised when an
InterlockedEpicsMotormove is blocked.The exception message is intended to be self-diagnostic so that the final line of a (typically long) Bluesky traceback identifies both the affected motor and the interlock that blocked it.
Initialize self. See help(type(self)) for accurate signature.
- class id3c.devices.interlocked_motor.InterlockedEpicsMotor(*args, interlock_description: str = '', **kwargs)[source]#
Bases:
ophyd.EpicsMotorEpicsMotor that consults a callable interlock before and during moves.
- Parameters:
interlock_description (str, optional) – Short human-readable description of the interlock condition, used in
MotionInterlockmessages. May be supplied via YAML (it is popped from kwargs beforesuper().__init__).
Notes
The
interlockcallable andinterlock_watchsignals are assigned as plain attributes (not Components) and are expected to be wired after construction; see the module docstring.If
interlockisNone(the default), this class behaves identically to a plainEpicsMotor.Initialize; pop
interlock_descriptionbefore EpicsMotor.interlockandinterlock_watchare initialized to inert defaults and are expected to be assigned post-construction (see the module docstring).- move(position, wait=True, **kwargs)[source]#
Pre-flight interlock check, then EpicsMotor.move.
- Raises:
MotionInterlock – If
self.interlockis wired and returnsFalseat the time of the call. No EPICS write is performed in that case.