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
import json

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

#-- decorator-------------------------------------------------------------------

[docs]def scpi_error_check(func): """ Decorator that catches and checks for errors on an SCPI call. Parameters ---------- func Class method that performs an SCPI call Returns ---------- Raises ---------- Exception An error was found in system error or an exception was passed as input argument. """ def decorator_wrapper(*args, **kwargs): try: return func(*args, **kwargs) except Exception as err: args[0]._check_error_queue(err) finally: args[0]._check_error_queue() return decorator_wrapper
#-- 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: #Check if build is compatible. build = self._read("*IDN?").split(',')[-1] build_ref = "fwVersion=0.6.3 fwBuild=17/12/2021-12:28:39 fwHash=0x39EDEDA fwDirty=0 kmodVersion=0.6.3 kmodBuild=14/12/2021-13:53:41 kmodHash=0x81E195F8 kmodDirty=0 swVersion=0.6.3 swBuild=14/12/2021-13:53:41 swHash=0x81E195F8 swDirty=0" if build != build_ref: build = re.split(' |=', build) build_ref = re.split(' |=', build_ref) raise ConnectionError("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?')
#--------------------------------------------------------------------------- @scpi_error_check def _get_idn(self): """ Get device identity and build information. Parameters ---------- None 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 var0 = self._read('*IDN?') return var0 #---------------------------------------------------------------------------
[docs] @scpi_error_check def reset(self): """ Reset device and clear all status and event registers (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- None Returns ------- None 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 self._write('*RST')
#---------------------------------------------------------------------------
[docs] @scpi_error_check def clear(self): """ Clear all status and event registers (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- None Returns ------- None 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 self._write('*CLS')
#---------------------------------------------------------------------------
[docs] @scpi_error_check 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 ---------- None 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 var0 = self._read('*STB?') return int(var0)
#---------------------------------------------------------------------------
[docs] @scpi_error_check 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 ------- None 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 self._write('*SRE {}'.format(reg))
#---------------------------------------------------------------------------
[docs] @scpi_error_check 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 ---------- None 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 var0 = self._read('*SRE?') return int(var0)
#---------------------------------------------------------------------------
[docs] @scpi_error_check def set_standard_event_status_enable(self, reg): """ 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 ------- None 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 self._write('*ESE {}'.format(reg))
#---------------------------------------------------------------------------
[docs] @scpi_error_check def get_standard_event_status_enable(self): """ Get standard event status enable register. The register is cleared after reading it (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- None 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. """ #SCPI call var0 = self._read('*ESE?') return int(var0)
#---------------------------------------------------------------------------
[docs] @scpi_error_check 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 ---------- None 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 var0 = self._read('*ESR?') return int(var0)
#---------------------------------------------------------------------------
[docs] @scpi_error_check def set_operation_complete(self): """ Set device in operation complete query active state (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- None Returns ------- None 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 self._write('*OPC')
#---------------------------------------------------------------------------
[docs] @scpi_error_check def get_operation_complete(self): """ Get operation complete state (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- None 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 var0 = self._read('*OPC?') return bool(int(var0))
#---------------------------------------------------------------------------
[docs] @scpi_error_check def test(self): """ Run self-test. Currently not implemented (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- None 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 var0 = self._read('*TST?') return bool(int(var0))
#---------------------------------------------------------------------------
[docs] @scpi_error_check def wait(self): """ Wait until operations completed before continuing (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- None Returns ------- None 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 self._write('*WAI')
#---------------------------------------------------------------------------
[docs] def get_system_error(self): """ Get system error from queue (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- None Returns ------- str System error description string. """ #SCPI call var0 = self._read('SYSTem:ERRor:NEXT?') return var0
#---------------------------------------------------------------------------
[docs] def get_num_system_error(self): """ Get number of system errors (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- None Returns ------- int Current number of system errors. """ #SCPI call var0 = self._read('SYSTem:ERRor:COUNt?') return int(var0)
#---------------------------------------------------------------------------
[docs] @scpi_error_check def get_system_version(self): """ Get SCPI system version (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- None 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 var0 = self._read('SYSTem:VERSion?') return var0
#---------------------------------------------------------------------------
[docs] @scpi_error_check 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 ---------- None Returns ------- None 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 self._write('STATus:PRESet')
#---------------------------------------------------------------------------
[docs] @scpi_error_check def get_questionable_condition(self): """ Get status questionable condition register (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- None 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 var0 = self._read('STATus:QUEStionable:CONDition?') return int(var0)
#---------------------------------------------------------------------------
[docs] @scpi_error_check def get_questionable_event(self): """ Get status questionable event register (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- None 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 var0 = self._read('STATus:QUEStionable:EVENt?') return int(var0)
#---------------------------------------------------------------------------
[docs] @scpi_error_check 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 ------- None 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 self._write('STATus:QUEStionable:ENABle {}'.format(reg))
#---------------------------------------------------------------------------
[docs] @scpi_error_check def get_questionable_enable(self): """ Get status questionable enable register (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- None 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 var0 = self._read('STATus:QUEStionable:ENABle?') return int(var0)
#---------------------------------------------------------------------------
[docs] @scpi_error_check def get_operation_condition(self): """ Get status operation condition register (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- None 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 var0 = self._read('STATus:OPERation:CONDition?') return int(var0)
#---------------------------------------------------------------------------
[docs] @scpi_error_check def get_operation_events(self): """ Get status operation event register (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- None 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 var0 = self._read('STATus:OPERation:EVENt?') return int(var0)
#---------------------------------------------------------------------------
[docs] @scpi_error_check 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 ------- None 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 self._write('STATus:OPERation:ENABle {}'.format(reg))
#---------------------------------------------------------------------------
[docs] @scpi_error_check def get_operation_enable(self): """ Get status operation enable register (see `SCPI <https://www.ivifoundation.org/docs/scpi-99.pdf>`_). Parameters ---------- None 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 var0 = self._read('STATus:OPERation:ENABle?') return int(var0)
#--------------------------------------------------------------------------- @scpi_error_check def _get_scpi_commands(self): """ Get SCPI commands. Parameters ---------- None Returns ------- str Concatenated list of strings separated by the semicolon character. Each command consists of nine sections respectively ordered 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 var0 = self._read('*CMDS?') return var0 #---------------------------------------------------------------------------
[docs] @scpi_error_check def identify(self): """ Toggle frontpanel LEDs to visually identify the instrument. Parameters ---------- None Returns ------- None 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 self._write('*IDENtify')
#--------------------------------------------------------------------------- @scpi_error_check def _get_system_status(self): """ Get general system state. Parameters ---------- None Returns ------- str Concatenated 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 occurred, but has been resolved. - ``ERROR``: An error indicated by the flags is occurring. :Flags: - ``CARRIER PLL UNLOCKED`` - ``FPGA PLL UNLOCKED`` - ``LO PLL UNLOCKED`` (only for RF-modules) - ``FPGA TEMPERATURE OUT-OF-RANGE`` - ``CARRIER TEMPERATURE OUT-OF-RANGE`` - ``AFE TEMPERATURE OUT-OF-RANGE`` - ``LO TEMPERATURE OUT-OF-RANGE`` - ``BACKPLANE TEMPERATURE OUT-OF-RANGE`` (only for Cluster) 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 var0 = self._read('STATus:GENeral:STATE?') return var0 #---------------------------------------------------------------------------
[docs] @scpi_error_check def get_current_fpga_temperature(self): """ Get current FPGA junction temperature (inside device). Parameters ---------- None 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 var0 = self._read('STATus:QUEStionable:TEMPerature:FPGA:CURRent?') return float(var0)
#---------------------------------------------------------------------------
[docs] @scpi_error_check def get_maximum_fpga_temperature(self): """ Get maximum FPGA junction temperature since boot or clear (inside device). Parameters ---------- None 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 var0 = self._read('STATus:QUEStionable:TEMPerature:FPGA:MAXimum?') return float(var0)
#---------------------------------------------------------------------------
[docs] @scpi_error_check def get_current_carrier_temperature(self): """ Get current carrier board temperature (inside device). Parameters ---------- None 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 var0 = self._read('STATus:QUEStionable:TEMPerature:CARRier:CURRent?') return float(var0)
#---------------------------------------------------------------------------
[docs] @scpi_error_check def get_maximum_carrier_temperature(self): """ Get maximum carrier board temperature since boot or clear (inside device). Parameters ---------- None 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 var0 = self._read('STATus:QUEStionable:TEMPerature:CARRier:MAXimum?') return float(var0)
#--------------------------------------------------------------------------- @scpi_error_check def _set_reference_source(self, internal): """ Set reference (10MHz) clock source. Parameters ---------- internal : bool Reference clock source (False = External, True = Internal). Returns ------- None 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 self._write('STATus:QUEStionable:FREQuency:REFerence:SRC {}'.format(0 if internal == False else 1)) #--------------------------------------------------------------------------- @scpi_error_check def _get_reference_source(self): """ Get reference (10MHz) clock source. Parameters ---------- None 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 var0 = self._read('STATus:QUEStionable:FREQuency:REFerence:SRC?') return bool(int(var0)) #--------------------------------------------------------------------------- @scpi_error_check def _get_lo_hw_present(self): """ Check if LO hardware is present. Parameters ---------- None 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 var0 = self._read('LO:PRESent?') return bool(int(var0)) #---------------------------------------------------------------------------
[docs] @scpi_error_check def get_current_afe_temperature(self): """ Get current analog frontend board temperature (inside device). Parameters ---------- None 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 var0 = self._read('STATus:QUEStionable:TEMPerature:AFE:CURRent?') return float(var0)
#---------------------------------------------------------------------------
[docs] @scpi_error_check def get_maximum_afe_temperature(self): """ Get maximum analog frontend board temperature since boot or clear (inside device). Parameters ---------- None 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 var0 = self._read('STATus:QUEStionable:TEMPerature:AFE:MAXimum?') return float(var0)
#---------------------------------------------------------------------------
[docs] @scpi_error_check def get_current_lo_temperature(self): """ Get current local oscillator board temperature (inside device). Parameters ---------- None Returns ------- float Current 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 var0 = self._read('STATus:QUEStionable:TEMPerature:LO:CURRent?') return float(var0)
#---------------------------------------------------------------------------
[docs] @scpi_error_check def get_maximum_lo_temperature(self): """ Get maximum local oscillator board temperature since boot or clear (inside device). Parameters ---------- None 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 var0 = self._read('STATus:QUEStionable:TEMPerature:LO:MAXimum?') return float(var0)
#--------------------------------------------------------------------------- @scpi_error_check def _set_lo_freq_0(self, freq): """ Set LO frequency for output 0. Parameters ---------- freq : int Frequency in Hertz. Returns ------- None 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 self._write('STATus:QUEStionable:FREQuency:LO0 {}'.format(freq)) #--------------------------------------------------------------------------- @scpi_error_check def _get_lo_freq_0(self): """ Get LO frequency for output 0. Parameters ---------- None Returns ------- int 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 var0 = self._read('STATus:QUEStionable:FREQuency:LO0?') return int(var0) #--------------------------------------------------------------------------- @scpi_error_check def _set_lo_pwr_0(self, pwr): """ Set LO power for output 0. Parameters ---------- pwr : int Power in dBm. Returns ------- None 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 self._write('STATus:QUEStionable:POWer:LO0 {}'.format(pwr)) #--------------------------------------------------------------------------- @scpi_error_check def _get_lo_pwr_0(self): """ Get LO power for output 0. Parameters ---------- None 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 var0 = self._read('STATus:QUEStionable:POWer:LO0?') return int(var0) #--------------------------------------------------------------------------- @scpi_error_check def _set_lo_freq_1(self, freq): """ Set LO frequency for output 1. Parameters ---------- freq : int Frequency in Hertz. Returns ------- None 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 self._write('STATus:QUEStionable:FREQuency:LO1 {}'.format(freq)) #--------------------------------------------------------------------------- @scpi_error_check def _get_lo_freq_1(self): """ Get LO frequency for output 1. Parameters ---------- None Returns ------- int 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 var0 = self._read('STATus:QUEStionable:FREQuency:LO1?') return int(var0) #--------------------------------------------------------------------------- @scpi_error_check def _set_lo_pwr_1(self, pwr): """ Set LO power for output 1. Parameters ---------- pwr : int Power in dBm. Returns ------- None 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 self._write('STATus:QUEStionable:POWer:LO1 {}'.format(pwr)) #--------------------------------------------------------------------------- @scpi_error_check def _get_lo_pwr_1(self): """ Get LO power for output 1. Parameters ---------- None 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 var0 = self._read('STATus:QUEStionable:POWer:LO1?') return int(var0) #---------------------------------------------------------------------------
[docs] @scpi_error_check def get_assembler_status(self): """ Get assembler status. Refer to the assembler log to get more information regarding the assembler result. Parameters ---------- None 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 var0 = self._read('STATus:ASSEMbler:SUCCess?') return bool(int(var0))
#---------------------------------------------------------------------------
[docs] @scpi_error_check def get_assembler_log(self): """ Get assembler log. Parameters ---------- None Returns ------- str Assembler log. 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 var0 = self._read_bin('STATus:ASSEMbler:LOG?') return var0.decode('utf-8', 'ignore')
#--------------------------------------------------------------------------- @scpi_error_check def _set_out_amp_offset_0(self, offset): """ Set output amplifier offset for output 0. Parameters ---------- offset : float Offset in range of 0 to 56.5 millivolt. Returns ------- None 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 self._write('AFE:OFFSet:OUTAMP0 {}'.format(offset)) #--------------------------------------------------------------------------- @scpi_error_check def _get_out_amp_offset_0(self): """ Get output amplifier offset for output 0. Parameters ---------- None 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 var0 = self._read('AFE:OFFSet:OUTAMP0?') return float(var0) #--------------------------------------------------------------------------- @scpi_error_check def _set_dac_offset_0(self, offset): """ Set dac offset for output 0. Parameters ---------- offset : float Offset in volts. Returns ------- None 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 self._write('AFE:OFFSet:DAC0 {}'.format(offset)) #--------------------------------------------------------------------------- @scpi_error_check def _get_dac_offset_0(self): """ Get dac offset for output 0. Parameters ---------- None Returns ------- float Offset in volts. 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 var0 = self._read('AFE:OFFSet:DAC0?') return float(var0) #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write('AFE:OFFSet:OUTAMP1 {}'.format(offset)) #--------------------------------------------------------------------------- @scpi_error_check def _get_out_amp_offset_1(self): """ Get output amplifier offset for output 1. Parameters ---------- None 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 var0 = self._read('AFE:OFFSet:OUTAMP1?') return float(var0) #--------------------------------------------------------------------------- @scpi_error_check def _set_dac_offset_1(self, offset): """ Set dac offset for output 1. Parameters ---------- offset : float Offset in volts. Returns ------- None 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 self._write('AFE:OFFSet:DAC1 {}'.format(offset)) #--------------------------------------------------------------------------- @scpi_error_check def _get_dac_offset_1(self): """ Get dac offset for output 1. Parameters ---------- None Returns ------- float Offset in volts. 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 var0 = self._read('AFE:OFFSet:DAC1?') return float(var0) #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write_bin('SEQuencer{}:CHANnelmap '.format(sequencer), channel_map) #--------------------------------------------------------------------------- @scpi_error_check 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 var0 = self._read_bin('SEQuencer{}:CHANnelmap?'.format(sequencer)) return var0 #--------------------------------------------------------------------------- @scpi_error_check 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 fails, 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 ------- None 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 self._write_bin('SEQuencer{}:PROGram '.format(sequencer), program.encode('ascii')) #--------------------------------------------------------------------------- @scpi_error_check 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 configuration struct does not have the correct format, an error is set in system error. Parameters ---------- sequencer : int Sequencer index. config : bytes Configuration struct. Returns ------- None 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 self._write_bin('SEQuencer{}:CONFiguration '.format(sequencer), config) #--------------------------------------------------------------------------- @scpi_error_check 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 var0 = self._read_bin('SEQuencer{}:CONFiguration?'.format(sequencer)) return var0 #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write('SEQuencer{}:ARM'.format(sequencer)) #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write('SEQuencer{}:START'.format(sequencer)) #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write('SEQuencer{}:STOP'.format(sequencer)) #--------------------------------------------------------------------------- @scpi_error_check 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 Concatenated 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: Acquisition binning encountered internal FIFO error. - ACQ BINNING COMM ERROR: Acquisition 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 var0 = self._read('SEQuencer{}:STATE?'.format(sequencer)) return var0 #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write('SEQuencer{}:AWG:WLISt:WAVeform:NEW "{}",{},{}'.format(sequencer, name, size, 0 if is_integer == False else 1)) #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write('SEQuencer{}:AWG:WLISt:WAVeform:DELete "{}"'.format(sequencer, name)) #--------------------------------------------------------------------------- @scpi_error_check 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 waveform size does not match the size specified while adding the waveform or if the waveform samples are out-of-range, an error is set in the system error. Parameters ---------- sequencer : int Sequencer index. name : str Waveform name. waveform : list[float] List of floats in the range of 1.0 to -1.0 representing the waveform samples. Returns ------- None 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 self._write_bin('SEQuencer{}:AWG:WLISt:WAVeform:DATA "{}",'.format(sequencer, name), struct.pack('f'*len(waveform), *waveform)) #--------------------------------------------------------------------------- @scpi_error_check 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[float] List of floats in the range of 1.0 to -1.0 representing the waveform 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', 'int', 'int']) #SCPI call var0 = self._read_bin('SEQuencer{}:AWG:WLISt:WAVeform:DATA? "{}",{},{}'.format(sequencer, name, start, size)) return struct.unpack('f'*int(len(var0)/4), var0) #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write('SEQuencer{}:AWG:WLISt:WAVeform:INDex "{}",{}'.format(sequencer, name, index)) #--------------------------------------------------------------------------- @scpi_error_check 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 var0 = self._read('SEQuencer{}:AWG:WLISt:WAVeform:INDex? "{}"'.format(sequencer, name)) return int(var0) #--------------------------------------------------------------------------- @scpi_error_check 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 var0 = self._read('SEQuencer{}:AWG:WLISt:WAVeform:LENGth? "{}"'.format(sequencer, name)) return int(var0) #--------------------------------------------------------------------------- @scpi_error_check 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 : int 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 var0 = self._read('SEQuencer{}:AWG:WLISt:WAVeform:NAME? {}'.format(sequencer, index)) return var0 #--------------------------------------------------------------------------- @scpi_error_check 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 var0 = self._read('SEQuencer{}:AWG:WLISt:SIZE?'.format(sequencer)) return int(var0) #--------------------------------------------------------------------------- @scpi_error_check 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 ------- list[bytes] 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 var0 = self._read('SEQuencer{}:AWG:WLISt?'.format(sequencer)) return var0 #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write('AFE:GAIN:INAMP0 {}'.format(gain)) #--------------------------------------------------------------------------- @scpi_error_check def _get_in_amp_gain_0(self): """ Get input amplifier gain for input 0. Parameters ---------- None 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 var0 = self._read('AFE:GAIN:INAMP0?') return int(var0) #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write('AFE:GAIN:INAMP1 {}'.format(gain)) #--------------------------------------------------------------------------- @scpi_error_check def _get_in_amp_gain_1(self): """ Get input amplifier gain for input 1. Parameters ---------- None 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 var0 = self._read('AFE:GAIN:INAMP1?') return int(var0) #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write_bin('ACQ:SCOpe:CONFiguration '.format(), config) #--------------------------------------------------------------------------- @scpi_error_check 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 ---------- None 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 var0 = self._read_bin('ACQ:SCOpe:CONFiguration?') return var0 #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write('SEQuencer{}:ACQ:WLISt:WEIght:NEW "{}",{},{}'.format(sequencer, name, size, 0 if is_integer == False else 1)) #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write('SEQuencer{}:ACQ:WLISt:WEIght:DELete "{}"'.format(sequencer, name)) #--------------------------------------------------------------------------- @scpi_error_check def _set_acq_weight_data(self, sequencer, name, weight): """ 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 weight size does not match the size specified while adding the weight or if the weight samples are out-of-range, an error is set in the system error. Parameters ---------- sequencer : int Sequencer index. name : str Weight name. weight : list[float] List of floats in the range of 1.0 to -1.0 representing the weight samples. Returns ------- None 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 self._write_bin('SEQuencer{}:ACQ:WLISt:WEIght:DATA "{}",'.format(sequencer, name), struct.pack('f'*len(weight), *weight)) #--------------------------------------------------------------------------- @scpi_error_check 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[float] List of floats in the range of 1.0 to -1.0 representing the weight 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', 'int', 'int']) #SCPI call var0 = self._read_bin('SEQuencer{}:ACQ:WLISt:WEIght:DATA? "{}",{},{}'.format(sequencer, name, start, size)) return struct.unpack('f'*int(len(var0)/4), var0) #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write('SEQuencer{}:ACQ:WLISt:WEIght:INDex "{}",{}'.format(sequencer, name, index)) #--------------------------------------------------------------------------- @scpi_error_check 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 var0 = self._read('SEQuencer{}:ACQ:WLISt:WEIght:INDex? "{}"'.format(sequencer, name)) return int(var0) #--------------------------------------------------------------------------- @scpi_error_check 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 var0 = self._read('SEQuencer{}:ACQ:WLISt:WEIght:LENGth? "{}"'.format(sequencer, name)) return int(var0) #--------------------------------------------------------------------------- @scpi_error_check 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 : int 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 var0 = self._read('SEQuencer{}:ACQ:WLISt:WEIght:NAME? {}'.format(sequencer, index)) return var0 #--------------------------------------------------------------------------- @scpi_error_check 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 var0 = self._read('SEQuencer{}:ACQ:WLISt:SIZE?'.format(sequencer)) return int(var0) #--------------------------------------------------------------------------- @scpi_error_check 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 ------- list[bytes] 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 var0 = self._read('SEQuencer{}:ACQ:WLISt?'.format(sequencer)) return var0 #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write('SEQuencer{}:ACQ:ALISt:ACQuisition:NEW "{}",{}'.format(sequencer, name, num_bins)) #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write('SEQuencer{}:ACQ:ALISt:ACQuisition:DELete "{}"'.format(sequencer, name)) #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write('SEQuencer{}:ACQ:ALISt:ACQuisition:DATA "{}"'.format(sequencer, name)) #--------------------------------------------------------------------------- @scpi_error_check 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[bytes] Binary structure containing the 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 var0 = self._read('SEQuencer{}:ACQ:ALISt:ACQuisition:DATA? "{}"'.format(sequencer, name)) return var0 #--------------------------------------------------------------------------- @scpi_error_check 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 ------- None 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 self._write('SEQuencer{}:ACQ:ALISt:ACQuisition:INDex "{}",{}'.format(sequencer, name, index)) #--------------------------------------------------------------------------- @scpi_error_check 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 var0 = self._read('SEQuencer{}:ACQ:ALISt:ACQuisition:INDex? "{}"'.format(sequencer, name)) return int(var0) #--------------------------------------------------------------------------- @scpi_error_check 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 var0 = self._read('SEQuencer{}:ACQ:ALISt:ACQuisition:BINs? "{}"'.format(sequencer, name)) return int(var0) #--------------------------------------------------------------------------- @scpi_error_check def _get_acq_acquisition_name(self, sequencer, index): """ 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 : int 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', 'int']) #SCPI call var0 = self._read('SEQuencer{}:ACQ:ALISt:ACQuisition:NAME? {}'.format(sequencer, index)) return var0 #--------------------------------------------------------------------------- @scpi_error_check def _get_acq_num_acquisitions(self, sequencer): """ Get number of 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 Number of 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 var0 = self._read('SEQuencer{}:ACQ:ALISt:SIZE?'.format(sequencer)) return int(var0) #--------------------------------------------------------------------------- @scpi_error_check 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 ------- list[bytes] 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 var0 = self._read('SEQuencer{}:ACQ:ALISt?'.format(sequencer)) return var0 #----------------------------------------------------------------------- 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 TypeError("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 TypeError("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