Basic Abstractions¶
This section covers the core abstract classes that serve as the foundation for all specific protocol implementations in AQPXLIB.
For instrument-level GPIO (read/drive/pulse/trigger), see GPIO.
Abstract Bus¶
The PxAbstractBus class defines the common interface for all protocol buses. It handles:
- Electrical configuration (voltage, pull-ups, etc.)
- Device attachment and management
- Common bus operations
PxAbstractBus
¶
PxAbstractBus(exerciser: AqProtocolExerciser)
Abstract Bus Class for all bus types.
| METHOD | DESCRIPTION |
|---|---|
get_config |
Get the configuration of the bus. |
get_target_pb_msg |
Get the configuration of the target from the bus. |
get_controller_pb_msg |
Get the configuration of the controller from the bus. |
remove_controller |
Remove a controller from the bus. |
remove_target |
Remove a target from the bus. |
remove_device |
Remove a device from the bus. |
get_device_state |
Get the state of the device from the bus. |
set_device_state |
Set the state of the device on the bus. |
get_device_pb_msg |
Get the configuration of the device from the bus. |
set_config |
Set the configuration of the bus. |
get_controllers |
Get the controllers of the bus. |
attach_controller |
Attach a controller to the bus. |
attach_target |
Attach a target to the bus. |
get_targets |
Get the targets of the bus. |
get_devices |
Get the devices of the bus. |
create_device |
Create a new device on the bus. |
add_event_handler |
Add an event handler to the current bus instance. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
available_devices_by_protobuf_key |
A mapping of device protobuf field name to device classes.
TYPE:
|
available_devices_by_identifier |
A mapping of device identifier (from abstract instance) to device classes.
TYPE:
|
handle_index |
The index of the bus interface.
TYPE:
|
voltage |
The voltage of the bus.
TYPE:
|
la_threshold_voltage |
The la threshold voltage of the bus.
TYPE:
|
pullup_resistance |
The pullup resistance of the bus.
TYPE:
|
pulldown_resistance |
The pulldown resistance of the bus.
TYPE:
|
bus_hold_enable |
The bus hold enable of the bus.
TYPE:
|
available_devices_by_protobuf_key
¶
available_devices_by_protobuf_key: dict[str, type[PxAbstractDevice]]
A mapping of device protobuf field name to device classes.
available_devices_by_identifier
¶
available_devices_by_identifier: dict[str, type[PxAbstractDevice]]
A mapping of device identifier (from abstract instance) to device classes.
get_target_pb_msg
¶
get_target_pb_msg(target: PxAbstractDevice) -> Message | None
Get the configuration of the target from the bus.
get_controller_pb_msg
¶
get_controller_pb_msg(controller: PxAbstractDevice) -> Message | None
Get the configuration of the controller from the bus.
remove_controller
¶
remove_controller(controller: PxAbstractDevice) -> None
Remove a controller from the bus.
get_device_state
¶
get_device_state(device: PxAbstractDevice) -> Message | None
Get the state of the device from the bus.
set_device_state
¶
set_device_state(device: PxAbstractDevice, state: Message) -> None
Set the state of the device on the bus.
get_device_pb_msg
¶
get_device_pb_msg(device: PxAbstractDevice) -> Message | None
Get the configuration of the device from the bus.
attach_controller
¶
attach_controller(controller: PxAbstractDevice) -> None
Attach a controller to the bus.
create_device
¶
create_device(
exerciser: AqProtocolExerciser, device_identifier: str, *args, **kwargs
) -> PxAbstractDevice
Create a new device on the bus.
A new device interface will be created and attached to the bus.
| PARAMETER | DESCRIPTION |
|---|---|
|
An exerciser instance which is used to send request to server
TYPE:
|
|
The unique identifier of the device to create
TYPE:
|
|
Additional arguments to pass to the device constructor
DEFAULT:
|
|
Additional keyword arguments to pass to the device constructor
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
PxAbstractDevice
|
The interface of the created device
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the |
Abstract Device¶
The PxAbstractDevice class is the base for all emulated devices (controllers and targets). It provides:
- Device identification and configuration
- State management
- Event handling
PxAbstractDevice
¶
PxAbstractDevice(
exerciser: AqProtocolExerciser,
bus: Optional[PxAbstractBus] = None,
name: str = "",
cts_op_name: str | None = None,
device_id: int = 0,
config: Message | None = None,
)
Abstract Device Class for all device types.
This class defines methods that are common to all device types.
| METHOD | DESCRIPTION |
|---|---|
detach_from_bus |
Detach the device from the bus. |
perform_operation |
Send an operation. |
add_event_handler |
Add an event handler to the current device instance. |
get_event_handlers |
Retreive handlers registerd on this device. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
is_attached |
Check if the device is attached to a bus.
TYPE:
|
state |
Get the state of the device.
TYPE:
|
name |
Get the name of the device.
TYPE:
|
config |
Get the config of the device.
TYPE:
|