Source code for pulsar_qrm.pulsar_qrm_scpi_ifc

""""""
#------------------------------------------------------------------------------
# Description    : SCPI interface
# Git repository : https://gitlab.com/qblox/packages/software/qblox_instruments.git
# Copyright (C) Qblox BV (2020)
#------------------------------------------------------------------------------


#------------------------------------------------------------------------------
# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY THIS FILE MANUALLY!
#------------------------------------------------------------------------------


#-- include --------------------------------------------------------------------

import sys
import struct
import re

#Add IEEE488.2 support
from ieee488_2.ieee488_2 import ieee488_2

#-- class ----------------------------------------------------------------------

[docs]class pulsar_qrm_scpi_ifc(ieee488_2): """ This interface provides an API for the mandatory and required SCPI calls and adds Pulsar related functionality (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). """ #---------------------------------------------------------------------------
[docs] def __init__(self, transport_inst, debug = 0): """ Creates SCPI interface object. Parameters ---------- transport_inst : :class:`~ieee488_2.transport` Transport class responsible for the lowest level of communication (e.g. ethernet). debug : int Debug level (0 = normal, 1 = no version check, >1 = no version or error checking). Returns ---------- :class:`~pulsar_qrm.pulsar_qrm_scpi_ifc` SCPI interface object. Raises ---------- Exception Debug level is 0 and there is a version mismatch. """ #Store parameters for later use. self._debug = debug #Initialize parent class. super(pulsar_qrm_scpi_ifc, self).__init__(transport_inst) if self._debug == 0: try: #Check if build is compatible. build = self._read("*IDN?").split(',')[-1] build_ref = "fwVersion=0.6.0 fwBuild=03/10/2021-16:45:54 fwHash=0x104D87E4 fwDirty=0 kmodVersion=0.6.0 kmodBuild=03/10/2021-16:45:54 kmodHash=0x104D87E4 kmodDirty=0 swVersion=0.6.0 swBuild=03/10/2021-16:45:54 swHash=0x104D87E4 swDirty=0" if build != build_ref: build = re.split(' |=', build) build_ref = re.split(' |=', build_ref) raise Exception("Error: pulsar_qrm_scpi_ifc version is not compatible with device version:\n" + \ "\n" + \ " pulsar_qcm_scpi_ifc: device version:\n" + \ "Firmware; Version: {} {}\n".format( build_ref[1], build[1]) + \ " Date: {} {}\n".format( build_ref[3], build[3]) + \ " Hash: {} {}\n".format( build_ref[5], build[5]) + \ " Dirty: {} {}\n".format(build_ref[7], build[7]) + \ "Kernel module; Version: {} {}\n".format( build_ref[9], build[9]) + \ " Date: {} {}\n".format( build_ref[11], build[11]) + \ " Hash: {} {}\n".format( build_ref[13], build[13]) + \ " Dirty: {} {}\n".format(build_ref[15], build[15]) + \ "Application; Version: {} {}\n".format( build_ref[17], build[17]) + \ " Date: {} {}\n".format( build_ref[19], build[19]) + \ " Hash: {} {}\n".format( build_ref[21], build[21]) + \ " Dirty: {} {}\n".format(build_ref[23], build[23]) + \ "\n" + \ "Please update your device's firmware or the Qblox Instruments package.") #Clear SCPI error queue. while int(self._read('SYSTem:ERRor:COUNt?')) != 0: self._read('SYSTem:ERRor:NEXT?') except Exception: raise
#--------------------------------------------------------------------------- def _get_idn(self): """ Get device identity and build information. Parameters ---------- Returns ---------- str Concatinated list of strings separated by the semicolon character. The IDN consists of four strings respectively ordered as: - Manufacturer - Model - Serial number - Build information Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('*IDN?') return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #---------------------------------------------------------------------------
[docs] def reset(self): """ Reset device and clear all status and event registers (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: self._write('*RST') except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def clear(self): """ Clear all status and event registers (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: self._write('*CLS') except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_status_byte(self): """ Get status byte register. Register is only cleared when feeding registers are cleared (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- int Status byte register. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('*STB?') return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def set_service_request_enable(self, reg): """ Set service request enable register (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- reg : int Service request enable register. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: self._write('*SRE {}'.format(reg)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_service_request_enable(self): """ Get service request enable register. The register is cleared after reading it (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- int Service request enable register. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('*SRE?') return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def set_standard_event_status_enable(self, reg): """ Get standard event status enable register. The register is cleared after reading it (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- int Standard event status enable register. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: self._write('*ESE {}'.format(reg)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_standard_event_status_enable(self): """ Set standard event status enable register (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- reg : int Standard event status enable register. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('*ESE?') return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_standard_event_status(self): """ Get standard event status register. The register is cleared after reading it (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- int Standard event status register. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('*ESR?') return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def set_operation_complete(self): """ Set device in operation complete query active state (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: self._write('*OPC') except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_operation_complete(self): """ Get operation complete state (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- bool Operation complete state (False = running, True = completed). Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('*OPC?') return bool(int(var0)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def test(self): """ Run self-test. Currently not implemented (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- bool Test result (False = failed, True = success). Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('*TST?') return bool(int(var0)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def wait(self): """ Wait until operations completed before continuing (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: self._write('*WAI') except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_system_error(self): """ Get system error from queue (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- str System error description string. """ #SCPI call try: var0 = self._read('SYSTem:ERRor:NEXT?') return var0 except: raise
#---------------------------------------------------------------------------
[docs] def get_num_system_error(self): """ Get number of system errors (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- int Current number of number of system errors. """ #SCPI call try: var0 = self._read('SYSTem:ERRor:COUNt?') return int(var0) except: raise
#---------------------------------------------------------------------------
[docs] def get_system_version(self): """ Get SCPI system version (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- str SCPI system version. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('SYSTem:VERSion?') return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def preset_system_status(self): """ Preset system status registers. Connects general system status flags for PLL unlock and temperature out-of-range indications to event status enable, status questionable temperature and status questionable frequency registers respectively (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: self._write('STATus:PRESet') except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_questionable_condition(self): """ Get status questionable condition register (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- int Status questionable condition register. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:QUEStionable:CONDition?') return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_questionable_event(self): """ Get status questionable event register (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- int Status questionable event register. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:QUEStionable:EVENt?') return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def set_questionable_enable(self, reg): """ Set status questionable enable register (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- reg : int Status questionable enable register. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: self._write('STATus:QUEStionable:ENABle {}'.format(reg)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_questionable_enable(self): """ Get status questionable enable register (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- int Status questionable enable register. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:QUEStionable:ENABle?') return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_operation_condition(self): """ Get status operation condition register (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- int Status operation condition register. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:OPERation:CONDition?') return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_operation_events(self): """ Get status operation event register (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- int Status operation event register. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:OPERation:EVENt?') return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def set_operation_enable(self, reg): """ Set status operation enable register (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- reg : int Status operation enable register. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: self._write('STATus:OPERation:ENABle {}'.format(reg)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_operation_enable(self): """ Get status operation enable register (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- Returns ---------- int Status operation enable register. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:OPERation:ENABle?') return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#--------------------------------------------------------------------------- def _get_scpi_commands(self): """ Get SCPI commands. Parameters ---------- Returns ---------- str Concatinated list of strings separated by the semicolon character. Each command consists of nine sections respectively order as: - SCPI command pattern - SCPI input type - SCPI output type - Python function - Python input types (comma separated) - Python input variable names (comma separated) - Python output types (comma separated) - User access level (0 = public, >=1 = private) - Comment Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('*CMDS?') return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_system_status(self): """ Get general system state. Parameters ---------- Returns ---------- str Concatinated list of strings separated by the semicolon character. Status is indicated by one status string and an optional number of flags respectively ordered as: :Status: - 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. :Flags: - CARRIER_PLL_UNLOCK: Carrier board PLL is unlocked. - FPGA_PLL_UNLOCK: FPGA PLL is unlocked. - LO_PLL_UNLOCK: LO PLL is unlocked. - FPGA_TEMP_OR: FPGA temperature is out-of-range. - CARRIER_TEMP_OR: Carrier board temperature is out-of-range. - AFE_TEMP_OR: Analog frontend board temperature is out-of-range. - LO_TEMP_OR: Local oscillator board temperature is out-of-range. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:GENeral:STATE?') return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #---------------------------------------------------------------------------
[docs] def get_current_fpga_temperature(self): """ Get current FPGA junction temperature (inside device). Parameters ---------- Returns ---------- float Current FPGA junction temperature. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:QUEStionable:TEMPerature:FPGA:CURRent?') return float(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_maximum_fpga_temperature(self): """ Get maximum FPGA junction temperature since boot or clear (inside device). Parameters ---------- Returns ---------- float Maximum FPGA junction temperature. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:QUEStionable:TEMPerature:FPGA:MAXimum?') return float(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_current_carrier_temperature(self): """ Get current carrier board temperature (inside device). Parameters ---------- Returns ---------- float Current carrier board temperature. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:QUEStionable:TEMPerature:CARRier:CURRent?') return float(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_maximum_carrier_temperature(self): """ Get maximum carrier board temperature since boot or clear (inside device). Parameters ---------- Returns ---------- float Maximum carrier board temperature. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:QUEStionable:TEMPerature:CARRier:MAXimum?') return float(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#--------------------------------------------------------------------------- def _set_reference_source(self, internal): """ Set reference (10MHz) clock source. Parameters ---------- internal : bool Reference clock source (False = External, True = Internal). Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['bool']) #SCPI call try: self._write('STATus:QUEStionable:FREQuency:REFerence:SRC {}'.format(0 if internal == False else 1)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_reference_source(self): """ Get reference (10MHz) clock source. Parameters ---------- Returns ---------- bool Reference clock source (False = External, True = Internal). Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:QUEStionable:FREQuency:REFerence:SRC?') return bool(int(var0)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_lo_hw_present(self): """ Check if LO hardware is present. Parameters ---------- Returns ---------- bool LO hardware presence (False = not present, True = present). Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('LO:PRESent?') return bool(int(var0)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #---------------------------------------------------------------------------
[docs] def get_current_afe_temperature(self): """ Get current analog frontend board temperature (inside device). Parameters ---------- Returns ---------- float Current analog frontend board temperature. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:QUEStionable:TEMPerature:AFE:CURRent?') return float(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_maximum_afe_temperature(self): """ Get maximum analog frontend board temperature since boot or clear (inside device). Parameters ---------- Returns ---------- float Maximum analog frontend board temperature. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:QUEStionable:TEMPerature:AFE:MAXimum?') return float(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_current_lo_temperature(self): """ Get the current local oscillator board temperature (inside device). Parameters ---------- Returns ---------- float Current local board temperature. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:QUEStionable:TEMPerature:LO:CURRent?') return float(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_maximum_lo_temperature(self): """ Get maximum local oscillator board temperature since boot or clear (inside device). Parameters ---------- Returns ---------- float Maximum local oscillator board temperature. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:QUEStionable:TEMPerature:LO:MAXimum?') return float(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#--------------------------------------------------------------------------- def _set_lo_freq_0(self, freq): """ Set LO frequency for output 0. Parameters ---------- freq : long Frequency in Hertz. Returns ---------- Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: self._write('STATus:QUEStionable:FREQuency:LO0 {}'.format(freq)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_lo_freq_0(self): """ Get LO frequency for output 0. Parameters ---------- Returns ---------- long Current frequency in Hertz. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:QUEStionable:FREQuency:LO0?') return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_lo_freq_1(self, freq): """ Set LO frequency for output 1. Parameters ---------- freq : long Frequency in Hertz. Returns ---------- Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: self._write('STATus:QUEStionable:FREQuency:LO1 {}'.format(freq)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_lo_freq_1(self): """ Get LO frequency for output 1. Parameters ---------- Returns ---------- long Current frequency in Hertz. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:QUEStionable:FREQuency:LO1?') return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_lo_pwr_0(self, pwr): """ Set LO power for output 0. Parameters ---------- pwr : int Power in dBm. Returns ---------- Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: self._write('STATus:QUEStionable:POWer:LO0 {}'.format(pwr)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_lo_pwr_0(self): """ Get LO power for output 0. Parameters ---------- Returns ---------- int Power in dBm. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:QUEStionable:POWer:LO0?') return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_lo_pwr_1(self, pwr): """ Set LO power for output 1. Parameters ---------- pwr : int PLL output power, unitless. Returns ---------- Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: self._write('STATus:QUEStionable:POWer:LO1 {}'.format(pwr)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_lo_pwr_1(self): """ Get LO power for output 1. Parameters ---------- Returns ---------- int PLL output power, unitless. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:QUEStionable:POWer:LO1?') return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #---------------------------------------------------------------------------
[docs] def get_assembler_status(self): """ Get assembler status. Refer to the assembler log to get more information regarding the assembler result. Parameters ---------- pwr : int PLL output power, unitless. Returns ---------- bool Assembler status (False = failed, True = success). Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('STATus:ASSEMbler:SUCCess?') return bool(int(var0)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#---------------------------------------------------------------------------
[docs] def get_assembler_log(self): """ Get assembler log. Parameters ---------- Returns ---------- int PLL output power, unitless. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read_bin('STATus:ASSEMbler:LOG?') return var0.decode('utf-8', 'ignore') except Exception as err: self._check_error_queue(err) finally: self._check_error_queue()
#--------------------------------------------------------------------------- def _set_in_amp_gain_0(self, gain): """ Set input amplifier gain for input 0. Parameters ---------- gain : int Gain in dB in a range of -6 to 26. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: self._write('AFE:GAIN:INAMP0 {}'.format(gain)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_in_amp_gain_0(self): """ Get input amplifier gain for input 0. Parameters ---------- Returns ---------- int Gain in dB in a range of -6 to 26. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('AFE:GAIN:INAMP0?') return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_in_amp_gain_1(self, gain): """ Set input amplifier gain for input 1. Parameters ---------- gain : int Gain in dB in a range of -6 to 26. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: self._write('AFE:GAIN:INAMP1 {}'.format(gain)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_in_amp_gain_1(self): """ Get input amplifier gain for input 1. Parameters ---------- Returns ---------- int Gain in dB in a range of -6 to 26. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('AFE:GAIN:INAMP1?') return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_out_amp_offset_0(self, offset): """ Set output amplifier offset for output 1. Parameters ---------- offset : float Offset in range of 0 to 56.5 millivolt. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['float']) #SCPI call try: self._write('AFE:OFFSet:OUTAMP0 {}'.format(offset)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_out_amp_offset_0(self): """ Get output amplifier offset for output 1. Parameters ---------- Returns ---------- float Offset in range of 0 to 56.5 millivolt. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('AFE:OFFSet:OUTAMP0?') return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_out_amp_offset_1(self, offset): """ Set output amplifier offset for output 1. Parameters ---------- offset : float Offset in range of 0 to 56.5 millivolt. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['float']) #SCPI call try: self._write('AFE:OFFSet:OUTAMP1 {}'.format(offset)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_out_amp_offset_1(self): """ Get output amplifier offset for output 1. Parameters ---------- Returns ---------- float Offset in range of 0 to 56.5 millivolt. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('AFE:OFFSet:OUTAMP1?') return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_dac_offset_0(self, offset): """ Set dac offset for output 0. Parameters ---------- offset : float Offset as a fraction of fullscale in a range of -1.0 to 1.0. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['float']) #SCPI call try: self._write('AFE:OFFSet:DAC0 {}'.format(offset)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_dac_offset_0(self): """ Get dac offset for output 0. Parameters ---------- Returns ---------- float Offset as a fraction of fullscale in a range of -1.0 to 1.0. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('AFE:OFFSet:DAC0?') return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_dac_offset_1(self, offset): """ Set dac offset for output 1. Parameters ---------- offset : float Offset as a fraction of fullscale in a range of -1.0 to 1.0. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['float']) #SCPI call try: self._write('AFE:OFFSet:DAC1 {}'.format(offset)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_dac_offset_1(self): """ Get dac offset for output 1. Parameters ---------- Returns ---------- float Offset as a fraction of fullscale in a range of -1.0 to 1.0. Raises ---------- Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read('AFE:OFFSet:DAC1?') return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_acq_scope_config(self, config): """ 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 : bytes Configuration struct. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['bytes']) #SCPI call try: self._write_bin('ACQ:SCOpe:CONFiguration '.format(), config) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_acq_scope_config(self): """ 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. Parameters ---------- Returns ---------- bytes Configuration struct. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #SCPI call try: var0 = self._read_bin('ACQ:SCOpe:CONFiguration?') return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_sequencer_channel_map(self, sequencer, channel_map): """ Set channel map of the indexed sequencer. The channel map consists of list of associated output channels for the given sequencer index. If an invalid sequencer index is given or the channel map is not valid, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. channel map : bytes channel map list. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'bytes']) #SCPI call try: self._write_bin('SEQuencer{}:CHANnelmap '.format(sequencer), channel_map) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_sequencer_channel_map(self, sequencer): """ Get channel map of the indexed sequencer. The channel map consists of list of associated output channels for the given sequencer index. If an invalid sequencer index is given or the channel map is not valid, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. Returns ---------- bytes channel map list. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: var0 = self._read_bin('SEQuencer{}:CHANnelmap?'.format(sequencer)) return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_sequencer_program(self, sequencer, program): """ Assemble and set the resulting Q1ASM program for the indexed sequencer. If an invalid sequencer index is given or assembling failes, an error is set in system error. The assembler status and log can be retrieved using separate commands. To set the Q1ASM program, the sequencer will be stopped. Parameters ---------- sequencer : int Sequencer index. program : str Q1ASM program. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str']) #SCPI call try: self._write_bin('SEQuencer{}:PROGram '.format(sequencer), program.encode('ascii')) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_sequencer_config(self, sequencer, config): """ Set configuration of the indexed sequencer. 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 ---------- sequencer : int Sequencer index. config : bytes Configuration struct. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'bytes']) #SCPI call try: self._write_bin('SEQuencer{}:CONFiguration '.format(sequencer), config) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_sequencer_config(self, sequencer): """ Get configuration of the indexed sequencer. 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. Parameters ---------- sequencer : int Sequencer index. Returns ---------- bytes Configuration struct. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: var0 = self._read_bin('SEQuencer{}:CONFiguration?'.format(sequencer)) return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _arm_sequencer(self, sequencer): """ 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 : int Sequencer index. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: self._write('SEQuencer{}:ARM'.format(sequencer)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _start_sequencer(self, sequencer): """ 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 : int Sequencer index. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: self._write('SEQuencer{}:START'.format(sequencer)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _stop_sequencer(self, sequencer): """ 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 : int Sequencer index. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: self._write('SEQuencer{}:STOP'.format(sequencer)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_sequencer_state(self, sequencer): """ Get the sequencer state. If an invalid sequencer index is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. Returns ---------- str Concatinated list of strings separated by the semicolon character. Status is indicated by one status string and an optional number of flags respectively ordered as: :Status: - 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. :Flags: - 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. - 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. - CLOCK INSTABILITY: Clock source instability occurred. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: var0 = self._read('SEQuencer{}:STATE?'.format(sequencer)) return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _add_awg_waveform(self, sequencer, name, size, is_integer): """ Add new waveform to waveform list of indexed sequencer's AWG path. If an invalid sequencer index is given or if the waveform causes the waveform memory limit to be exceeded, an error is set in system error. The waveform names 'all' and 'ALL' are reserved and adding those will also result in an error being set in system error. Parameters ---------- sequencer : int Sequencer index. name : str Waveform name. size : int Waveform length in number of samples. is_integer : bool Waveform is provided as integers (False = floats, True = integers). Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str', 'int', 'bool']) #SCPI call try: self._write('SEQuencer{}:AWG:WLISt:WAVeform:NEW "{}",{},{}'.format(sequencer, name, size, 0 if is_integer == False else 1)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _delete_awg_waveform(self, sequencer, name): """ Delete waveform from waveform list of indexed sequencer's AWG path. If an invalid sequencer index is given or if a non-existing waveform name is given, an error is set in system error. The waveform names 'all' and 'ALL' are reserved and deleting those will cause a purge of the entire waveform list. Parameters ---------- sequencer : int Sequencer index. name : str Waveform name. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str']) #SCPI call try: self._write('SEQuencer{}:AWG:WLISt:WAVeform:DELete "{}"'.format(sequencer, name)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_awg_waveform_data(self, sequencer, name, waveform): """ Set waveform data of waveform in waveform list of indexed sequencer's AWG path. If an invalid sequencer index is given or if a non-existing waveform name is given, an error is set in system error. If the wavefrom size does not match the size specified while adding the waveform or if the wavefrom samples are out-of-range, an error is set in the system error. Parameters ---------- sequencer : int Sequencer index. name : str Waveform name. waveform : list List of floats in the range of 1.0 to -1.0 representing the waveform. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str', 'float']) #SCPI call try: self._write_bin('SEQuencer{}:AWG:WLISt:WAVeform:DATA "{}",'.format(sequencer, name), struct.pack('f'*len(waveform), *waveform)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_awg_waveform_data(self, sequencer, name, start, size): """ Get waveform data of waveform in waveform list of indexed sequencer's AWG path. If an invalid sequencer index is given or if a non-existing waveform name is given, an error is set in system error. The start and size arguments can be used to return a section of the waveform. If the start argument is not given, zero is used as the default start sample. If the size argument is not given, all samples starting from the start sample are returned. Parameters ---------- sequencer : int Sequencer index. name : str Waveform name. start : int First sample within the waveform to be returned. size : int Number of samples starting from the start sample to be returned. Returns ---------- list List of floats in the range of 1.0 to -1.0 representing the waveform. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str', 'int', 'int']) #SCPI call try: var0 = self._read_bin('SEQuencer{}:AWG:WLISt:WAVeform:DATA? "{}",{},{}'.format(sequencer, name, start, size)) return struct.unpack('f'*int(len(var0)/4), var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_awg_waveform_index(self, sequencer, name, index): """ Set waveform index of waveform in waveform list of indexed sequencer's AWG path. The index is used by the sequencer Q1ASM program to refer to the waveform. If an invalid sequencer or waveform index is given or if a non-existing waveform name is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. name : str Waveform name. index : int Waveform index of the waveform in the waveform list. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str', 'int']) #SCPI call try: self._write('SEQuencer{}:AWG:WLISt:WAVeform:INDex "{}",{}'.format(sequencer, name, index)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_awg_waveform_index(self, sequencer, name): """ Get waveform index of waveform in waveform list of indexed sequencer's AWG path. The index is used by the sequencer Q1ASM program to refer to the waveform. If an invalid sequencer index is given or if a non-existing waveform name is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. name : str Waveform name. Returns ---------- int Waveform index of the waveform in the waveform list. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str']) #SCPI call try: var0 = self._read('SEQuencer{}:AWG:WLISt:WAVeform:INDex? "{}"'.format(sequencer, name)) return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_awg_waveform_length(self, sequencer, name): """ Get length of waveform in waveform list of indexed sequencer's AWG path. If an invalid sequencer index is given or if a non-existing waveform name is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. name : str Waveform name. Returns ---------- int Waveform length in number of samples. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str']) #SCPI call try: var0 = self._read('SEQuencer{}:AWG:WLISt:WAVeform:LENGth? "{}"'.format(sequencer, name)) return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_awg_waveform_name(self, sequencer, index): """ Get name of waveform in waveform list of indexed sequencer's AWG path based on its waveform index. If an invalid sequencer index is given or if a non-existing waveform index is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. index : str Waveform index. Returns ---------- str Waveform name. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'int']) #SCPI call try: var0 = self._read('SEQuencer{}:AWG:WLISt:WAVeform:NAME? {}'.format(sequencer, index)) return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_awg_num_waveforms(self, sequencer): """ Get number of waveforms in waveform list of indexed sequencer's AWG path. If an invalid sequencer index is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. Returns ---------- int Number of waveforms. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: var0 = self._read('SEQuencer{}:AWG:WLISt:SIZE?'.format(sequencer)) return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_awg_waveforms(self, sequencer): """ Get all waveforms in waveform list of indexed sequencer's AWG path. If an invalid sequencer index is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. Returns ---------- int Dictionary with waveforms. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: var0 = self._read_bin('SEQuencer{}:AWG:WLISt?'.format(sequencer)) return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _add_acq_weight(self, sequencer, name, size, is_integer): """ Add new weight to weight list of indexed sequencer's acquisition path. If an invalid sequencer index is given or if the weight causes the weight memory limit to be exceeded, an error is set in system error. The weight names 'all' and 'ALL' are reserved and adding those will also result in an error being set in system error. Parameters ---------- sequencer : int Sequencer index. name : str Weight name. size : int Weight length in number of samples. is_integer : bool Weight is provided as integers (False = floats, True = integers). Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str', 'int', 'bool']) #SCPI call try: self._write('SEQuencer{}:ACQ:WLISt:WEIght:NEW "{}",{},{}'.format(sequencer, name, size, 0 if is_integer == False else 1)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _delete_acq_weight(self, sequencer, name): """ Delete weight from weight list of indexed sequencer's acquisition path. If an invalid sequencer index is given or if a non-existing weight name is given, an error is set in system error. The weight names 'all' and 'ALL' are reserved and deleting those will cause a purge of the entire weight list. Parameters ---------- sequencer : int Sequencer index. name : str Weight name. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str']) #SCPI call try: self._write('SEQuencer{}:ACQ:WLISt:WEIght:DELete "{}"'.format(sequencer, name)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_acq_weight_data(self, sequencer, name, waveform): """ Set weight data of weight in weight list of indexed sequencer's acquisition path. If an invalid sequencer index is given or if a non-existing weight name is given, an error is set in system error. If the wavefrom size does not match the size specified while adding the weight or if the wavefrom samples are out-of-range, an error is set in the system error. Parameters ---------- sequencer : int Sequencer index. name : str Weight name. weight : list List of floats in the range of 1.0 to -1.0 representing the weight. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str', 'float']) #SCPI call try: self._write_bin('SEQuencer{}:ACQ:WLISt:WEIght:DATA "{}",'.format(sequencer, name), struct.pack('f'*len(waveform), *waveform)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_acq_weight_data(self, sequencer, name, start, size): """ Get weight data of weight in weight list of indexed sequencer's acquisition path. If an invalid sequencer index is given or if a non-existing weight name is given, an error is set in system error. The start and size arguments can be used to return a section of the weight. If the start argument is not given, zero is used as the default start sample. If the size argument is not given, all samples starting from the start sample are returned. Parameters ---------- sequencer : int Sequencer index. name : str Weight name. start : int First sample within the weight to be returned. size : int Number of samples starting from the start sample to be returned. Returns ---------- list List of floats in the range of 1.0 to -1.0 representing the weight. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str', 'int', 'int']) #SCPI call try: var0 = self._read_bin('SEQuencer{}:ACQ:WLISt:WEIght:DATA? "{}",{},{}'.format(sequencer, name, start, size)) return struct.unpack('f'*int(len(var0)/4), var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_acq_weight_index(self, sequencer, name, index): """ Set weight index of weight in weight list of indexed sequencer's acquisition path. The index is used by the sequencer Q1ASM program to refer to the weight. If an invalid sequencer or weight index is given or if a non-existing weight name is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. name : str Weight name. index : int Weight index of the weight in the weight list. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str', 'int']) #SCPI call try: self._write('SEQuencer{}:ACQ:WLISt:WEIght:INDex "{}",{}'.format(sequencer, name, index)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_acq_weight_index(self, sequencer, name): """ Get weight index of weight in weight list of indexed sequencer's acquisition path. The index is used by the sequencer Q1ASM program to refer to the weight. If an invalid sequencer index is given or if a non-existing weight name is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. name : str Weight name. Returns ---------- int Weight index of the weight in the weight list. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str']) #SCPI call try: var0 = self._read('SEQuencer{}:ACQ:WLISt:WEIght:INDex? "{}"'.format(sequencer, name)) return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_acq_weight_length(self, sequencer, name): """ Get length of weight in weight list of indexed sequencer's acquisition path. If an invalid sequencer index is given or if a non-existing weight name is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. name : str Weight name. Returns ---------- int Weight length in number of samples. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str']) #SCPI call try: var0 = self._read('SEQuencer{}:ACQ:WLISt:WEIght:LENGth? "{}"'.format(sequencer, name)) return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_acq_weight_name(self, sequencer, index): """ Get name of weight in weight list of indexed sequencer's acquisition path based on its weight index. If an invalid sequencer index is given or if a non-existing weight index is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. index : str Weight index. Returns ---------- str Weight name. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'int']) #SCPI call try: var0 = self._read('SEQuencer{}:ACQ:WLISt:WEIght:NAME? {}'.format(sequencer, index)) return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_acq_num_weights(self, sequencer): """ Get number of weights in weight list of indexed sequencer's acquisition path. If an invalid sequencer index is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. Returns ---------- int Number of weights. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: var0 = self._read('SEQuencer{}:ACQ:WLISt:SIZE?'.format(sequencer)) return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_acq_weights(self, sequencer): """ Get all weights in weight list of indexed sequencer's acquisition path. If an invalid sequencer index is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. Returns ---------- int Dictionary with weights. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: var0 = self._read_bin('SEQuencer{}:ACQ:WLISt?'.format(sequencer)) return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _add_acq_acquisition(self, sequencer, name, num_bins): """ Add new acquisition to acquisition list of indexed sequencer's acquisition path. If an invalid sequencer index is given or if the required acquisition memory cannot be allocated, an error is set in system error. The acquisition names 'all' and 'ALL' are reserved and adding those will also result in an error being set in system error. Parameters ---------- sequencer : int Sequencer index. name : str Acquisition name. num_bins : int Number of bins in acquisition. Maximum is 2^24. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str', 'int']) #SCPI call try: self._write('SEQuencer{}:ACQ:ALISt:ACQuisition:NEW "{}",{}'.format(sequencer, name, num_bins)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _delete_acq_acquisition(self, sequencer, name): """ Delete acquisition from acquisition list of indexed sequencer's acquisition path. If an invalid sequencer index is given or if a non-existing acquisition name is given, an error is set in system error. The acquisition names 'all' and 'ALL' are reserved and deleting those will cause a purge of the entire acquisition list. Parameters ---------- sequencer : int Sequencer index. name : str Acquisition name. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str']) #SCPI call try: self._write('SEQuencer{}:ACQ:ALISt:ACQuisition:DELete "{}"'.format(sequencer, name)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_acq_acquisition_data(self, sequencer, name): """ Move scope mode (raw) acquisition data into acquisition in acquisition list of indexed sequencer's acquisition path. If an invalid sequencer index is given or if a non-existing acquisition name is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. name : str Acquisition name. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str']) #SCPI call try: self._write('SEQuencer{}:ACQ:ALISt:ACQuisition:DATA "{}"'.format(sequencer, name)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_acq_acquisition_data(self, sequencer, name): """ Get acquisition data of acquisition in acquisition list of indexed sequencer's acquisition path. If an invalid sequencer index is given or if a non-existing acquisition name is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. name : str Acquisition name. Returns ---------- list Binary structure containing the acquistition. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str']) #SCPI call try: var0 = self._read_bin('SEQuencer{}:ACQ:ALISt:ACQuisition:DATA? "{}"'.format(sequencer, name)) return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _set_acq_acquisition_index(self, sequencer, name, index): """ Set acquisition index of acquisition in acquisition list of indexed sequencer's acquisition path. The index is used by the sequencer Q1ASM program to refer to the acquisition. If an invalid sequencer or acquisition index is given or if a non-existing acquisition name is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. name : str Acquisition name. index : int Acquisition index of the acquisition in the acquisition list. Returns ---------- Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str', 'int']) #SCPI call try: self._write('SEQuencer{}:ACQ:ALISt:ACQuisition:INDex "{}",{}'.format(sequencer, name, index)) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_acq_acquisition_index(self, sequencer, name): """ Get acquisition index of acquisition in acquisition list of indexed sequencer's acquisition path. The index is used by the sequencer Q1ASM program to refer to the acquisition. If an invalid sequencer index is given or if a non-existing acquisition name is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. name : str Acquisition name. Returns ---------- int Acquisition index of the acquisition in the acquisition list. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str']) #SCPI call try: var0 = self._read('SEQuencer{}:ACQ:ALISt:ACQuisition:INDex? "{}"'.format(sequencer, name)) return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_acq_acquisition_num_bins(self, sequencer, name): """ Get number of bins in acquisition in acquisition list of indexed sequencer's acquisition path. If an invalid sequencer index is given or if a non-existing acquisition name is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. name : str Acquisition name. Returns ---------- int Number of bins in acquisition. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int', 'str']) #SCPI call try: var0 = self._read('SEQuencer{}:ACQ:ALISt:ACQuisition:BINs? "{}"'.format(sequencer, name)) return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_acq_num_acquisitions(self, sequencer): """ Get name of acquisition in acquisition list of indexed sequencer's acquisition path based on its acquisition index. If an invalid sequencer index is given or if a non-existing acquisition index is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. index : str Acquisition index. Returns ---------- str Acquisition name. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: var0 = self._read('SEQuencer{}:ACQ:ALISt:SIZE?'.format(sequencer)) return int(var0) except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #--------------------------------------------------------------------------- def _get_acq_acquisitions(self, sequencer): """ Get all acquisitions in acquisition list of indexed sequencer's acquisition path. If an invalid sequencer index is given, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. Returns ---------- int Dictionary with acquisitions. Raises ---------- Exception Invalid input parameter type. Exception An error is reported in system error and debug <= 1. All errors are read from system error and listed in the exception. """ #Check input types. self._check_in_type(locals(), ['int']) #SCPI call try: var0 = self._read_bin('SEQuencer{}:ACQ:ALISt?'.format(sequencer)) return var0 except Exception as err: self._check_error_queue(err) finally: self._check_error_queue() #----------------------------------------------------------------------- def _check_in_type(self, in_arg_dict, in_type_list): """ Checks input argument types against reference types. Parameters ---------- in_arg_dict : dict Dictionary with input arguments created by locals(). in_type_list : list List of reference input argument types. Returns ---------- Raises ---------- Exception Input argument type mismatch. """ if self._debug <= 1: del in_arg_dict['self'] in_val_list = [in_arg_dict[name] for name in in_arg_dict] for i, (in_val, in_type) in enumerate(zip(in_val_list, in_type_list)): if str(type(in_val).__name__) == "list" or str(type(in_val).__name__) == "ndarray": if len(in_val) > 0: in_val = in_val[0] else: raise Exception("Error: unexpected type for input argument {}, expected {} but got empty {}.".format(i, in_type, str(type(in_val).__name__))) if str(type(in_val).__name__)[:len(in_type)] != in_type: raise Exception("Error: unexpected type for input argument {}, expected {} but got {}.".format(i, in_type, str(type(in_val).__name__))) #--------------------------------------------------------------------------- def _check_error_queue(self, err=None): """ Check system error for errors. Empties and prints the complete error queue. Parameters ---------- err : Exception Exception to reraise. Returns ---------- Raises ---------- Exception An error was found in system error or an exception was passed as input argument. """ if self._debug <= 1: errors = [str(err)] if err is not None else [] while int(self._read('SYSTem:ERRor:COUNt?')) != 0: errors.append(','.join(self._read('SYSTem:ERRor:NEXT?').split(',')[1:])) if len(errors) > 0: if err is not None: err_type = type(err) else: err_type = Exception raise err_type('\n'.join(errors)).with_traceback(sys.exc_info()[2]) from None