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)[source]#

Bases: object

Class that implements the IEEE488.2 interface.

__init__(transport)[source]#

Creates IEEE488.2 interface object.

Parameters:

transport (Transport) – Transport class responsible for the lowest level of communication (e.g. ethernet).

Transport layer#

class IpTransport(host, port=5025, timeout=60.0, snd_buf_size=524288)[source]#

Bases: Transport

Class for data transport of IP socket.

__init__(host, port=5025, timeout=60.0, snd_buf_size=524288)[source]#

Create IP socket transport class.

Parameters:
  • host (str) – Instrument IP address.

  • port (int) – Instrument port.

  • timeout (float) – Instrument call timeout in seconds.

  • snd_buf_size (int) – Instrument buffer size for transmissions to instrument.

close()[source]#

Close IP socket.

Return type:

None

read_binary(size)[source]#

Read binary data from instrument over IP socket.

Parameters:

size (int) – Number of bytes

Return type:

bytes

Returns:

bytes Binary data array of length “size”.

readline()[source]#

Read data from instrument over IP socket.

Return type:

str

Returns:

str String with data.

write(cmd_str)[source]#

Write command to instrument over IP socket.

Parameters:

cmd_str (str) – Command

Return type:

None

write_binary(*data)[source]#

Write binary data to instrument over IP socket.

Parameters:

*data (bytes) – Binary data

Return type:

None

class ClusterDummyTransport(dummy_cfg)[source]#

Bases: DummyTransport

Class 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)[source]#

Create Cluster dummy transport class.

Parameters:

dummy_cfg (dict) – 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 type ClusterType.

delete_dummy_binned_acquisition_data(slot_idx, sequencer=None, acq_index_name=None)[source]#

Delete all dummy binned acquisition data for the dummy.

Parameters:
  • slot_idx (int) – Slot of the hardware you want to set the data to on a cluster.

  • sequencer (Optional[int]) – Sequencer.

  • acq_index_name (Optional[str]) – Acquisition index name.

Return type:

None

delete_dummy_scope_acquisition_data(slot_idx)[source]#

Delete 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.

Return type:

None

set_dummy_binned_acquisition_data(slot_idx, sequencer, acq_index_name, data)[source]#

Set dummy binned acquisition data for the dummy.

Parameters:
  • slot_idx (int) – Slot of the hardware you want to set the data to on a cluster.

  • sequencer (int) – Sequencer.

  • acq_index_name (str) – Acquisition index name.

  • data (Iterable[Union[DummyBinnedAcquisitionData, None]]) – Dummy data for the binned acquisition. An iterable of all the bin values.

Return type:

None

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:

None

Supporting classes and functions#

class ModuleDummyTransport(dummy_type)[source]#

Bases: DummyTransport

Class 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)[source]#

Create module dummy transport class.

Parameters:

dummy_type (ClusterType) – Dummy module type

delete_dummy_binned_acquisition_data(sequencer=None, acq_index_name=None)[source]#

Set dummy binned acquisition data for the dummy.

Parameters:
  • sequencer (Optional[int]) – Sequencer.

  • acq_index_name (Optional[str]) – Acquisition index name.

Return type:

None

delete_dummy_scope_acquisition_data()[source]#

Delete dummy scope acquisition data for the dummy.

Return type:

None

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[Union[DummyBinnedAcquisitionData, None]]) – Dummy data for the binned acquisition. An iterable of all the bin values.

Return type:

None

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:

None

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)[source]#

Bases: ABC, Transport

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)[source]#

Create dummy transport class.

Parameters:

dummy_type (ClusterType) – Dummy instrument type

close()[source]#

Close and resets base dummy transport class.

Return type:

None

abstract delete_dummy_binned_acquisition_data(sequencer=None, acq_index_name=None)[source]#

Delete all dummy binned acquisition data for the dummy.

Parameters:
  • sequencer (Optional[int]) – Sequencer.

  • acq_index_name (Optional[str]) – Acquisition index name.

Raises:

ValueError – If the slot_idx doesn’t make sense for the transport.

Return type:

None

abstract 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:

None

get_cmd_hist()[source]#

Get list of every executed command since the initialization or reset of the class.

Return type:

list

Returns:

list List of executed command strings including arguments (does not include binary data argument).

read_binary(size)[source]#

Read binary data from dummy.

Parameters:

size (int) – Number of bytes

Return type:

bytes

Returns:

bytes Binary data array of length “size”.

readline()[source]#

Read data from dummy.

Return type:

str

Returns:

str String with data.

abstract 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[Union[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:

None

abstract 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:

None

write(cmd_str)[source]#

Write command to dummy. Stores command in command history.

Parameters:

cmd_str (str) – Command

Return type:

None

write_binary(*data)[source]#

Write binary data to dummy. Stores command in command history.

Parameters:

*data (bytes) – Binary data

Return type:

None

property instrument_class: str#

Get instrument class (e.g. Cluster).

Returns:

str Instrument class

property instrument_type: str#

Get instrument type (e.g. MM, QRM, QCM).

Returns:

str Instrument type

class Transport[source]#

Bases: object

Abstract base class for data transport to instruments.

abstract close()[source]#

Abstract method to close instrument.

Return type:

None

abstract read_binary(size)[source]#

Abstract method to read binary data from instrument.

Parameters:

size (int) – Number of bytes

Return type:

bytes

Returns:

bytes Binary data array of length “size”.

abstract readline()[source]#

Abstract method to read data from instrument.

Return type:

str

Returns:

str String with data.

abstract write(cmd_str)[source]#

Abstract method to write command to instrument.

Parameters:

cmd_str (str) – Command

Return type:

None

abstract write_binary(*data)[source]#

Abstract method to write binary data to instrument.

Parameters:

*data (bytes) – Binary data

Return type:

None

class DummyBinnedAcquisitionData(data, thres, avg_cnt)[source]#

Bases: object

Class to hold data for the dummy hardware for the binned acquisition. This class contains all values for one bin.

__init__(data, thres, avg_cnt)#
avg_cnt: int#
data: tuple[float, float]#
thres: int#
class DummyScopeAcquisitionData(data, out_of_range, avg_cnt)[source]#

Bases: object

Class to hold data for the dummy hardware for the scope acquisition. This class contains all values for the scope acquisition on one module.

__init__(data, out_of_range, avg_cnt)#
avg_cnt: tuple[int, int]#
data: Iterable[tuple[float, float]]#
out_of_range: tuple[bool, bool]#