Exemple #1
0
 def __init__(self, name: str, index: int, parent_instr,
              parent_contr) -> None:
     InstrumentChannel.__init__(self, parent_instr, name)
     self._awg = HDAWG_AWG(parent_contr, index)
     self._awg._setup()
     # add custom parameters as QCoDeS parameters
     self.add_parameter(
         "output1",
         unit=self._awg.output1._unit,
         docstring=self._awg.output1.__repr__(),
         get_cmd=self._awg.output1,
         set_cmd=self._awg.output1,
         label="Output Ch 1",
         vals=vals.OnOff(),
     )
     self.add_parameter(
         "output2",
         unit=self._awg.output2._unit,
         docstring=self._awg.output2.__repr__(),
         get_cmd=self._awg.output2,
         set_cmd=self._awg.output2,
         label="Output Ch 2",
         vals=vals.OnOff(),
     )
     self.add_parameter(
         "gain1",
         unit=self._awg.gain1._unit,
         docstring=self._awg.gain1.__repr__(),
         get_cmd=self._awg.gain1,
         set_cmd=self._awg.gain1,
         label="Gain Ch 1",
         vals=vals.Numbers(-1, 1),
     )
     self.add_parameter(
         "gain2",
         unit=self._awg.gain2._unit,
         docstring=self._awg.gain2.__repr__(),
         get_cmd=self._awg.gain2,
         set_cmd=self._awg.gain2,
         label="Gain Ch 2",
         vals=vals.Numbers(-1, 1),
     )
     self.add_parameter(
         "modulation_phase_shift",
         unit=self._awg.modulation_phase_shift._unit,
         docstring=self._awg.modulation_phase_shift.__repr__(),
         get_cmd=self._awg.modulation_phase_shift,
         set_cmd=self._awg.modulation_phase_shift,
         label="Modulation Phase Shift",
         vals=vals.Numbers(),
     )
     self.add_parameter(
         "modulation_freq",
         unit=self._awg.modulation_freq._unit,
         docstring=self._awg.modulation_freq.__repr__(),
         get_cmd=self._awg.modulation_freq,
         set_cmd=self._awg.modulation_freq,
         label="Modulation Frequency",
         vals=vals.Numbers(),
     )
Exemple #2
0
 def __init__(self, name: str, parent_instr, parent_contr) -> None:
     super().__init__(parent_instr, name)
     self._awg = UHFQA_AWG(parent_contr, 0)
     self._awg._setup()
     # add custom parameters as QCoDeS parameters
     self.add_parameter(
         "output1",
         unit=self._awg.output1._unit,
         docstring=self._awg.output1.__repr__(),
         get_cmd=self._awg.output1,
         set_cmd=self._awg.output1,
         label="Output Ch 1",
         vals=vals.OnOff(),
     )
     self.add_parameter(
         "output2",
         unit=self._awg.output2._unit,
         docstring=self._awg.output2.__repr__(),
         get_cmd=self._awg.output2,
         set_cmd=self._awg.output2,
         label="Output Ch 2",
         vals=vals.OnOff(),
     )
     self.add_parameter(
         "gain1",
         unit=self._awg.gain1._unit,
         docstring=self._awg.gain1.__repr__(),
         get_cmd=self._awg.gain1,
         set_cmd=self._awg.gain1,
         label="Gain Ch 1",
         vals=vals.Numbers(-1, 1),
     )
     self.add_parameter(
         "gain2",
         unit=self._awg.gain2._unit,
         docstring=self._awg.gain2.__repr__(),
         get_cmd=self._awg.gain2,
         set_cmd=self._awg.gain2,
         label="Gain Ch 2",
         vals=vals.Numbers(-1, 1),
     )
Exemple #3
0
    assert p.cache._value == 42
    assert p.cache._raw_value == 42
    assert p.cache.timestamp is not None


_P = Parameter


@pytest.mark.parametrize(
    argnames=('p', 'value', 'raw_value'),
    argvalues=(
        (_P('p', set_cmd=None, get_cmd=None), 4, 4),
        (_P('p', set_cmd=False, get_cmd=None), 14, 14),
        (_P('p', set_cmd=None, get_cmd=False), 14, 14),
        (_P('p', set_cmd=None, get_cmd=None, vals=vals.OnOff()), 'on', 'on'),
        (_P('p', set_cmd=None, get_cmd=None, val_mapping={'screw': 1}),
         'screw', 1),
        (_P('p', set_cmd=None, get_cmd=None, set_parser=str, get_parser=int),
         14, '14'),
        (_P('p', set_cmd=None, get_cmd=None, step=7), 14, 14),
        (_P('p', set_cmd=None, get_cmd=None, offset=3), 14, 17),
        (_P('p', set_cmd=None, get_cmd=None, scale=2), 14, 28),
        (_P('p', set_cmd=None, get_cmd=None, offset=-3, scale=2), 14, 25),
    ),
    ids=(
        'with_nothing_extra',
        'without_set_cmd',
        'without_get_cmd',
        'with_on_off_validator',
        'with_val_mapping',
Exemple #4
0
    def __init__(self, name, address, baudrate=9600):

        super().__init__(name, address)

        handle = self.visa_handle
        handle.baud_rate = baudrate

        self._bit_mask = 0x00

        self.add_parameter('phase_1_4',
                           label='phase_1_4',
                           vals=validators.OnOff(),
                           val_mapping={
                               'on': 1,
                               'off': 0
                           },
                           set_cmd=lambda val: self._set_bit(val, '1_4'),
                           get_cmd=lambda: self._get_bit('1_4'))

        self.add_parameter('phase_2_8',
                           label='phase_2_8',
                           vals=validators.OnOff(),
                           val_mapping={
                               'on': 1,
                               'off': 0
                           },
                           set_cmd=lambda val: self._set_bit(val, '2_8'),
                           get_cmd=lambda: self._get_bit('2_8'))

        self.add_parameter('phase_5_6',
                           label='phase_5_6',
                           vals=validators.OnOff(),
                           val_mapping={
                               'on': 1,
                               'off': 0
                           },
                           set_cmd=lambda val: self._set_bit(val, '5_6'),
                           get_cmd=lambda: self._get_bit('5_6'))

        self.add_parameter('phase_11_2',
                           label='phase_11_2',
                           vals=validators.OnOff(),
                           val_mapping={
                               'on': 1,
                               'off': 0
                           },
                           set_cmd=lambda val: self._set_bit(val, '11_2'),
                           get_cmd=lambda: self._get_bit('11_2'))

        self.add_parameter('phase_22_5',
                           label='phase_22_5',
                           vals=validators.OnOff(),
                           val_mapping={
                               'on': 1,
                               'off': 0
                           },
                           set_cmd=lambda val: self._set_bit(val, '22_5'),
                           get_cmd=lambda: self._get_bit('22_5'))

        self.add_parameter('phase_45',
                           label='phase_45',
                           vals=validators.OnOff(),
                           val_mapping={
                               'on': 1,
                               'off': 0
                           },
                           set_cmd=lambda val: self._set_bit(val, '45'),
                           get_cmd=lambda: self._get_bit('45'))

        self.add_parameter('phase_90',
                           label='phase_90',
                           vals=validators.OnOff(),
                           val_mapping={
                               'on': 1,
                               'off': 0
                           },
                           set_cmd=lambda val: self._set_bit(val, '90'),
                           get_cmd=lambda: self._get_bit('90'))

        self.add_parameter('phase_180',
                           label='phase_180',
                           vals=validators.OnOff(),
                           val_mapping={
                               'on': 1,
                               'off': 0
                           },
                           set_cmd=lambda val: self._set_bit(val, '180'),
                           get_cmd=lambda: self._get_bit('180'))
        self._write()

        self.connect_message()
    assert p.cache._raw_value == 42
    assert p.cache.timestamp is not None


_P = Parameter


@pytest.mark.parametrize(argnames=('p', 'value', 'raw_value'),
                         argvalues=(
                             (_P('p', set_cmd=None, get_cmd=None), 4, 4),
                             (_P('p', set_cmd=False, get_cmd=None), 14, 14),
                             (_P('p', set_cmd=None, get_cmd=False), 14, 14),
                             (_P('p',
                                 set_cmd=None,
                                 get_cmd=None,
                                 vals=vals.OnOff()), 'on', 'on'),
                             (_P('p',
                                 set_cmd=None,
                                 get_cmd=None,
                                 val_mapping={'screw': 1}), 'screw', 1),
                             (_P('p',
                                 set_cmd=None,
                                 get_cmd=None,
                                 set_parser=str,
                                 get_parser=int), 14, '14'),
                             (_P('p', set_cmd=None, get_cmd=None,
                                 step=7), 14, 14),
                             (_P('p', set_cmd=None, get_cmd=None,
                                 offset=3), 14, 17),
                             (_P('p', set_cmd=None, get_cmd=None,
                                 scale=2), 14, 28),
Exemple #6
0
    def __init__(self, name, address, **kwargs):

        super().__init__(name=name, address=address, **kwargs)

        self.add_parameter(name='power',
                           label='Power',
                           unit='dBm',
                           get_cmd='SOUR:POW?',
                           set_cmd='SOUR:POW {:.4f}',
                           get_parser=VISA_str_to_int,
                           vals=vals.Numbers(-150, 25))

        self.add_function('tooltip_on', call_cmd='SYST:ERR:DISP ON')
        self.add_function('tooltip_off', call_cmd='SYST:ERR:DISP OFF')
        self.add_function('cont_meas_on', call_cmd='INIT:CONT:ALL ON')
        self.add_function('cont_meas_off', call_cmd='INIT:CONT:ALL OFF')
        self.add_function('update_display_once', call_cmd='SYST:DISP:UPD ONCE')
        self.add_function('update_display_on', call_cmd='SYST:DISP:UPD ON')
        self.add_function('update_display_off', call_cmd='SYST:DISP:UPD OFF')
        self.add_function('rf_off', call_cmd='OUTP1 OFF')
        self.add_function('rf_on', call_cmd='OUTP1 ON')

        ###################
        # Common commands #
        ###################
        # common commands for all devices as described in IEEE 488.2
        self.add_function('reset', call_cmd='*RST')
        self.add_function('wait_to_continue', call_cmd='*WAI')

        ######################
        # CALCULATE commands #
        ######################
        # commands for post-acquisition data processing
        self.add_parameter('format',
                           set_cmd='CALCULATE:FORMAT {:s}',
                           vals=vals.Enum('mlin', 'mlog', 'phas', 'uph', 'pol',
                                          'smit', 'ism', 'gdel', 'real',
                                          'imag', 'swr'))

        ####################
        # DISPLAY commands #
        ####################
        # Commands to select and present data on screen
        self.add_function('autoscale_trace', call_cmd='DISP:TRAC:Y:AUTO ONCE')

        #####################
        # INITIATE commands #
        #####################
        # commands to control the initialization of the trigger system and define
        # the scope ot the triggered measurement
        self.add_parameter(name='continuous_mode_all',
                           docstring='My explanation',
                           set_cmd='INIT:CONT {:s}',
                           vals=vals.OnOff())

        self.add_function('start_sweep_all', call_cmd='INITIATE:IMMEDIATE:ALL')

        ##################
        # SENSE commands #
        ##################
        # commands affecting the receiver settings
        self.add_function('clear_avg', call_cmd='SENS:AVER:CLEAR')

        self.add_parameter(name='avg',
                           label='Averages',
                           unit='',
                           get_cmd='SENS:AVER:COUN?',
                           set_cmd='SENS:AVER:COUN {:.4f}',
                           get_parser=VISA_str_to_int,
                           vals=vals.Numbers(1, 1000))

        self.add_parameter(name='average_mode',
                           get_cmd='SENS:AVER:MODE?',
                           set_cmd='SENS:AVER:MODE {:s}',
                           vals=vals.Enum('auto', 'flatten', 'reduce',
                                          'moving'))

        self.add_parameter(name='average_state',
                           get_cmd='SENS:AVER:STAT?',
                           set_cmd='SENS:AVER:STAT {:s}',
                           vals=vals.OnOff())

        self.add_parameter(name='bandwidth',
                           label='Bandwidth',
                           unit='Hz',
                           get_cmd='SENS:BAND?',
                           set_cmd='SENS:BAND {:.4f}',
                           get_parser=VISA_str_to_int,
                           vals=vals.Numbers(1, 1e6))

        self.add_parameter(name='center_frequency',
                           unit='Hz',
                           get_cmd='SENSE:FREQUENCY:CENTER?',
                           set_cmd='SENSE:FREQUENCY:CENTER {:.4f}',
                           get_parser=VISA_str_to_int,
                           vals=vals.Numbers(100e3, 20e9))

        self.add_parameter(name='span_frequency',
                           unit='Hz',
                           get_cmd='SENSE:FREQUENCY:SPAN?',
                           set_cmd='SENSE:FREQUENCY:SPAN {:.4f}',
                           get_parser=VISA_str_to_int,
                           vals=vals.Numbers(0, 20e9))

        self.add_parameter(name='start_frequency',
                           unit='Hz',
                           get_cmd='SENSE:FREQUENCY:START?',
                           set_cmd='SENSE:FREQUENCY:START {:.4f}',
                           get_parser=VISA_str_to_int,
                           vals=vals.Numbers(100e3, 20e9))

        self.add_parameter(name='stop_frequency',
                           unit='Hz',
                           get_cmd='SENSE:FREQUENCY:STOP?',
                           set_cmd='SENSE:FREQUENCY:STOP {:.4f}',
                           get_parser=VISA_str_to_int,
                           vals=vals.Numbers(100e3, 20e9))

        self.add_function('delete_all_segments', call_cmd='SENS:SEGM:DEL:ALL')

        self.add_parameter(name='number_sweeps_all',
                           set_cmd='SENS:SWE:COUN:ALL {:.4f}',
                           vals=vals.Ints(1, 100000))

        self.add_parameter(name='npts',
                           get_cmd='SENS:SWE:POIN?',
                           set_cmd='SENS:SWE:POIN {:.4f}',
                           get_parser=VISA_str_to_int,
                           vals=vals.Ints(1, 100001))

        self.add_parameter(name='min_sweep_time',
                           get_cmd='SENS:SWE:TIME:AUTO?',
                           set_cmd='SENS:SWE:TIME:AUTO {:s}',
                           get_parser=VISA_str_to_int,
                           vals=vals.OnOff())

        self.add_parameter(name='sweep_time',
                           get_cmd='SENS:SWE:TIME?',
                           set_cmd='SENS:SWE:TIME {:.4f}',
                           get_parser=VISA_str_to_float,
                           vals=vals.Numbers(0, 1e5))

        self.add_parameter(name='sweep_type',
                           get_cmd='SENS:SWE:TYPE?',
                           set_cmd='SENS:SWE:TYPE {:s}',
                           get_parser=str,
                           vals=vals.Enum('lin', 'linear', 'log',
                                          'logarithmic', 'pow', 'power', 'cw',
                                          'poin', 'point', 'segm', 'segment'))

        #####################
        #  TRIGGER commands #
        #####################
        # commands to syncronize analyzer's actions
        self.add_parameter(name='trigger_source',
                           set_cmd='TRIGGER:SEQUENCE:SOURCE {:s}',
                           vals=vals.Enum('immediate', 'external', 'manual',
                                          'multiple'))

        self.reset()
        self.connect_message()