resonance.api.core.primitives¶
resonance.api.core.primitives
¶
Low-level safe async primitives for beamline control
AbortFlag()
¶
wait_for_motors(server, motors, timeout=30.0, check_interval=0.05, abort_flag=None)
async
¶
Wait for all motors to complete movement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server
|
BCSServer
|
BCS server instance |
required |
motors
|
list[str]
|
Motor names to wait for |
required |
timeout
|
float
|
Maximum time to wait in seconds |
30.0
|
check_interval
|
float
|
Time between status checks |
0.05
|
abort_flag
|
AbortFlag or None
|
Optional abort flag to check |
None
|
Raises:
| Type | Description |
|---|---|
MotorTimeoutError
|
If timeout exceeded |
ScanAbortedError
|
If abort_flag is set |
Source code in src/resonance/api/core/primitives.py
wait_for_settle(delay, abort_flag=None)
async
¶
Wait for motor settling with abort check.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delay
|
float
|
Time to wait in seconds |
required |
abort_flag
|
AbortFlag or None
|
Optional abort flag to check |
None
|
Raises:
| Type | Description |
|---|---|
ScanAbortedError
|
If abort_flag is set during wait |
Source code in src/resonance/api/core/primitives.py
motor_move(server, motors, timeout=30.0, backlash=True, restore_on_exit=True)
async
¶
Context manager for safe motor movements with automatic position restoration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server
|
BCSServer
|
BCS server instance |
required |
motors
|
dict[str, float]
|
Motor name to target position mapping |
required |
timeout
|
float
|
Timeout for motor moves |
30.0
|
backlash
|
bool
|
Use backlash compensation |
True
|
restore_on_exit
|
bool
|
Restore initial positions on exit |
True
|
Yields:
| Type | Description |
|---|---|
dict[str, float]
|
Initial motor positions |
Raises:
| Type | Description |
|---|---|
MotorError
|
If motor move fails |
Examples:
Source code in src/resonance/api/core/primitives.py
shutter_control(server, shutter='Light Output', delay_before_open=0.0)
async
¶
Context manager for safe shutter control. Guarantees shutter closes even on exception.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server
|
BCSServer
|
BCS server instance |
required |
shutter
|
str
|
Shutter DIO channel name |
'Light Output'
|
delay_before_open
|
float
|
Delay before opening shutter |
0.0
|
Examples: