IEEE488.2#
Every SCPI interface is based on the IEEE488.2 protocol. This Python implementation separates the protocol into two layers:
IEEE488.2 layer: IEEE488.2 layer that implements the protocol based on the transport layer.
Transport layer: Transport layers responsible for lowest level of communication (e.g. Ethernet or dummy).”
IEEE488.2 layer#
- class Ieee488_2(transport, debug=DebugLevel.MINIMAL_CHECK)[source]#
Bases:
objectClass that implements the IEEE488.2 interface.
- __init__(transport, debug=DebugLevel.MINIMAL_CHECK)[source]#
Creates IEEE488.2 interface object.
- Parameters:
transport (
Transport) – Transport class responsible for the lowest level of communication (e.g. ethernet).debug (
DebugLevel(default:<DebugLevel.MINIMAL_CHECK: 0>)) – Debug level. SeeDebugLevelfor more information. By default None, which means that for a connection to a dummy cluster, DebugLevel.ERROR_CHECK will be used, and for a real cluster, DebugLevel.MINIMAL_CHECK.
- async close()[source]#
Close the connection to the instrument. It can not be used afterwards.
- Return type:
- fast_error_check(*raw_data)#
Inspects raw SCPI responses for firmware error sentinels. Triggers a full error queue check if a sentinel is detected.
- Parameters:
*raw_data (
Any) – The raw response data returned from the SCPI read operation. Accepts multiple arguments if a command returns multiple variables.- Raises:
RuntimeError – An error was found in the system error queue after a sentinel was detected.
- Return type:
- get_operation_complete()#
Get operation complete state.
- get_service_request_enable()#
Get service request enable register. The register is cleared after reading it.
- get_standard_event_status()#
Get standard event status register. The register is cleared after reading it.
- get_standard_event_status_enable()#
Get standard event status enable register. The register is cleared after reading it.
- get_status_byte()#
Get status byte register. Register is only cleared when feeding registers are cleared.
- set_operation_complete()#
Set device in operation complete query active state.
- set_service_request_enable(reg)#
Set service request enable register.
- set_standard_event_status_enable(reg)#
Set standard event status enable register.
- test()#
Run self-test.
Transport layer#
- class IpTransport(host, port=5025, timeout=60.0, snd_buf_size=524288, loop_from=None, use_running_loop=False)[source]#
Bases:
TransportClass for data transport of IP socket.
- __init__(host, port=5025, timeout=60.0, snd_buf_size=524288, loop_from=None, use_running_loop=False)[source]#
Create IP socket transport class.
- Parameters:
host (
str) – Instrument IP address.port (
int(default:5025)) – Instrument port.timeout (
float(default:60.0)) – Instrument call timeout in seconds.snd_buf_size (
int(default:524288)) – Instrument buffer size for transmissions to instrument.loop_from (
Transport|None(default:None)) – Transport to use event loop from: bypasses use_running_loop checks.use_running_loop (
bool(default:False)) – Whether to use an existing event loop if it is already running; use this only if you are supplying your own event loop and only invoking asynchronous functions, or if the event loop is not running when invoking synchronous command functions. Default to False.
- async readline()[source]#
Read data from instrument over IP socket.
- Return type:
- Returns:
str String with data.
- class ClusterDummyTransport(dummy_cfg, loop_from=None, use_running_loop=False)[source]#
Bases:
DummyTransportClass to replace Cluster device with dummy device to support software stack testing without hardware. The class implements all mandatory, required and Cluster specific SCPI calls. Call responses are largely artificially constructed to be inline with the call’s functionality (e.g. *IDN? returns valid, but artificial IDN data). To assist development, the Q1ASM assembler has been completely implemented. Please have a look at the call’s implementation to know what to expect from its response.
- __init__(dummy_cfg, loop_from=None, use_running_loop=False)[source]#
Create Cluster dummy transport class.
- Parameters:
dummy_cfg (
DummyConfiguration|dict[str|int,ClusterType]) – Dictionary of dummy module types (e.g. Cluster QCM, Cluster QRM). Each key of the dictionary is a slot index with a dummy type specification of typeClusterType.loop_from (
Transport|None(default:None)) – Transport to use event loop from: bypasses use_running_loop checks.use_running_loop (
bool(default:False)) – Whether to use an existing event loop if it is already running; use this only if you are supplying your own event loop and only invoking asynchronous functions, or if the event loop is not running when invoking synchronous command functions. Default to False.
- delete_dummy_binned_acquisition_data(slot_idx, sequencer=None, acq_index_name=None)[source]#
Delete all dummy binned acquisition data for the dummy.
- delete_dummy_scope_acquisition_data(slot_idx)[source]#
Delete dummy scope acquisition data for the dummy.
- get_module_transport(slot_idx)[source]#
Get transport for individual module.
- set_dummy_binned_acquisition_data(slot_idx, sequencer, acq_index_name, data)[source]#
Set dummy binned acquisition data for the dummy.
- Parameters:
- Return type:
- set_dummy_scope_acquisition_data(slot_idx, data)[source]#
Set dummy scope acquisition data for the dummy.
- Parameters:
slot_idx (
int) – Slot of the hardware you want to set the data to on a cluster.data (
DummyScopeAcquisitionData) – Dummy data for the scope acquisition.
- Return type:
Supporting classes and functions#
- class ModuleDummyTransport(dummy_type, loop_from=None, use_running_loop=False)[source]#
Bases:
DummyTransportClass to replace a module with a dummy device to support software stack testing without hardware. The class implements all mandatory, required and module specific SCPI calls. Call responses are largely artificially constructed to be inline with the call’s functionality (e.g. *IDN? returns valid, but artificial IDN data). To assist development, the Q1ASM assembler has been completely implemented. Please have a look at the call’s implementation to know what to expect from its response.
- __init__(dummy_type, loop_from=None, use_running_loop=False)[source]#
Create module dummy transport class.
- Parameters:
dummy_type (
ClusterType) – Dummy module typeloop_from (
Transport|None(default:None)) – Transport to use event loop from: bypasses use_running_loop checks.use_running_loop (
bool(default:False)) – Whether to use an existing event loop if it is already running; use this only if you are supplying your own event loop and only invoking asynchronous functions, or if the event loop is not running when invoking synchronous command functions. Default to False.
- delete_dummy_binned_acquisition_data(sequencer=None, acq_index_name=None)[source]#
Set dummy binned acquisition data for the dummy.
- delete_dummy_scope_acquisition_data()[source]#
Delete dummy scope acquisition data for the dummy.
- Return type:
- set_dummy_binned_acquisition_data(sequencer, acq_index_name, data)[source]#
Set dummy binned acquisition data for the dummy.
- set_dummy_scope_acquisition_data(data)[source]#
Set dummy scope acquisition data for the dummy.
- Parameters:
data (
DummyScopeAcquisitionData) – Dummy data for the scope acquisition.- Return type:
- property is_eom_type: bool#
Return if module is of type EOM.
- Returns:
bool True if module is of type EOM.
- property is_linq_type: bool#
Return if module is of type LINQ.
- Returns:
bool True if module is of type LINQ.
- property is_qcm_type: bool#
Return if module is of type QCM.
- Returns:
bool True if module is of type QCM.
- property is_qdm_type: bool#
Return if module is of type QDM.
- Returns:
bool True if module is of type QDM.
- property is_qrc_type: bool#
Return if module is of type QRC.
- Returns:
bool True if module is of type QRC.
- property is_qrm_type: bool#
Return if module is of type QRM.
- Returns:
bool True if module is of type QRM.
- property is_qsm_type: bool#
Return if module is of type QSM.
- Returns:
bool True if module is of type QSM.
- property is_qtm_type: bool#
Return if module is of type QTM.
- Returns:
bool True if module is of type QTM.
- property is_rf_type: bool#
Return if module is of type QCM-RF or QRM-RF.
- Returns:
bool True if module is of type QCM-RF or QRM-RF.
- property module_type: InstrumentType#
Return module type.
- Returns:
InstrumentType Module type.
- class DummyTransport(dummy_type, sw_scpi_version=(1, 2), loop_from=None, use_running_loop=False)[source]#
-
Class to replace device with dummy device to support software stack testing without hardware. The class implements all mandatory and required SCPI calls. Call responses are largely artificially constructed to be inline with the call’s functionality (e.g. *IDN? returns valid, but artificial IDN data).
- __init__(dummy_type, sw_scpi_version=(1, 2), loop_from=None, use_running_loop=False)[source]#
Create dummy transport class.
- Parameters:
dummy_type (
ClusterType) – Dummy instrument typesw_scpi_version (
tuple[int,...] (default:(1, 2))) – SCPI layer version.loop_from (
Transport|None(default:None)) – Transport to use event loop from: bypasses use_running_loop checks.use_running_loop (
bool(default:False)) – Whether to use an existing event loop if it is already running; use this only if you are supplying your own event loop and only invoking asynchronous functions, or if the event loop is not running when invoking synchronous command functions. Default to False.
- abstractmethod delete_dummy_binned_acquisition_data(sequencer=None, acq_index_name=None)[source]#
Delete all dummy binned acquisition data for the dummy.
- abstractmethod delete_dummy_scope_acquisition_data()[source]#
Delete dummy scope acquisition data for the dummy.
- Raises:
ValueError – If the slot_idx doesn’t make sense for the transport.
- Return type:
- get_cmd_hist()[source]#
Get list of every executed command since the initialization or reset of the class.
- abstractmethod set_dummy_binned_acquisition_data(sequencer, acq_index_name, data)[source]#
Set dummy binned acquisition data for the dummy.
- Parameters:
sequencer (
int) – Sequencer.acq_index_name (
str) – Acquisition index name.data (
Iterable[DummyBinnedAcquisitionData|None]) – Dummy data for the binned acquisition. An iterable of all the bin values.
- Raises:
ValueError – If the slot_idx doesn’t make sense for the transport.
- Return type:
- abstractmethod set_dummy_scope_acquisition_data(data)[source]#
Set dummy scope acquisition data for the dummy.
- Parameters:
data (
DummyScopeAcquisitionData) – Dummy data for the scope acquisition.- Raises:
ValueError – If the slot_idx doesn’t make sense for the transport.
- Return type:
- class Transport(loop_from=None, use_running_loop=False)[source]#
Bases:
objectAbstract base class for data transport to instruments.
- __init__(loop_from=None, use_running_loop=False)[source]#
Create transport instance.
- Parameters:
loop_from (
Transport|None(default:None)) – Transport to use event loop from: bypasses use_running_loop checks.use_running_loop (
bool(default:False)) – Whether to use an existing event loop if it is already running; use this only if you are supplying your own event loop and only invoking asynchronous functions, or if the event loop is not running when invoking synchronous command functions. Default to False.
- abstractmethod async read_binary(size)[source]#
Abstract method to read binary data from instrument.
- abstractmethod async readline()[source]#
Abstract method to read data from instrument.
- Return type:
- Returns:
str String with data.
- abstractmethod async write_binary(*data)[source]#
Abstract method to write binary data to instrument.
- property loop: BaseEventLoop#
Event loop for this transport.
- class DummyBinnedAcquisitionData(data, thres, avg_cnt)[source]#
Bases:
objectClass to hold data for the dummy hardware for the binned acquisition. This class contains all values for one bin.
- __init__(data, thres, avg_cnt)#