Generic native interface functions¶
The native interface generic_func module contains the bulk of the functional code for the native interfaces
of the Pulsar and Cluster so that this code can be reused between instruments. The functions can be parametrized
using the FuncRefs
class that contains references to functions
of the native interfaces parent class.
- class qblox_instruments.native.generic_func.StateEnum(value)[source]¶
Bases:
Enum
State enum base class that arranges child enum string representations.
- class qblox_instruments.native.generic_func.StateTuple[source]¶
Bases:
object
State tuple base class that arranges child tuple string representations.
- class qblox_instruments.native.generic_func.SystemStatus(value)[source]¶
Bases:
StateEnum
System status enum.
- BOOTING = 'System is booting.'¶
- OKAY = 'System is okay.'¶
- CRITICAL = 'An error indicated by the flags occured, but has been resolved.'¶
- ERROR = 'An error indicated by the flags is occuring.'¶
- class qblox_instruments.native.generic_func.SystemStatusFlags(value)[source]¶
Bases:
StateEnum
System status flags enum.
- CARRIER_PLL_UNLOCKED = 'Carrier board PLL is unlocked.'¶
- FPGA_PLL_UNLOCKED = 'FPGA PLL is unlocked.'¶
- LO_PLL_UNLOCKED = 'Local oscillator PLL is unlocked.'¶
- FPGA_TEMPERATURE_OUT_OF_RANGE = 'FPGA temperature is out-of-range.'¶
- CARRIER_TEMPERATURE_OUT_OF_RANGE = 'Carrier board temperature is out-of-range.'¶
- AFE_TEMPERATURE_OUT_OF_RANGE = 'Analog-frontend board temperature is out-of-range.'¶
- LO_TEMPERATURE_OUT_OF_RANGE = 'Local oscillator board temperature is out-of-range.'¶
- BACKPLANE_TEMPERATURE_OUT_OF_RANGE = 'Backplane board temperature is out-of-range.'¶
- MODULE_NOT_CONNECTED = 'Module is not connected.'¶
- MODULE_FIRMWARE_INCOMPATIBLE = 'Module firmware is incompatible with the rest of the system.'¶
- MODULE_FF_CALIB_FAILED = 'The feedback network calibration failed.'¶
- class qblox_instruments.native.generic_func.SystemStatusSlotFlags(slot_flags: Dict = {})[source]¶
Bases:
SystemStatusSlotFlags
Tuple containing lists of Cluster slot status flag enums of type
SystemStatusFlags
. Each Cluster slot has its own status flag list attribute named slot<X>.
- class qblox_instruments.native.generic_func.SystemState(status, flags, slot_flags)[source]¶
Bases:
SystemState
,StateTuple
System status tuple returned by
get_system_state()
. The tuple contains a system status enum of typeSystemStatus
, a list of associated system status flag enums of typeSystemStatusFlags
and a tuple of typeSystemStatusSlotFlags
containing Cluster slot status flags.
- class qblox_instruments.native.generic_func.SequencerStatus(value)[source]¶
Bases:
StateEnum
Sequencer status enum.
- IDLE = 'Sequencer waiting to be armed and started.'¶
- ARMED = 'Sequencer is armed and ready to start.'¶
- RUNNING = 'Sequencer is running.'¶
- Q1_STOPPED = 'Classical part of the sequencer has stopped; waiting for real-time part to stop.'¶
- STOPPED = 'Sequencer has completely stopped.'¶
- class qblox_instruments.native.generic_func.SequencerStatusFlags(value)[source]¶
Bases:
StateEnum
Sequencer status flags enum.
- DISARMED = 'Sequencer was disarmed.'¶
- FORCED_STOP = 'Sequencer was stopped while still running.'¶
- SEQUENCE_PROCESSOR_Q1_ILLEGAL_INSTRUCTION = 'Classical sequencer part executed an unknown instruction.'¶
- SEQUENCE_PROCESSOR_RT_EXEC_ILLEGAL_INSTRUCTION = 'Real-time sequencer part executed an unknown instruction.'¶
- SEQUENCE_PROCESSOR_RT_EXEC_COMMAND_UNDERFLOW = 'Real-time sequencer part command queue underflow.'¶
- AWG_WAVE_PLAYBACK_INDEX_INVALID_PATH_0 = 'AWG path 0 tried to play an unknown waveform.'¶
- AWG_WAVE_PLAYBACK_INDEX_INVALID_PATH_1 = 'AWG path 1 tried to play an unknown waveform.'¶
- ACQ_WEIGHT_PLAYBACK_INDEX_INVALID_PATH_0 = 'Acquisition path 0 tried to play an unknown weight.'¶
- ACQ_WEIGHT_PLAYBACK_INDEX_INVALID_PATH_1 = 'Acquisition path 1 tried to play an unknown weight.'¶
- ACQ_SCOPE_DONE_PATH_0 = 'Scope acquisition for path 0 has finished.'¶
- ACQ_SCOPE_OUT_OF_RANGE_PATH_0 = 'Scope acquisition data for path 0 was out-of-range.'¶
- ACQ_SCOPE_OVERWRITTEN_PATH_0 = 'Scope acquisition data for path 0 was overwritten.'¶
- ACQ_SCOPE_DONE_PATH_1 = 'Scope acquisition for path 1 has finished.'¶
- ACQ_SCOPE_OUT_OF_RANGE_PATH_1 = 'Scope acquisition data for path 1 was out-of-range.'¶
- ACQ_SCOPE_OVERWRITTEN_PATH_1 = 'Scope acquisition data for path 1 was overwritten.'¶
- ACQ_BINNING_DONE = 'Acquisition binning completed.'¶
- ACQ_BINNING_FIFO_ERROR = 'Acqusition binning encountered internal FIFO error.'¶
- ACQ_BINNING_COMM_ERROR = 'Acqusition binning encountered internal communication error.'¶
- ACQ_BINNING_OUT_OF_RANGE = 'Acquisition binning data out-of-range.'¶
- ACQ_INDEX_INVALID = 'Acquisition tried to process an invalid acquisition.'¶
- ACQ_BIN_INDEX_INVALID = 'Acquisition tried to process an invalid bin.'¶
- TRIGGER_NETWORK_CONFLICT = 'Trigger network has encountered a conflict.'¶
- TRIGGER_NETWORK_MISSED_INTERNAL_TRIGGER = 'Trigger network missed an internal trigger.'¶
- OUTPUT_OVERFLOW = 'Output overflow.'¶
- CLOCK_INSTABILITY = 'Clock source instability occurred.'¶
- class qblox_instruments.native.generic_func.SequencerState(status, flags)[source]¶
Bases:
SequencerState
,StateTuple
Sequencer status tuple returned by
get_sequencer_state()
. The tuple contains a sequencer status enum of typeSequencerStatus
and a list of associated sequencer status flag enums of typeSequencerStatusFlags
.
- class qblox_instruments.native.generic_func.FuncRefs(instrument: Optional[Any] = None)[source]¶
Bases:
object
Function reference container intended to hold references to methods of the instrument’s SCPI and native interfaces that are called by methods in
generic_func
. In effect, this class enables passing parametrized methods to thegeneric_func
functions so that those functions can be reused between different instruments.- __init__(instrument: Optional[Any] = None)[source]¶
Create function reference container.
- Parameters
instrument (Any) – Instrument parent object of the function references.
- property instrument: Any¶
Return function references parent object.
- Returns
Instrument parent object of the function references.
- Return type
Any
- property funcs: Dict¶
Return dictionary of instrument function names and their associate references, referenced in this module’s functions so that the referenced functions can be registered to this object using the register method.
- Returns
Dictionary of required instrument function names and associated references.
- Return type
- register(ref: Callable[[Any], Any], attr_name: Optional[str] = None) None [source]¶
Register function reference as attribute to object.
- Parameters
ref (Callable[[Any], Any]) – Function reference to register.
attr_name (Optional[str]) – Attribute name to register function to. If attribute name is not provided. The function is registered to the name of the reference argument.
- Raises
AttributeError – Could not get name of reference.
KeyError – Attribute name is not found in function name list.
- qblox_instruments.native.generic_func.copy_docstr(src_func)[source]¶
Decorator that copies the docstring from the provided function to the decorated function.
- Parameters
src_func – Function from which to copy the docstring.
- qblox_instruments.native.generic_func.check_sequencer_index(sequencer: int) None [source]¶
Check if sequencer index is within range. We just check if the index is a positive integer here, because sending a negative number breaks the underlying SCPI command. The upperbound is checked by the instrument.
- Parameters
sequencer (int) – Sequencer index.
- Raises
ValueError – Sequencer index is out-of-range (i.e. < 1).
- qblox_instruments.native.generic_func.check_qrm_type(is_qrm_type: bool) None [source]¶
Check if module is of type QRM. If not throw a NotImplemented exception. This helper function can be used to catch execution of QRM functionality on non-QRM type modules.
- Parameters
is_qrm_type (bool) – Is QRM module type.
- Raises
NotImplementedError – Functionality not available on this module.
- qblox_instruments.native.generic_func.create_read_bin(read_bin_func: Callable[[str, bool], bytes], cmd: str) Callable[[Optional[int], Optional[str]], bytes] [source]¶
Create binary read function that can provide a binary read with a preconfigured command. This is usefull for functions like _get_awg_waveforms, that need a specific binary read command to kick off a stream of binary blocks.
- Parameters
- Returns
Binary read function with preconfigured command that takes the optional sequencer index and optional name string as arguments.
- Return type
- qblox_instruments.native.generic_func.get_scpi_commands(funcs: FuncRefs) Dict [source]¶
Get SCPI commands and convert to dictionary.
- Returns
Dictionary containing all available SCPI commands, corresponding parameters, arguments and Python methods and finally a descriptive comment.
- Return type
- qblox_instruments.native.generic_func.get_idn(funcs: FuncRefs) Dict [source]¶
Get device identity and build information and convert them to a dictionary.
- Returns
Dictionary containing manufacturer, model, serial number and build information. The build information is subdivided into FPGA firmware, kernel module software, application software and driver software build information. Each of those consist of the version, build date, build Git hash and Git build dirty indication.
- Return type
- qblox_instruments.native.generic_func.get_system_state(funcs: FuncRefs) SystemState [source]¶
Get general system state and convert it to a
SystemState
.- Returns
Tuple containing general system status and corresponding flags.
- Return type
- qblox_instruments.native.generic_func.get_acq_scope_config_format() str [source]¶
Get format for converting the configuration dictionary to a C struct.
- Returns
String compatible with struct package.
- Return type
- qblox_instruments.native.generic_func.set_acq_scope_config(funcs: FuncRefs, config: Dict) None [source]¶
Set configuration of the scope acquisition. The configuration consists of multiple parameters in a C struct format. If an invalid sequencer index is given or the configation struct does not have the correct format, an error is set in system error.
- Parameters
config (dict) – Configuration dictionary.
- Raises
NotImplementedError – Functionality not available on this module.
- qblox_instruments.native.generic_func.get_acq_scope_config(funcs: FuncRefs) Dict [source]¶
Get configuration of the scope acquisition. The configuration consists of multiple parameters in a C struct format. If an invalid sequencer index is given, an error is set in system error.
- Returns
Configuration dictionary.
- Return type
- Raises
NotImplementedError – Functionality not available on this module.
- qblox_instruments.native.generic_func.set_acq_scope_config_val(funcs: FuncRefs, param: str, val: Any) None [source]¶
Set value of specific scope acquisition parameter.
- Parameters
param (str) – Parameter name.
val (Any) – Value to set parameter to.
- qblox_instruments.native.generic_func.get_acq_scope_config_val(funcs: FuncRefs, param: str) Any [source]¶
Get value of specific scope acquisition parameter.
- Parameters
param (str) – Parameter name.
- Returns
Parameter value.
- Return type
Any
- qblox_instruments.native.generic_func.set_sequencer_program(funcs: FuncRefs, sequencer: int, program: str) None [source]¶
Assemble and set Q1ASM program for the indexed sequencer. If assembling failes, an RuntimeError is thrown with the assembler log attached.
- Parameters
- Raises
RuntimeError – Assembly failed.
- qblox_instruments.native.generic_func.get_sequencer_config_format(is_qrm_type: bool) str [source]¶
Get format for converting the configuration dictionary to a C struct.
- Returns
String compatible with struct package.
- Return type
- qblox_instruments.native.generic_func.set_sequencer_config(funcs: FuncRefs, sequencer: int, config: Dict) None [source]¶
Set configuration of the indexed sequencer. The configuration consists dictionary containing multiple parameters that will be converted into a C struct supported by the Pulsar QRM.
- qblox_instruments.native.generic_func.get_sequencer_config(funcs: FuncRefs, sequencer: int) Dict [source]¶
Get configuration of the indexed sequencer. The configuration consists dictionary containing multiple parameters that will be converted from a C struct provided by the Pulsar QRM.
- qblox_instruments.native.generic_func.set_sequencer_config_val(funcs: FuncRefs, sequencer: int, param: str, val: Any) None [source]¶
Set value of specific sequencer parameter.
- qblox_instruments.native.generic_func.get_sequencer_config_val(funcs: FuncRefs, sequencer: int, param: str) Any [source]¶
Get value of specific sequencer parameter.
- qblox_instruments.native.generic_func.set_sequencer_config_rotation_matrix(funcs: FuncRefs, sequencer: int, phase_incr: float) None [source]¶
Sets the integration result phase rotation matrix in the acquisition path.
- Parameters
- Raises
NotImplementedError – Functionality not available on this module.
- qblox_instruments.native.generic_func.get_sequencer_config_rotation_matrix(funcs: FuncRefs, sequencer: int) float [source]¶
Gets the integration result phase rotation matrix in the acquisition path.
- Parameters
sequencer (int) – Sequencer index.
- Returns
Phase increment in degrees.
- Return type
- Raises
NotImplementedError – Functionality not available on this module.
- qblox_instruments.native.generic_func.set_sequencer_channel_map(funcs: FuncRefs, sequencer: int, output: int, enable: bool) None [source]¶
Set enable of the indexed sequencer’s path to output. If an invalid sequencer index is given or the channel map is not valid, an error is set in system error.
- qblox_instruments.native.generic_func.get_sequencer_channel_map(funcs: FuncRefs, sequencer: int, output: int) bool [source]¶
Get enable of the indexed sequencer’s path to output. If an invalid sequencer index is given or the channel map is not valid, an error is set in system error.
- qblox_instruments.native.generic_func.arm_sequencer(funcs: FuncRefs, scpi_cmd_prefix: str) None [source]¶
Prepare the indexed sequencer to start by putting it in the armed state. If no sequencer index is given, all sequencers are armed. Any sequencer that was already running is stopped and rearmed. If an invalid sequencer index is given, an error is set in system error.
- Parameters
sequencer (Optional[int]) – Sequencer index.
- Raises
RuntimeError – An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception.
- qblox_instruments.native.generic_func.start_sequencer(funcs: FuncRefs, scpi_cmd_prefix: str) None [source]¶
Start the indexed sequencer, thereby putting it in the running state. If an invalid sequencer index is given or the indexed sequencer was not yet armed, an error is set in system error. If no sequencer index is given, all armed sequencers are started and any sequencer not in the armed state is ignored. However, if no sequencer index is given and no sequencers are armed, and error is set in system error.
- Parameters
sequencer (Optional[int]) – Sequencer index.
- Raises
RuntimeError – An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception.
- qblox_instruments.native.generic_func.stop_sequencer(funcs: FuncRefs, scpi_cmd_prefix: str) None [source]¶
Stop the indexed sequencer, thereby putting it in the stopped state. If an invalid sequencer index is given, an error is set in system error. If no sequencer index is given, all sequencers are stopped.
- Parameters
sequencer (Optional[int]) – Sequencer index.
- Raises
RuntimeError – An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception.
- qblox_instruments.native.generic_func.get_sequencer_state(funcs: FuncRefs, sequencer: int, timeout: int = 0, timeout_poll_res: float = 0.02) SequencerState [source]¶
Get the sequencer state. If an invalid sequencer index is given, an error is set in system error. If the timeout is set to zero, the function returns the state immediately. If a positive non-zero timeout is set, the function blocks until the sequencer completes. If the sequencer hasn’t stopped before the timeout expires, a TimeoutError is thrown.
- Parameters
- Returns
Tuple containing sequencer status and corresponding flags.
- Return type
- Raises
TimeoutError – Timeout
- qblox_instruments.native.generic_func.get_acq_acquisition_data(instrument: Any, funcs: FuncRefs, sequencer: int, name: str) Dict [source]¶
Get acquisition data of acquisition in acquisition list of indexed sequencer’s acquisition path. The acquisition scope and bin data is normalized to a range of -1.0 to 1.0 taking both the bit widths of the processing path and average count into considaration. For the binned integration results, the integration length is not handled during normalization and therefore these values have to be divided by their respective integration lenghts. If an invalid sequencer index is given or if a non-existing acquisition name is given, an error is set in system error.
- Parameters
- Returns
Dictionary with data of single acquisition.
- Return type
- Raises
RuntimeError – An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception.
- qblox_instruments.native.generic_func.add_waveforms(funcs: FuncRefs, sequencer: int, waveforms: Dict) None [source]¶
Add all waveforms in JSON compatible dictionary to the AWG waveform list of indexed sequencer. The dictionary must be structured as follows:
name: waveform name.
data: waveform samples in a range of 1.0 to -1.0.
- index: optional waveform index used by the sequencer Q1ASM program
to refer to the waveform.
- qblox_instruments.native.generic_func.delete_waveform(funcs: FuncRefs, sequencer: int, name: str = '', all: bool = False) None [source]¶
Delete a waveform specified by name in the AWG waveform list of indexed sequencer or delete all waveforms if all is True.
- qblox_instruments.native.generic_func.get_waveforms(funcs: FuncRefs, sequencer: int) Dict [source]¶
Get all waveforms and weigths in the AWG waveform list of indexed sequencer. The returned dictionary is structured as follows:
name: waveform name.
data: waveform samples in a range of 1.0 to -1.0.
- index: waveform index used by the sequencer Q1ASM program to refer
to the waveform.
- qblox_instruments.native.generic_func.add_weights(funcs: FuncRefs, sequencer: int, weights: Dict) None [source]¶
Add all weights in JSON compatible dictionary to the aquisition weight list of indexed sequencer. The dictionary must be structured as follows:
name : weight name.
data: weight samples in a range of 1.0 to -1.0.
- index: optional waveweightform index used by the sequencer Q1ASM
program to refer to the weight.
- Parameters
- Raises
KeyError – Missing weight data of weight in dictionary.
NotImplementedError – Functionality not available on this module.
- qblox_instruments.native.generic_func.delete_weight(funcs: FuncRefs, sequencer: int, name: str = '', all: bool = False) None [source]¶
Delete a weight specified by name in the acquisition weight list of indexed sequencer or delete all weights if all is True.
- Parameters
- Raises
NotImplementedError – Functionality not available on this module.
- qblox_instruments.native.generic_func.get_weights(funcs: FuncRefs, sequencer: int) Dict [source]¶
Get all weigths in the acquisition weight lists of indexed sequencer. The returned dictionary is structured as follows:
-name : weight name.
data: weight samples in a range of 1.0 to -1.0.
- index: weight index used by the sequencer Q1ASM program to refer
to the weight.
- Parameters
sequencer (int) – Sequencer index.
- Returns
Dictionary with weights.
- Return type
- Raises
NotImplementedError – Functionality not available on this module.
- qblox_instruments.native.generic_func.get_acquisition_state(funcs: FuncRefs, sequencer: int, timeout: int = 0, timeout_poll_res: float = 0.02, check_seq_state: bool = True) bool [source]¶
Return acquisition binning completion state of the indexed sequencer. If an invalid sequencer is given, an error is set in system error. If the timeout is set to zero, the function returns the state immediately. If a positive non-zero timeout is set, the function blocks until the acquisition binning completes. If the acquisition hasn’t completed before the timeout expires, a TimeoutError is thrown. Note that when sequencer state checking is enabled, the sequencer state is checked using get_sequencer_state with the selected timeout period first and then the acquisition state is checked with the same timeout period. This means that the total timeout period is two times the set timeout period.
- Parameters
- Returns
Indicates the acquisition binning completion state (False = uncompleted, True = completed).
- Return type
- Raises
TimeoutError – Timeout
NotImplementedError – Functionality not available on this module.
- qblox_instruments.native.generic_func.add_acquisitions(funcs: FuncRefs, sequencer: int, acquisitions: Dict) None [source]¶
Add all waveforms and weights in JSON compatible dictionary to AWG waveform and aquisition weight lists of indexed sequencer. The dictionary must be structured as follows:
- name: acquisition name.
num_bins: number of bins in acquisition.
- index: optional acquisition index used by the sequencer Q1ASM
program to refer to the acquition.
- Parameters
- Raises
KeyError – Missing dictionary key in acquisitions.
NotImplementedError – Functionality not available on this module.
- qblox_instruments.native.generic_func.delete_acquisition(funcs: FuncRefs, sequencer: int, name: str = '', all: bool = False) None [source]¶
Delete an acquisition specified by name in the acquisition list of indexed sequencer or delete all acquisitions if all is True.
- Parameters
- Raises
NotImplementedError – Functionality not available on this module.
- qblox_instruments.native.generic_func.delete_acquisition_data(funcs: FuncRefs, sequencer: int, name: str = '', all: bool = False) None [source]¶
Delete data from an acquisition specified by name in the acquisition list of indexed sequencer or delete data in all acquisitions if all is True.
- Parameters
- Raises
NotImplementedError – Functionality not available on this module.
- qblox_instruments.native.generic_func.store_scope_acquisition(funcs: FuncRefs, sequencer: int, name: str) None [source]¶
After an acquisition has completed, store the scope acquisition results in the acquisition specified by name of the indexed sequencers. If an invalid sequencer index is given an error is set in system error. To get access to the acquisition results, the sequencer will be stopped when calling this function.
- Parameters
- Raises
NotImplementedError – Functionality not available on this module.
- qblox_instruments.native.generic_func.get_acquisitions(funcs: FuncRefs, sequencer: int) Dict [source]¶
Get all acquisitions in acquisition lists of indexed sequencer. The acquisition scope and bin data is normalized to a range of -1.0 to 1.0 taking both the bit widths of the processing path and average count into considaration. For the binned integration results, the integration length is not handled during normalization and therefore these values have to be divided by their respective integration lenghts. The returned dictionary is structured as follows:
name: acquisition name
- index: acquisition index used by the sequencer Q1ASM program to
refer to the acquisition.
acquisition: acquisition dictionary
scope: Scope data
path0: input path 0
data: acquisition samples in a range of 1.0 to -1.0.
- out-of-range: out-of-range indication for the entire
acquisition (False = in-range, True = out-of-range).
avg_cnt: number of averages.
path1: input path 1
data: acquisition samples in a range of 1.0 to -1.0.
- out-of-range: out-of-range indication for the entire
acquisition (False = in-range, True = out-of-range).
avg_cnt: number of averages.
bins: bin data
integration: integration data
path_0: input path 0 integration result bin list
path_1: input path 1 integration result bin list
threshold: threshold result bin list
valid: list of valid indications per bin
avg_cnt: list of number of averages per bin
- Parameters
sequencer (int) – Sequencer index.
- Returns
Dictionary with acquisitions.
- Return type
- Raises
NotImplementedError – Functionality not available on this module.
- qblox_instruments.native.generic_func.set_sequence(funcs: FuncRefs, sequencer: int, sequence: Union[str, Dict[str, Any]], validation_enable: bool = True) None [source]¶
Set sequencer program, AWG waveforms, acquisition weights and acquisitions from a JSON file or from a dictionary directly. The JSON file or dictionary need to apply the schema specified by QCM_SEQUENCE_JSON_SCHEMA, QRM_SEQUENCE_JSON_SCHEMA, WAVE_JSON_SCHEMA and ACQ_JSON_SCHEMA.