Exemplo n.º 1
0
    def __init__(self, parent: 'GS200', name: str, present: bool) -> None:
        super().__init__(parent, name)

        self.present = present

        # Start off with all disabled
        self._enabled = False
        self._output = False

        # Set up mode cache. These will be filled in once the parent
        # is fully initialized.
        self._range: Union[None, float] = None
        self._unit: Union[None, str] = None

        # Set up monitoring parameters
        if present:
            self.add_parameter('enabled',
                               label='Measurement Enabled',
                               get_cmd=self.state,
                               set_cmd=lambda x: self.on()
                               if x else self.off(),
                               val_mapping={
                                   'off': 0,
                                   'on': 1,
                               })

            # Note: Measurement will only run if source and
            # measurement is enabled.
            self.add_parameter('measure',
                               label='<unset>',
                               unit='V/I',
                               get_cmd=self._get_measurement,
                               snapshot_get=False)

            self.add_parameter('NPLC',
                               label='NPLC',
                               unit='1/LineFreq',
                               vals=Ints(1, 25),
                               set_cmd=':SENS:NPLC {}',
                               set_parser=int,
                               get_cmd=':SENS:NPLC?',
                               get_parser=float_round)
            self.add_parameter('delay',
                               label='Measurement Delay',
                               unit='ms',
                               vals=Ints(0, 999999),
                               set_cmd=':SENS:DEL {}',
                               set_parser=int,
                               get_cmd=':SENS:DEL?',
                               get_parser=float_round)

            self.add_parameter('interval',
                               label='Measurement Interval',
                               unit='s',
                               vals=Numbers(0.1, 3600),
                               set_cmd=':SENS:INT {}',
                               set_parser=float,
                               get_cmd=':SENS:INT?',
                               get_parser=float)
Exemplo n.º 2
0
    def __init__(self, parent: VisaInstrument, name: str,
                 proper_function: str) -> None:

        super().__init__(parent, name)

        self._proper_function = proper_function
        range_vals = self.function_modes[self._proper_function]["range_vals"]
        unit = self.function_modes[self._proper_function]["unit"]

        self.function = self.parent.digi_sense_function

        self.add_parameter(
            self._proper_function,
            get_cmd=self._measure,
            unit=unit,
            docstring="Make measurements, place them in a reading buffer, and "
            "return the last reading.")

        self.add_parameter(
            "range",
            get_cmd=f":SENSe:DIGitize:{self._proper_function}:RANGe?",
            set_cmd=f":SENSe:DIGitize:{self._proper_function}:RANGe {{}}",
            vals=range_vals,
            get_parser=float,
            unit=unit,
            docstring="Determine the positive full-scale measure range.")

        self.add_parameter(
            "input_impedance",
            get_cmd=":SENSe:DIGitize:VOLTage:INPutimpedance?",
            set_cmd=":SENSe:DIGitize:VOLTage:INPutimpedance {}",
            vals=Enum("AUTO", "MOHM10"),
            docstring="Determine when the 10 MΩ input divider is enabled. "
            "'MOHM10' means 10 MΩ for all ranges.")

        self.add_parameter(
            'acq_rate',
            get_cmd=f":SENSe:DIGitize:{self._proper_function}:SRATE?",
            set_cmd=f":SENSe:DIGitize:{self._proper_function}:SRATE {{}}",
            vals=Ints(1000, 1000000),
            docstring="Define the precise acquisition rate at which the "
            "digitizing measurements are made.")

        self.add_parameter(
            "aperture",
            get_cmd=f":SENSe:DIGitize:{self._proper_function}:APERture?",
            set_cmd=f":SENSe:DIGitize:{self._proper_function}:APERture {{}}",
            unit="us",
            docstring="Determine the aperture setting.")

        self.add_parameter(
            "count",
            get_cmd="SENSe:DIGitize:COUNt?",
            set_cmd="SENSe:DIGitize:COUNt {}",
            vals=Ints(1, 55000000),
            docstring="Set the number of measurements to digitize when a "
            "measurement is requested")
Exemplo n.º 3
0
    def __init__(self, parent: "AMI430") -> None:
        super().__init__(parent, "SwitchHeater")

        # Add state parameters
        self.add_parameter(
            "enabled",
            label="Switch Heater Enabled",
            get_cmd=self.check_enabled,
            set_cmd=lambda x: (self.enable() if x else self.disable()),
            vals=Bool(),
        )
        self.add_parameter(
            "state",
            label="Switch Heater On",
            get_cmd=self.check_state,
            set_cmd=lambda x: (self.on() if x else self.off()),
            vals=Bool(),
        )
        self.add_parameter(
            "in_persistent_mode",
            label="Persistent Mode",
            get_cmd="PERS?",
            val_mapping={
                True: 1,
                False: 0
            },
        )

        # Configuration Parameters
        self.add_parameter(
            "current",
            label="Switch Heater Current",
            unit="mA",
            get_cmd="PS:CURR?",
            get_parser=float,
            set_cmd="CONF:PS:CURR {}",
            vals=Numbers(0, 125),
        )
        self.add_parameter(
            "heat_time",
            label="Heating Time",
            unit="s",
            get_cmd="PS:HTIME?",
            get_parser=int,
            set_cmd="CONF:PS:HTIME {}",
            vals=Ints(5, 120),
        )
        self.add_parameter(
            "cool_time",
            label="Cooling Time",
            unit="s",
            get_cmd="PS:CTIME?",
            get_parser=int,
            set_cmd="CONF:PS:CTIME {}",
            vals=Ints(5, 3600),
        )
Exemplo n.º 4
0
    def __init__(self, parent: "DMC4133Controller", name: str,
                 **kwargs: Any) -> None:
        """
        Initializes the vector mode submodule for the controller

        Args:
            parent: an instance of DMC4133Controller
            name: name of the vector mode plane
        """
        super().__init__(parent, name, **kwargs)
        self._plane = name
        self._vector_position_validator = Ints(min_value=-2147483648,
                                               max_value=2147483647)

        self.add_parameter(
            "coordinate_system",
            get_cmd="CA ?",
            get_parser=self._parse_coordinate_system_active,
            set_cmd="CA {}",
            vals=Enum("S", "T"),
            docstring="activates coordinate system for the motion. Two "
            " coordinate systems are possible with values "
            "'S' and 'T'. All vector mode commands will apply to "
            "the active coordinate system.",
        )

        self.add_parameter(
            "vector_acceleration",
            get_cmd="VA ?",
            get_parser=lambda s: int(float(s)),
            set_cmd="VA {}",
            vals=Multiples(min_value=1024, max_value=1073740800, divisor=1024),
            unit="counts/sec2",
            docstring="sets and gets the defined vector's acceleration",
        )

        self.add_parameter(
            "vector_deceleration",
            get_cmd="VD ?",
            get_parser=lambda s: int(float(s)),
            set_cmd="VD {}",
            vals=Multiples(min_value=1024, max_value=1073740800, divisor=1024),
            unit="counts/sec2",
            docstring="sets and gets the defined vector's deceleration",
        )

        self.add_parameter(
            "vector_speed",
            get_cmd="VS ?",
            get_parser=lambda s: int(float(s)),
            set_cmd="VS {}",
            vals=Multiples(min_value=2, max_value=15000000, divisor=2),
            unit="counts/sec",
            docstring="sets and gets defined vector's speed",
        )
Exemplo n.º 5
0
    def test_failed_numbers(self):
        with self.assertRaises(TypeError):
            Ints(1, 2, 3)

        with self.assertRaises(TypeError):
            Ints(1, 1)  # min >= max

        for val in self.not_ints:
            with self.assertRaises((TypeError, OverflowError)):
                Ints(max_value=val)

            with self.assertRaises((TypeError, OverflowError)):
                Ints(min_value=val)
Exemplo n.º 6
0
def test_failed_numbers():
    with pytest.raises(TypeError):
        Ints(1, 2, 3)

    with pytest.raises(TypeError):
        Ints(1, 1)  # min >= max

    for val in not_ints:
        with pytest.raises((TypeError, OverflowError)):
            Ints(max_value=val)

        with pytest.raises((TypeError, OverflowError)):
            Ints(min_value=val)
Exemplo n.º 7
0
    def __init__(self, name, address, reset=False, **kwargs):
        super().__init__(name,
                         address,
                         terminator='\r\n',
                         device_clear=False,
                         **kwargs)

        self.add_parameter(name='voltage',
                           label='Voltage',
                           unit='V',
                           get_cmd='OD',
                           set_cmd='S{:.5E}\r\nE',
                           get_parser=voltage_parser,
                           vals=Numbers(min_value=-30.0, max_value=30.0),
                           post_delay=0.1)
        self.add_parameter(name='voltage_limit',
                           label='Voltage limit',
                           unit='V',
                           set_cmd='LV{:d}',
                           post_delay=0.1,
                           vals=Ints(min_value=1, max_value=30))
        self.add_parameter(
            name='panel_settings',
            label='Panel settings',
            get_cmd=self._get_panel_settings,
        )
        self.add_parameter(name='status', label='current status', get_cmd='OC')

        self.add_function('enable_output', call_cmd='O1E')
        self.add_function('disable_output', call_cmd='O0E')
Exemplo n.º 8
0
    def __init__(self, name, spi_rack, module, **kwargs):
        super().__init__(name, **kwargs)

        self.f1d = F1d_module(spi_rack, module)

        self.add_parameter('IQ_filter',
                           label='IQ filter',
                           set_cmd=self.f1d.set_IQ_filter,
                           unit='MHz',
                           vals=Ints(1, 3, 10, 20))

        self.add_parameter('I_gain',
                           label='I gain',
                           set_cmd=self.f1d.set_I_gain,
                           vals=Enum('low', 'mid', 'high'))

        self.add_parameter('Q_gain',
                           label='Q gain',
                           set_cmd=self.f1d.set_Q_gain,
                           vals=Enum('low', 'mid', 'high'))

        self.add_parameter('RF_level',
                           label='RF level',
                           set_cmd=self.f1d.get_RF_level,
                           unit='dBm')

        self.add_parameter('LO_level',
                           label='LO level',
                           set_cmd=self.f1d.get_LO_level,
                           unit='dBm')

        self.add_function('enable_remote', self.f1d.enable_remote)
        self.add_function('is_rf_clipped', self.f1d.rf_clipped)
Exemplo n.º 9
0
def test_good():
    m = MultiTypeOr(Strings(2, 4), Ints(10, 1000))

    for v in [10, 11, 123, 1000, "aa", "mop", "FRED"]:
        m.validate(v)

    for v in [
            9,
            1001,
            "Q",
            "Qcode",
            None,
            100.0,
            b"nice",
        [],
        {},
            a_func,
            AClass,
            AClass(),
            True,
            False,
    ]:
        with pytest.raises(ValueError):
            m.validate(v)

    assert repr(m) == "<MultiTypeOr: Strings 2<=len<=4, Ints 10<=v<=1000>"
    assert m.is_numeric
    assert not MultiTypeOr(Strings(), Enum(1, 2)).is_numeric
Exemplo n.º 10
0
    def test_elt_vals(self):
        l = Lists(Ints(max_value=10))
        v1 = [0, 1, 5]
        l.validate(v1)

        v2 = [0, 1, 11]
        with self.assertRaises(ValueError):
            l.validate(v2)
Exemplo n.º 11
0
def test_elt_vals():
    l = Lists(Ints(max_value=10))
    v1 = [0, 1, 5]
    l.validate(v1)

    v2 = [0, 1, 11]
    with pytest.raises(ValueError):
        l.validate(v2)
Exemplo n.º 12
0
def test_elt_vals():
    l = Sequence(Ints(max_value=10))
    v1 = [0, 1, 5]
    l.validate(v1)

    v2 = [0, 1, 11]
    with pytest.raises(ValueError, match="11 is invalid: must be between"):
        l.validate(v2)
Exemplo n.º 13
0
def test_unlimited():
    n = Ints()
    n.validate(n.valid_values[0])

    for v in ints:
        n.validate(v)

    for v in not_ints:
        with pytest.raises(TypeError):
            n.validate(v)
Exemplo n.º 14
0
    def test_unlimited(self):
        n = Ints()
        n.validate(n.valid_values[0])

        for v in self.ints:
            n.validate(v)

        for v in self.not_ints:
            with self.assertRaises(TypeError):
                n.validate(v)
Exemplo n.º 15
0
    def __init__(self, parent: 'AMI430') -> None:
        super().__init__(parent, "SwitchHeater")

        # Add state parameters
        self.add_parameter('enabled',
                           label='Switch Heater Enabled',
                           get_cmd=self.check_enabled,
                           set_cmd=lambda x: (self.enable()
                                              if x else self.disable()),
                           vals=Bool())
        self.add_parameter('state',
                           label='Switch Heater On',
                           get_cmd=self.check_state,
                           set_cmd=lambda x: (self.on() if x else self.off()),
                           vals=Bool())
        self.add_parameter('in_persistent_mode',
                           label='Persistent Mode',
                           get_cmd="PERS?",
                           val_mapping={
                               True: 1,
                               False: 0
                           })

        # Configuration Parameters
        self.add_parameter('current',
                           label='Switch Heater Current',
                           unit='mA',
                           get_cmd='PS:CURR?',
                           get_parser=float,
                           set_cmd='CONF:PS:CURR {}',
                           vals=Numbers(0, 125))
        self.add_parameter('heat_time',
                           label='Heating Time',
                           unit='s',
                           get_cmd='PS:HTIME?',
                           get_parser=int,
                           set_cmd='CONF:PS:HTIME {}',
                           vals=Ints(5, 120))
        self.add_parameter('cool_time',
                           label='Cooling Time',
                           unit='s',
                           get_cmd='PS:CTIME?',
                           get_parser=int,
                           set_cmd='CONF:PS:CTIME {}',
                           vals=Ints(5, 3600))
    def __init__(self, parent: 'Keithley2460', name: str,
                 proper_function: str) -> None:
        super().__init__(parent, name)
        self._proper_function = proper_function
        range_vals = self.function_modes[self._proper_function]["range_vals"]
        unit = self.function_modes[self._proper_function]["unit"]

        self.function = self.parent.sense_function

        self.add_parameter(
            "four_wire_measurement",
            set_cmd=f":SENSe:{self._proper_function}:RSENse {{}}",
            get_cmd=f":SENSe:{self._proper_function}:RSENse?",
            val_mapping=create_on_off_val_mapping(on_val="1", off_val="0"))

        self.add_parameter(
            "range",
            set_cmd=f":SENSe:{self._proper_function}:RANGe {{}}",
            get_cmd=f":SENSe:{self._proper_function}:RANGe?",
            vals=range_vals,
            get_parser=float,
            unit=unit)

        self.add_parameter(
            "auto_range",
            set_cmd=f":SENSe:{self._proper_function}:RANGe:AUTO {{}}",
            get_cmd=f":SENSe:{self._proper_function}:RANGe:AUTO?",
            val_mapping=create_on_off_val_mapping(on_val="1", off_val="0"))

        self.add_parameter(self._proper_function,
                           get_cmd=self._measure,
                           get_parser=float,
                           unit=unit,
                           snapshot_value=False)

        self.add_parameter("sweep",
                           label=self._proper_function,
                           get_cmd=self._measure_sweep,
                           unit=unit,
                           vals=Arrays(shape=(self.parent.npts, )),
                           parameter_class=ParameterWithSetpoints)

        self.add_parameter(
            "nplc",
            get_cmd=f":SENSe:{self._proper_function}:NPLCycles?",
            set_cmd=f":SENSe:{self._proper_function}:NPLCycles {{}}",
            vals=Numbers(0.001, 10))

        self.add_parameter('user_number',
                           get_cmd=None,
                           set_cmd=None,
                           vals=Ints(1, 5))

        self.add_parameter("user_delay",
                           get_cmd=self._get_user_delay,
                           set_cmd=self._set_user_delay,
                           vals=Numbers(0, 1e4))
Exemplo n.º 17
0
    def __init__(self, parent: 'GS200', name: str) -> None:
        super().__init__(parent, name)
        self._repeat = 1
        self._file_name = None

        self.add_parameter("interval",
                           label="the program interval time",
                           unit='s',
                           vals=Numbers(0.1, 3600.0),
                           get_cmd=":PROG:INT?",
                           set_cmd=":PROG:INT {}")

        self.add_parameter("slope",
                           label="the program slope time",
                           unit='s',
                           vals=Numbers(0.1, 3600.0),
                           get_cmd=":PROG:SLOP?",
                           set_cmd=":PROG:SLOP {}")

        self.add_parameter("save",
                           set_cmd=":PROG:SAVE '{}'",
                           docstring="save the program to the system memory "
                           "(.csv file)")

        self.add_parameter("load",
                           get_cmd=":PROG:LOAD?",
                           set_cmd=":PROG:LOAD '{}'",
                           docstring="load the program (.csv file) from the "
                           "system memory")

        self.add_parameter("repeat",
                           label="program execution repetition",
                           get_cmd=":PROG:REP?",
                           set_cmd=":PROG:REP {}",
                           val_mapping={
                               'OFF': 0,
                               'ON': 1
                           })
        self.add_parameter("count",
                           label="step of the current program",
                           get_cmd=":PROG:COUN?",
                           set_cmd=":PROG:COUN {}",
                           vals=Ints(1, 10000))

        self.add_function('start',
                          call_cmd=":PROG:EDIT:STAR",
                          docstring="start program editing")
        self.add_function('end',
                          call_cmd=":PROG:EDIT:END",
                          docstring="end program editing")
        self.add_function(
            'run',
            call_cmd=":PROG:RUN",
            docstring="run the program",
        )
Exemplo n.º 18
0
    def test_max(self):
        for max_val in self.ints:
            n = Ints(max_value=max_val)
            for v in self.ints:
                if v <= max_val:
                    n.validate(v)
                else:
                    with self.assertRaises(ValueError):
                        n.validate(v)

        for v in self.not_ints:
            with self.assertRaises(TypeError):
                n.validate(v)
Exemplo n.º 19
0
def test_max():
    for max_val in ints:
        n = Ints(max_value=max_val)
        for v in ints:
            if v <= max_val:
                n.validate(v)
            else:
                with pytest.raises(ValueError):
                    n.validate(v)

    for v in not_ints:
        with pytest.raises(TypeError):
            n.validate(v)
Exemplo n.º 20
0
    def __init__(self, parent: Instrument, name: str, id: int, **kwargs):
        super().__init__(parent=parent, name=name, **kwargs)
        self.fpga = self._parent.fpga
        self.id = id
        self.n_pointer_bits = 9
        self.n_op_bits = 10
        self.n_phase_bits = 45
        self.n_accum_bits = 45
        self.n_amp_bits = 16
        self.n_timing_bits = 32  # number of bits for pulse to auto-advance
        self.clk = 100e6
        self.v_max = 1.5
        self.f_max = 200e6
        self.fpga_port = self.id

        self.pulse_timing_offset = 14  # Offset for auto-advancing of pulses

        self.add_parameter(
            'output_enable',
            label=f'ch{self.id} output_enable',
            set_cmd=self._set_output_enable,
            vals=Bool(),
            docstring='Whether the system has an enabled output')

        self.add_parameter(
            'load_delay',
            label=f'ch{self.id} load_delay',
            set_cmd=self._set_load_delay,
            vals=Ints(0, 15),
            docstring='How long the delay should be during loading a new pulse '
            'to calculate the new coefficients (delay in samples).')

        self.add_parameter(
            'pcdds_enable',
            label=f'ch{self.id} pcdds_enable',
            set_cmd=self._set_pcdds_enable,
            vals=Bool(),
            docstring='Set the output of the device to use the PCDDS system '
            'and not the inbuilt functionality')

        self.add_parameter(
            'instruction_sequence',
            label=f'ch{self.id} instruction sequence of pulses',
            initial_value=[],
            docstring='The instruction sequence for all pulses sent to the DDS.'
            'Gets cleared during clear_memory()')

        self.debug_mode = Parameter(initial_value=False,
                                    set_cmd=None,
                                    docstring='Print debug messages')

        # Initially set load delay to 10 samples
        self.load_delay(10)
Exemplo n.º 21
0
 def test_valid_values(self):
     ms = [MultiType(Strings(2, 4), Ints(10, 32)),
           MultiType(Ints(), Lists(Ints())),
           MultiType(Ints(), MultiType(Lists(Ints()), Ints()))]
     for m in ms:
         for val in m.valid_values:
             m.validate(val)
Exemplo n.º 22
0
    def __init__(self, name: str, address: str,
                 attenuation: Optional[int] = None,
                 terminator="\r", **kwargs):
        super().__init__(name=name, address=address,
                         terminator=terminator, **kwargs)

        model = self.IDN()['model']
        if model in ["J7211A", "J7211B"]:
            vals = Ints(0, 120)
        elif model in ["J7211C"]:
            vals = Ints(0, 100)
        else:
            raise RuntimeError(f"Model {model} is not supported.")

        self.add_parameter('attenuation', unit='dB',
                           set_cmd='ATT {:03.0f}',
                           get_cmd='ATT?',
                           get_parser=int,
                           vals=vals,
                           initial_value=attenuation)

        self.connect_message()
Exemplo n.º 23
0
    def __init__(self, parent: 'Newport_AG_UC8_Channel', axis: int) -> None:
        assert axis in (1, 2)
        super().__init__(parent, "axis_%d" % axis)

        self.axis = axis

        self.add_parameter("step_delay",
                           label="Step delay in units of 10 us",
                           get_cmd="%dDL?" % axis,
                           set_cmd="%dDL{}" % axis,
                           get_parser=_make_get_parser("%dDL" % axis),
                           vals=Ints(0, 200000))
        self.add_parameter("step_amplitude_pos",
                           label="Step amplitude in positive direction",
                           get_cmd="%dSU+?" % axis,
                           set_cmd="%dSU+{}" % axis,
                           get_parser=_make_get_parser("%dSU+" % axis),
                           vals=Ints(1, 50))
        self.add_parameter("step_amplitude_neg",
                           label="Step amplitude in negative direction",
                           get_cmd="%dSU-?" % axis,
                           set_cmd="%dSU-{}" % axis,
                           get_parser=_make_get_parser("%dSU-" % axis),
                           vals=Ints(1, 50))
        self.add_parameter("steps",
                           label="Accumulated number of steps since last " +
                           "reset of the step counter",
                           get_cmd="%dTP" % axis,
                           get_parser=_make_get_parser("%dTP" % axis))
        self.add_parameter("status",
                           label="Status of the axis",
                           get_cmd="%dTS" % axis,
                           get_parser=_make_get_parser("%dTS" % axis),
                           val_mapping={
                               "ready": 0,
                               "stepping": 1,
                               "jogging": 2,
                               "moving_to_limit": 3
                           })
Exemplo n.º 24
0
    def test_range(self):
        n = Ints(0, 10)

        for v in self.ints:
            if 0 <= v <= 10:
                n.validate(v)
            else:
                with self.assertRaises(ValueError):
                    n.validate(v)

        for v in self.not_ints:
            with self.assertRaises(TypeError):
                n.validate(v)

        self.assertEqual(repr(n), '<Ints 0<=v<=10>')
        self.assertTrue(n.is_numeric)
Exemplo n.º 25
0
def test_range():
    n = Ints(0, 10)

    for v in ints:
        if 0 <= v <= 10:
            n.validate(v)
        else:
            with pytest.raises(ValueError):
                n.validate(v)

    for v in not_ints:
        with pytest.raises(TypeError):
            n.validate(v)

    assert repr(n) == '<Ints 0<=v<=10>'
    assert n.is_numeric
Exemplo n.º 26
0
def test_valid_values():
    # combiner == 'OR'
    ms = [
        MultiType(Strings(2, 4), Ints(10, 32)),
        MultiType(Ints(), Lists(Ints())),
        MultiType(Ints(), MultiType(Lists(Ints()), Ints()))
    ]
    for m in ms:
        for val in m.valid_values:
            m.validate(val)
Exemplo n.º 27
0
    def test_good(self):
        m = MultiType(Strings(2, 4), Ints(10, 1000))

        for v in [10, 11, 123, 1000, 'aa', 'mop', 'FRED']:
            m.validate(v)

        for v in [9, 1001, 'Q', 'Qcode', None, 100.0, b'nice', [], {},
                  a_func, AClass, AClass(), True, False]:
            with self.assertRaises(ValueError):
                m.validate(v)

        self.assertEqual(
            repr(m), '<MultiType: Strings 2<=len<=4, Ints 10<=v<=1000>')

        self.assertTrue(m.is_numeric)

        self.assertFalse(MultiType(Strings(), Enum(1, 2)).is_numeric)
Exemplo n.º 28
0
    def __init__(self, name: str, address: str, **kwargs: Any) -> None:
        """
        Initializes the DMC4133Controller class

        Args:
            name: name for the instance
            address: address of the controller burned in
        """
        super().__init__(name=name, address=address, **kwargs)

        self.add_parameter(
            "position_format_decimals",
            get_cmd=None,
            set_cmd="PF 10.{}",
            vals=Ints(0, 4),
            docstring="sets number of decimals in the format "
            "of the position",
        )

        self.add_parameter(
            "absolute_position",
            get_cmd=self._get_absolute_position,
            set_cmd=None,
            unit="quadrature counts",
            docstring="gets absolute position of the motors "
            "from the set origin",
        )

        self.add_parameter(
            "wait",
            get_cmd=None,
            set_cmd="WT {}",
            unit="ms",
            vals=Multiples(min_value=2, max_value=2147483646, divisor=2),
            docstring="controller will wait for the amount of "
            "time specified before executing the next "
            "command",
        )

        self._set_default_update_time()
        self.add_submodule("motor_a", Motor(self, "A"))
        self.add_submodule("motor_b", Motor(self, "B"))
        self.add_submodule("motor_c", Motor(self, "C"))
        self.add_submodule("plane_ab", VectorMode(self, "AB"))
        self.add_submodule("plane_bc", VectorMode(self, "BC"))
        self.add_submodule("plane_ac", VectorMode(self, "AC"))
Exemplo n.º 29
0
def test_good_or():
    # combiner == 'OR'
    m = MultiType(Strings(2, 4), Ints(10, 1000))

    for v in [10, 11, 123, 1000, 'aa', 'mop', 'FRED']:
        m.validate(v)

    for v in [
            9, 1001, 'Q', 'Qcode', None, 100.0, b'nice', [], {}, a_func,
            AClass,
            AClass(), True, False
    ]:
        with pytest.raises(ValueError):
            m.validate(v)

    assert repr(m) == '<MultiType: Strings 2<=len<=4, Ints 10<=v<=1000>'
    assert m.is_numeric
    assert not MultiType(Strings(), Enum(1, 2)).is_numeric
Exemplo n.º 30
0
    def __init__(self, parent, name, channel_letter):
        """
        Args:
            parent (Instrument): The instrument the channel is a part of
            name (str): the name of the channel
            channel_letter (str): channel letter ['a', 'b', 'c' or 'd'])
        """

        super().__init__(parent, name)
        self.channel_letter = channel_letter.upper()
        _chanlist = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
        self.channel_number = _chanlist.index(channel_letter)

        self.add_parameter('switch',
                           label='switch {}'.format(self.channel_letter),
                           set_cmd=self._set_switch,
                           get_cmd=self._get_switch,
                           vals=Ints(1, 2))