resonance.api.core.dio¶
resonance.api.core.dio
¶
DIOAccessor(conn)
¶
Async interface for reading and writing BCS digital I/O channels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
BCSServer
|
Active BCSz server connection. |
required |
Notes
Wraps BCSz digital I/O channels. read reads digital inputs; set writes
digital outputs. The shutter channel ("Light Output", "Shutter Output", etc.)
is the most common use case. Values are always coerced to bool.
Examples:
>>> state = await bl.dio.read("Shutter Output", "Light Output")
>>> print(state)
{'Shutter Output': True, 'Light Output': True}
>>> await bl.dio.set("Shutter Output", False)
>>> await bl.dio.set("Light Output", True)
>>> state = await bl.dio.read("Shutter Output", "Light Output")
>>> print(state)
{'Shutter Output': False, 'Light Output': True}
Source code in src/resonance/api/core/dio.py
read(*channels)
async
¶
Read current state of one or more digital I/O channels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*channels
|
str
|
One or more DIO channel names to read. Must be members of the
|
()
|
Returns:
| Type | Description |
|---|---|
dict[str, bool]
|
Mapping of channel name to its current boolean state. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If any channel name is not a valid DIO channel. |
Notes
Channels are read in a single BCSz get_di call. The response
data field is coerced to bool for each channel.
Source code in src/resonance/api/core/dio.py
set(channel, value)
async
¶
Set a digital output channel to True (on) or False (off).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
str
|
DIO channel name to write. Must be a member of the |
required |
value
|
bool or int
|
Output value to set. Non-zero integers map to True, zero maps to False. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Raises:
| Type | Description |
|---|---|
KeyError
|
If |
ValueError
|
If |
ShutterError
|
If the BCSz |
Notes
Value is coerced to bool: any non-zero int is True, 0 is False. Typical use is controlling the beamline shutter (e.g. channel="Light Output").