Ejemplo n.º 1
0
    def fit(self, range, function=None):
        """Fits a function to the active display's data trace within a
        specified range of the time window.

        E.g.::

            # Fit's a gaussian to the first 30% of the time window.
            lockin.fit(range=(0, 30), function='gauss')

        :param start: The left limit of the time window in percent.
        :param stop: The right limit of the time window in percent.
        :param function: The function used to fit the data, either 'line',
            'exp', 'gauss' or None, the default. The configured fit function is
            left unchanged if function is None.

        .. note::

            Fitting takes some time. Check the status byte to see when the
            operation is done. A running scan will be paused until the
            fitting is complete.

        .. warning::

            The SR850 will generate an error if the active display trace is not
            stored when the fit command is executed.

        """
        if function is not None:
            self.fit_function = function
        cmd = 'FITT', Integer(min=0, max=100), Integer(min=0, max=100)
        self._write(cmd, start, stop)
Ejemplo n.º 2
0
    def __init__(self, transport):
        protocol = slave.protocol.IEC60488(msg_data_sep=' ',
                                           msg_term='\r',
                                           resp_data_sep=' ',
                                           resp_term='\r')
        super(SR5113, self).__init__(transport, protocol)

        self.backlight = Command('BL', 'BL', Boolean)
        self.contrast = Command('LCD', 'LCD', Integer(min=0, max=15))
        self.identification = Command(query=('ID', String))
        self.version = Command(query=('VER', String))
        self.remote = Command('REMOTE', 'REMOTE', Enum(True, False))
        self.status = Command(query=('ST', Register(SR5113.STATUS)))
        # TODO check if lines are readable. Check 40 character limit.
        self.line = CommandSequence(self._transport, self._protocol, [
            Command('LINE 1', 'LINE 1\r', String(max=40)),
            Command('LINE 2', 'LINE 2\r', String(max=40)),
        ])

        self.coarse_gain = Command('CG', 'CG', Enum(*SR5113.COARSE_GAIN))
        self.fine_gain = Command('FG', 'FG', Enum(*SR5113.FINE_GAIN))
        self.gain_vernier = Command('GV', 'GV', Integer(min=0, max=15))
        self.input_coupling = Command('CP', 'CP', Enum('ac', 'dc'))
        self.dynamic_reserve = Command('DR', 'DR',
                                       Enum('low noise', 'high reserve'))
        self.input_mode = Command('IN', 'IN', Enum('A', 'A-B'))
        self.time_constant = Command('TC', 'TC', Enum('1 s', '10 s'))
        self.filter_mode = Command('FLT', 'FLT', Enum(*SR5113.FILTER_MODE))
        self.filter_frequency = Command(
            'FF', 'FF', [Enum('low', 'high'),
                         Enum(*SR5113.FREQUENCIES)])
Ejemplo n.º 3
0
    def softcal(self, std, dest, serial, T1, U1, T2, U2, T3=None, U3=None):
        """Generates a softcal curve.

        :param std: The standard curve index used to calculate the softcal
            curve. Valid entries are 1-20
        :param dest: The user curve index where the softcal curve is stored.
            Valid entries are 21-60.
        :param serial: The serial number of the new curve. A maximum of 10
            characters is allowed.
        :param T1: The first temperature point.
        :param U1: The first sensor units point.
        :param T2: The second temperature point.
        :param U2: The second sensor units point.
        :param T3: The third temperature point. Default: `None`.
        :param U3: The third sensor units point. Default: `None`.

        """
        args = [std, dest, serial, T1, U1, T2, U2]
        dtype = [
            Integer(min=1, max=21),
            Integer(min=21, max=61),
            String(max=10), Float, Float, Float, Float
        ]
        if (T3 is not None) and (U3 is not None):
            args.extend([T3, U3])
            dtype.extend([Float, Float])
        self._write(('SCAL', dtype), *args)
Ejemplo n.º 4
0
    def __init__(self, connection, idx):
        super(Loop, self).__init__(connection)
        self.idx = idx = int(idx)
        self.filter = Command('CFILT? {0}'.format(idx),
                              'CFILT {0},'.format(idx),
                              Boolean)
        self.limit = Command('CLIMIT? {0}'.format(idx),
                             'CLIMIT {0},'.format(idx),
                             [Float, Float, Float,
                              Enum(0.25, 0.5, 1., 2., start=1),
                              Integer(min=0, max=5)])
        self.manual_output = Command('MOUT? {0}'.format(idx),
                                     'MOUT {0},'.format(idx),
                                     Float(min=-100., max=100.))
        self.mode = Command('CMODE? {0}'.format(idx), 'CMODE {0},'.format(idx),
                            Enum('manual', 'zone', 'open', 'pid', 'pi', 'p',
                                 start=1))

        self.parameters = Command('CSET? {0}'.format(idx),
                                  'CSET {0},'.format(idx),
                                  [Set('A', 'B'),
                                   Enum('kelvin', 'celsius', 'sensor',
                                        start=1),
                                   Boolean,
                                   Boolean])
        self.pid = Command('PID? {0}'.format(idx), 'PID {0},'.format(idx),
                           [Float, Float, Float])
        self.ramp = Command('RAMP? {0}'.format(idx), 'RAMP {0},'.format(idx),
                            [Boolean, Float])
        self.ramping = Command(('RAMPST? {0}'.format(idx), Boolean))
        self.setpoint = Command('SETP? {0}'.format(idx),
                                'SETP {0},'.format(idx), Float)
        for z in range(1, 11):
            type_ = [
                Float(min=0),  # top value
                Float(min=0),  # P value
                Float(min=0),  # I value
                Float(min=0),  # D value
                Float(min=0),  # manual output
                Integer(min=0, max=5),  # heater range
            ]
            cmd = Command('ZONE? {0}, {1},'.format(idx, z),
                          'ZONE {0}, {1},'.format(idx, z),
                          type_)
            setattr(self, 'zone{0}'.format(z), cmd)
        if idx == 1:
            self.tuning_status = Command(('TUNEST?', Boolean))
            self.settle = Command('SETTLE?', 'SETTLE',
                                  [Float(min=0., max=100.),
                                   Integer(min=0, max=86400)])
        cdisp = [
            Enum('none', 'loop1', 'loop2', 'both'),
            Integer(min=0, max=1000),
            Enum('current', 'power', start=1),
            Boolean,
        ]
        self.display_parameters = Command('CDISP? {0}'.format(idx),
                                          'CDISP {0},'.format(idx), cdisp)
Ejemplo n.º 5
0
 def make_zone(i):
     """Helper function to create a zone command."""
     type_ = [
         Float, Float(min=0.001, max=1000.), Integer(min=0, max=10000),
         Integer(min=0, max=10000), Integer(min=0, max=100),
         Enum(*Heater.RANGE), Boolean, Boolean,
         Integer(min=-100, max=100),Integer(min=-100, max=100)
     ]
     return Command('ZONE? {0}'.format(i), 'ZONE {0},'.format(i), type_)
Ejemplo n.º 6
0
 def __getitem__(self, item):
     if isinstance(item, slice):
         indices = item.indices(len(self))
         return [self[i] for i in range(*indices)]
     # Simple index
     item = slave.misc.index(item, len(self))
     response_t = [Float, Float]
     data_t = [Integer(min=1), Integer(min=1, max=200)]
     # Since indices in LS304 start at 1, it must be added.
     return self._query(('CRVPT?', response_t, data_t), self.idx, item + 1)
Ejemplo n.º 7
0
 def __setitem__(self, item, value):
     if isinstance(item, slice):
         indices = item.indices(min(len(self), len(value)))
         for i in range(*indices):
             self[i] = value[i]
     else:
         item = slave.misc.index(item, len(self))
         unit, temp = value
         data_t = [Integer(min=1), Integer(min=1, max=200), Float, Float]
         # Since indices in LS304 start at 1, it must be added.
         self._write(('CRVPT', data_t), self.idx, item + 1, unit, temp)
Ejemplo n.º 8
0
 def __init__(self, transport, protocol, location):
     super(Display, self).__init__(transport, protocol)
     location = int(location)
     self.config = Command(
         'DISPLOC? {0}'.format(location),
         'DISPLOC {0},'.format(location),
         [
             Integer(min=0, max=16),
             Enum('kelvin', 'ohm', 'linear', 'min', 'max', start=1),
             Integer(min=4, max=6)
         ]
     )
Ejemplo n.º 9
0
 def __setitem__(self, item, value):
     if not self._writeable:
         raise AttributeError('Curve is not writeable.')
     if isinstance(item, slice):
         indices = item.indices(min(len(self), len(value)))
         for i in range(*indices):
             self[i] = value[i]
     else:
         item = slave.misc.index(item, len(self))
         unit, temp = value
         data_t = [Integer(min=1), Integer(min=1, max=200), Float, Float]
         cmd = Command(write=('CRVPT', data_t),
                       connection=self.connection)
         # Since indices in LS304 start at 1, it must be added.
         cmd.write((self.idx, item + 1, unit, temp))
Ejemplo n.º 10
0
    def save(self, idx):
        """Stores the current settings of a device in local memory.

        :param idx: Specifies the memory slot.

        """
        self._write(('*SAV', Integer(min=0)), idx)
Ejemplo n.º 11
0
    def recall(self, idx):
        """Restores the current settings from a copy stored in local memory.

        :param idx: Specifies the memory slot.

        """
        self._write(('*RCL', Integer(min=0)), idx)
Ejemplo n.º 12
0
    def recall_setup(self, id):
        """Recalls the lock-in setup from the setup buffer.

        :param id: Represents the buffer id (0 < buffer < 10). If no
          lock-in setup is stored under this id, recalling results in
          an error in the hardware.
        """
        self._write(('RSET', Integer(min=0, max=10)), id)
Ejemplo n.º 13
0
    def beep(self, duration, frequency):
        """Generates a beep.

        :param duration: The duration in seconds, in the range 0.1 to 5.
        :param frequency: The frequency in Hz, in the range 500 to 5000.

        """
        cmd = 'BEEP', [Float(min=0.1, max=5.0), Integer(min=500, max=5000)]
        self._write(cmd, duration, frequency)
Ejemplo n.º 14
0
    def test_constructor(self):
        types = [
            Integer,
            Integer(),
            (Integer, ),
            (Integer(), ),
            (Integer, Integer),
            (Integer(), Integer()),
        ]
        type_ = [Integer()]
        result = [
            type_,
            type_,
            type_,
            type_,
            type_ + type_,
            type_ + type_,
        ]

        # All these commands should be equal.
        for type_, result in itertools.izip(types, result):
            query = _Message('QUERY?', None, result)
            write = _Message('WRITE', result, None)

            self.assertEqual(_Message('QUERY?', None, result), query)

            commands = [
                Command('QUERY?', 'WRITE', type_),
                Command(('QUERY?', type_), ('WRITE', type_)),
                Command(('QUERY?', type_), ('WRITE', type_), Float),
            ]
            for cmd in commands:
                print 'QUERY: {0}; {1}; {2}'.format(
                    query.header, cmd._query.header,
                    query.header == cmd._query.header)
                print 'QUERY: {0}; {1}; {2}'.format(
                    query.data_type, cmd._query.data_type,
                    query.data_type == cmd._query.data_type)
                print 'QUERY: {0}; {1}; {2}'.format(
                    query.response_type, cmd._query.response_type,
                    query.response_type == cmd._query.response_type)

                self.assertEqual(query, cmd._query)
                self.assertEqual(write, cmd._write)
Ejemplo n.º 15
0
    def __init__(self, transport, max_field=None):
        # The PPMS uses whitespaces to separate data and semicolon to terminate
        # a message.
        protocol = slave.protocol.IEC60488(msg_data_sep=',',
                                           msg_term=';',
                                           resp_data_sep=',',
                                           resp_term=';')
        super(PPMS, self).__init__(transport, protocol)
        self.advisory_number = Command(('ADVNUM?', Integer(min=0, max=999)))
        self.chamber = Command(
            'CHAMBER?', 'CHAMBER',
            Enum('seal', 'purge seal', 'vent seal', 'pump', 'vent'))
        self.sample_space_pressure = Command(('GETDAT? 524288', Float))
        self.move_config = Command(
            'MOVECFG?',
            'MOVECFG',
            (
                Enum('steps', 'degree', 'radian', 'mm', 'cm', 'mils', 'inch'),
                Float,  # Units per step
                Float  # The total range
            ))
        self.sample_position = Command(('GETDAT? 8', Float))
        self.magnet_config = Command('MAGCNF?', 'MAGCNF',
                                     [Float] * 5 + [Integer, Integer])
        if max_field is None:
            max_field = self.magnet_config[0]

        self.target_field = Command(
            'FIELD?', 'FIELD',
            (Float(min=-max_field, max=max_field,
                   fmt='{0:.2f}'), Float(min=10.5, max=196., fmt='{0:.1f}'),
             Enum('linear', 'no overshoot',
                  'oscillate'), Enum('persistent', 'driven')))
        # TODO Allow for the configuration of the ranges
        self.target_temperature = Command(
            'TEMP?', 'TEMP', (Float(min=1.9, max=350.), Float(
                min=0., max=20), Enum('fast', 'no overshoot')))
        self.digital_input = Command(
            ('DIGIN?', Register(STATUS_DIGITAL_INPUT)))
        cmds = [
            Command('DRVOUT? {}'.format(i), 'DRVOUT {} '.format(i),
                    [Float(min=0, max=1000.),
                     Float(min=0., max=20.)]) for i in range(1, 3)
        ]
        self.driver_output = CommandSequence(self._transport, self._protocol, [
            Command('DRVOUT? {}'.format(i), 'DRVOUT {} '.format(i),
                    [Float(min=0, max=1000.),
                     Float(min=0., max=20.)]) for i in range(1, 3)
        ])
        self.bridge = [
            BridgeChannel(self._transport, self._protocol, i)
            for i in range(1, 5)
        ]
        self.level = Command(
            ('LEVEL?', [Float, Enum('>1h', '<1h', 'continuous')]))
        self.revision = Command(('REV?', [String, String]))
Ejemplo n.º 16
0
 def __init__(self, transport, protocol, channels):
     super(Input, self).__init__(transport, protocol)
     # The ls370 channels start at 1
     self._channels = tuple(
         InputChannel(transport, protocol, idx) for idx in range(1, channels + 1)
     )
     self.scan = Command(
         'SCAN?',
         'SCAN',
         (Integer(min=0, max=len(self)), Boolean)
     )
Ejemplo n.º 17
0
    def move(self, position, slowdown=0):
        """Move to the specified sample position.

        :param position: The target position.
        :param slowdown: The slowdown code, an integer in the range 0 to 14,
            used to scale the stepper motor speed. 0, the default, is the
            fastest rate and 14 the slowest.

        """
        cmd = 'MOVE', [Float, Integer, Integer(min=0, max=14)]
        self._write(cmd, position, 0, slowdown)
Ejemplo n.º 18
0
    def pass_control_back(self, primary, secondary):
        """The address to which the controll is to be passed back.

        Tells a potential controller device the address to which the control is
        to be passed back.

        :param primary: An integer in the range 0 to 30 representing the
            primary address of the controller sending the command.
        :param secondary: An integer in the range of 0 to 30 representing the
            secondary address of the controller sending the command. If it is
            missing, it indicates that the controller sending this command does
            not have extended addressing.

        """
        if secondary is None:
            self._write(('*PCB', Integer(min=0, max=30)), primary)
        else:
            self._write(
                ('*PCB', [Integer(min=0, max=30),
                          Integer(min=0, max=30)]), primary, secondary)
Ejemplo n.º 19
0
 def __init__(self, transport, protocol):
     super(GPIB, self).__init__(transport, protocol)
     self.address = Command(
         'SYST:COMM:GPIB:ADDR?',
         'SYST:COMM:GPIB:ADDR',
         Integer(min=0, max=30)
     )
     self.external = Command(
         'SYST:COMM:GPIB:ADDR:EXT?',
         'SYST:COMM:GPIB:ADDR:EXT',
         Boolean
     )
Ejemplo n.º 20
0
 def __init__(self, transport):
     super(K2182, self).__init__(transport)
     self.initiate = Initiate(self._transport, self._protocol)
     self.output = Output(self._transport, self._protocol)
     self.sample_count = Command(':SAMP:COUN?', ':SAMP:COUN',
                                 Integer(min=1, max=1024))
     self.sense = Sense(self._transport, self._protocol)
     self.system = System(self._transport, self._protocol)
     self.temperature = Command((':MEAS:TEMP?', Float))
     self.trace = Trace(self._transport, self._protocol)
     self.triggering = Trigger(self._transport, self._protocol)
     self.unit = Unit(self._transport, self._protocol)
     self.voltage = Command((':MEAS:VOLT?', Float))
Ejemplo n.º 21
0
 def __init__(self, transport, protocol):
     super(Trace, self).__init__(transport, protocol)
     self.points = Command(':TRAC:POIN?', ':TRAC:POIN',
                           Integer(min=2, max=1024))
     self.feed = Command(
         ':TRAC:FEED?', ':TRAC:FEED',
         Mapping({
             'sense': 'SENS',
             'calculate': 'CALC',
             None: 'NONE'
         }))
     self.feed_control = Command(':TRAC:FEED:CONT?', ':TRAC:FEED:CONT?',
                                 Mapping({
                                     'next': 'NEXT',
                                     'never': 'NEV'
                                 }))
Ejemplo n.º 22
0
 def __init__(self, transport, protocol, idx):
     super(Display, self).__init__(transport, protocol)
     idx = int(idx)
     self.type = Command('DTYP? {0}'.format(idx), 'DTYP {0},'.format(idx),
                         Enum('polar', 'blank', 'bar', 'chart'))
     self.trace = Command('DTRC? {0}'.format(idx), 'DTRC {0},'.format(idx),
                          Integer(min=1, max=4))
     self.range = Command('DSCL? {0}'.format(idx), 'DSCL {0},'.format(idx),
                          Float(min=1e-18, max=1e18))
     self.offset = Command('DOFF? {0}'.format(idx), 'DOFF {0},'.format(idx),
                           Float(min=1e-12, max=1e12))
     self.horizontal_scale = Command(
         'DHZS? {0}'.format(idx), 'DHZS {0},'.format(idx),
         Enum('2 ms', '5 ms', '10 ms', '20 ms', '50 ms', '0.1 s', '0.2 s',
              '0.5 s', '1 s', '2 s', '5 s', '10 s', '20 s', '50 s', '1 min',
              '100 s', '2 min', '200 s', '5 min', '500 s', '10 min', '1 ks',
              '20 min', '2 ks', '1 h', '10 ks', '3 h', '20 ks', '50 ks',
              '100 ks', '200 ks'))
     self.bin = Command(('RBIN ? {0}'.format(idx), Integer))
     self.cursor = Command(('CURS? {0}'.format(idx), (Float, Float)))
Ejemplo n.º 23
0
 def __init__(self, transport, protocol, idx):
     super(Input, self).__init__(transport, protocol)
     self.idx = idx = int(idx)
     self.average = Command(
         'MEAS:AVER? {0}'.format(idx),
         'MEAS:AVER {0},'.format(idx),
         Integer(min=1, max=250)
     )
     self.polarity = Command(
         'MEAS:POL? {0}'.format(idx),
         'MEAS:POL {0},'.format(idx),
         Enum('unipolar', 'bipolar', start=1)
     )
     # Due to a bug in the isc4807 firmware, a query returns 10.0001 instead
     # of 10. This leads to problems when a Set type is used as query and
     # write type.
     self.range = Command(
         ('MEAS:RANG? {0}'.format(idx), Integer),
         ('MEAS:RANG {0},'.format(idx), Set(5, 10))
     )
     self.voltage = Command(('MEAS:VOLT? {0}'.format(idx), Float))
Ejemplo n.º 24
0
    def __init__(self, connection, name):
        super(Input, self).__init__(connection)
        self.name = name = str(name)
        # The reading status register, used in linear_status, reading_status
        # and minmax_status.
        rds = Register(dict((v, k) for k, v in self.READING_STATUS.items()))

        self.alarm = Command('ALARM? {0}'.format(name),
                             'ALARM {0},'.format(name),
                             [Boolean,
                              Enum('kelvin', 'celsius', 'sensor', 'linear'),
                              Float, Float, Boolean, Boolean])
        self.alarm_status = Command(('ALARMST?', [Boolean, Boolean]))
        self.celsius = Command(('CRDG? {0}'.format(name), Float))
        self.filter = Command('FILTER? {0}'.format(name),
                              'FILTER {0},'.format(name),
                              [Boolean, Integer(min=0),
                               Integer(min=0, max=100)])
        self.set = Command('INSET? {0}'.format(name),
                           'INSET {0},'.format(name),
                           [Boolean, Enum('off', 'on', 'pause')])
        self.curve = Command('INCRV? {0}'.format(name),
                             'INCRV {0},'.format(name),
                             Integer(min=0, max=60))
        self.input_type = Command('INTYPE? {0}'.format(name),
                                  'INTYPE {0},'.format(name),
                                  [Enum('special', 'Si', 'GaAlAs',
                                        'Pt100 250 Ohm', 'Pt100 500 Ohm',
                                        'Pt1000', 'RhFe', 'Carbon-Glass',
                                        'Cernox', 'RuOx', 'Ge', 'Capacitor',
                                        'Thermocouple'),
                                   Enum('special', 'volt', 'ohm'),
                                   Enum('special', '-', '+'),
                                   # XXX Volt and Ampere?
                                   Enum('off', '30nA', '100nA', '300nA', '1uA',
                                        '3uA', '10uA', '30uA', '100uA',
                                        '300uA', '1mA', '10mV', '1mV'),
                                   Enum('1mV', '2.5mV', '5mV', '10mV', '25mV',
                                        '50mV', '100mV', '250mV', '500mV',
                                        '1V', '2.5V', '5V', '7.5V', start=1)])
        self.kelvin = Command(('KRDG? {0}'.format(name), Float))
        self.sensor_units = Command(('SRDG? {0}'.format(name), Float))
        self.linear = Command(('LDAT? {0}'.format(name), Float))
        leq = [
            Enum('slope-intercept', 'point-slope'),
            Float,  # m value
            Enum('kelvin', 'celsius', 'sensor units', start=1),
            Enum('value', '+sp1', '-sp1', '+sp2', '-sp2', start=1),
            Float,  # b value
        ]
        self.linear_equation = Command('LINEAR? {0}'.format(name),
                                       'LINEAR {0},'.format(name), leq)
        self.linear_status = Command(('LDATST? {0}'.format(name), rds))
        self.reading_status = Command(('RDGST? {0}'.format(name), rds))
        self.minmax = Command(('MDAT? {0}'.format(name), [Float, Float]))
        self.minmax_parameter = Command('MNMX? {0}'.format(name),
                                        'MNMX {0},'.format(name),
                                        [Enum('on', 'pause'),
                                         Enum('kelvin', 'celsius',
                                              'sensor units', 'linear')])
        self.minmax_status = Command(('MDATST? {0}'.format(name), rds, rds))
Ejemplo n.º 25
0
    def __init__(self, transport, scanner=None):
        super(LS370, self).__init__(transport)
        self.baud = Command('BAUD?', 'BAUD', Enum(300, 1200, 9600))
        self.beeper = Command('BEEP?', 'BEEP', Boolean)
        self.brightness = Command('BRIGT?', 'BRIGT', Enum(25, 50, 75, 100))
        self.common_mode_reduction = Command('CMR?', 'CMR', Boolean)
        self.control_mode = Command(
            'CMODE?',
            'CMODE',
            Enum('closed', 'zone', 'open', 'off', start=1)
        )
        self.control_params = Command(
            'CSET?',
            'CSET',
            [Integer(min=0, max=16), Enum('unfiltered', 'filtered'),
             Enum('kelvin', 'ohm', start=1), Integer(min=0, max=255),
             Enum('current', 'power', start=1), Enum(*Heater.RANGE),
             Float(min=1., max=100000.)]
        )
        # TODO disable if 3716 scanner option is used.
        self.digital_output = Command(
            'DOUT?',
            'DOUT',
            Register({
                0: 'DO1',
                1: 'DO2',
                2: 'DO3',
                3: 'DO4',
                4: 'DO5'
            }),
        )
        self.displays = tuple(
            Display(transport, self._protocol, i) for i in range(1, 9)
        )
        self.display_locations = Command(
            'DISPLAY?',
            'DISPLAY',
            Integer(min=1, max=8)
        )
        self.frequency = Command(
            'FREQ?',
            'FREQ',
            Enum('9.8 Hz', '13.7 Hz', '16.2 Hz', start=1)
        )
        self.guard = Command('GUARD?', 'GUARD', Boolean)
        self.ieee = Command('IEEE?', 'IEEE',
                            [Enum('\r\n', '\n\r', '\n', None),
                             Boolean,
                             Integer(min=0, max=30)])
        # TODO only active if model scanner 3716 is installed.
        self.input_change = Command('CHGALL?', 'CHGALL', Enum('one', 'all'))
        self.mode = Command('MODE?', 'MODE',
                            Enum('local', 'remote', 'lockout', start=1))
        self.monitor = Command(
            'MONITOR?',
            'MONITOR',
            Enum('off', 'cs neg', 'cs pos', 'vad',
                 'vcm neg', 'vcm pos', 'vdif', 'vmix')
        )
        self.output = (
            Output(transport, self._protocol, 1),
            Output(transport, self._protocol, 2)
        )
        self.pid = Command(
            'PID?',
            'PID',
            [Float(min=1e-3, max=1e3), Float(min=0., max=1e4),
             Float(min=0, max=2.5e3)]
        )
        self.polarity = Command('CPOL?', 'CPOL', Enum('unipolar', 'bipolar'))
        self.ramp = Command(
            'RAMP?',
            'RAMP',
            [Boolean, Float(min=1e-3, max=10.)]
        )
        self.ramping = Command(('RAMPST?', Boolean))
        self.low_relay = Relay(transport, self._protocol, 1)
        self.high_relay = Relay(transport, self._protocol, 2)
        self.scanner = scanner
        self.setpoint = Command('SETP?', 'SETP', Float)
        self.still = Command('STILL?', 'STILL', Float)
        self.all_curves = Curve(transport, self._protocol, 0, 200)
        self.user_curve = tuple(
            Curve(transport, self._protocol, i, 200) for i in range(1, 21)
        )

        def make_zone(i):
            """Helper function to create a zone command."""
            type_ = [
                Float, Float(min=0.001, max=1000.), Integer(min=0, max=10000),
                Integer(min=0, max=10000), Integer(min=0, max=100),
                Enum(*Heater.RANGE), Boolean, Boolean,
                Integer(min=-100, max=100),Integer(min=-100, max=100)
            ]
            return Command('ZONE? {0}'.format(i), 'ZONE {0},'.format(i), type_)
        self.zones = CommandSequence(
            self._transport,
            self._protocol,
            (make_zone(i) for i in range(1, 11))
        )
Ejemplo n.º 26
0
 def __init__(self, transport, protocol, idx):
     super(InputChannel, self).__init__(transport, protocol)
     self.index = idx = int(idx)
     self.alarm = Command(
         'ALARM ? {0}'.format(idx),
         'ALARM {0},'.format(idx),
         [Boolean, Enum('kelvin', 'ohm', 'linear'),
          Float, Float, Float, Boolean]
     )
     self.alarm_status = Command(
         ('ALARMST? {0}'.format(idx), [Boolean, Boolean])
     )
     self.autoscan = Command(
         'SCAN? {0}'.format(idx),
         'SCAN {0},'.format(idx),
         Boolean
     )
     self.config = Command(
         'INSET? {0}'.format(idx),
         'INSET {0},'.format(idx),
         [
             Boolean, Integer(min=1, max=200),
             Integer(min=3, max=200),
             Enum('no curve', *range(20)),
             Enum('negative', 'positive', start=1)
         ]
     )
     self.excitation_power = Command(('RDGPWR? {0}'.format(idx), Float))
     self.filter = Command(
         'FILTER? {0}'.format(idx),
         'FILTER {0},'.format(idx),
         [Boolean, Integer(min=1, max=200), Integer(min=1, max=80)]
     )
     self.kelvin = Command(('RDGK? {0}'.format(idx), Float))
     self.linear = Command(('LDAT? {0}'.format(idx), Float))
     self.linear_equation = Command(
         'LINEAR? {0}'.format(idx),
         'LINEAR {0},'.format(idx),
         [
             Enum('slope-intercept', 'point-slope'),
             Float,  # m value
             Enum('kelvin', 'celsius', 'sensor units', start=1),
             Enum('value', '+sp1', '-sp1', '+sp2', '-sp2', start=1),
             Float,  # b value
         ]
     )
     self.minmax = Command(('MDAT? {0}'.format(idx), [Float, Float]))
     self.minmax_parameter = Command(
         'MNMX? {0}'.format(idx),
         'MNMX {0},'.format(idx),
         Enum('kelvin', 'ohm', 'linear'),
     )
     self.reading_status = Command((
         'RDGST? {0}'.format(idx),
         Register({
             0: 'cs overload',  # current source overload
             1: 'vcm overload',  # voltage common mode overload
             2: 'vmix overload',  # differential overload
             3: 'vdif overload',  # mixer overload
             4: 'range over',
             5: 'range under',
             6: 'temp over',
             7: 'temp under',
         })
     ))
     self.resistance = Command(('RDGR? {}'.format(idx), Float))
     self.resistance_range = Command(
         'RDGRNG? {0}'.format(idx),
         'RDGRNG {0},'.format(idx),
         [
             Enum('voltage', 'current'),
             Integer(min=1, max=22),
             Integer(min=1, max=22),
             Boolean,
             Boolean
         ]
     )
Ejemplo n.º 27
0
 def setUp(self):
     self._to_low = -11
     self._to_big = 11
     self._values = range(-10, 10)
     self._serialized = map(str, self._values)
     self._type = Integer(min=-10, max=10)
Ejemplo n.º 28
0
 def __init__(self, connection):
     super(Heater, self).__init__(connection)
     self.output = Command(('HTR?', Float))
     self.range = Command('RANGE?', 'RANGE', Integer(min=0, max=5))
     self.status = Command(('HTRST?', Enum(*self.ERROR_STATUS)))
Ejemplo n.º 29
0
    def __init__(self, transport):
        stb = {
            0: 'SCN',
            1: 'IFC',
            2: 'ERR',
            3: 'LIA',
            4: 'MAV',
            5: 'ESB',
            6: 'SRQ',
            7: '7'
        }
        esb = {
            0: 'INP',
            1: '1',
            2: 'QRY',
            3: '3',
            4: 'EXE',
            5: 'CMD',
            6: 'URQ',
            7: 'PON',
        }
        err = {
            0: 'print/plot error',
            1: 'backup error',
            2: 'ram error',
            3: 'disk error',
            4: 'rom error',
            5: 'gpib error',
            6: 'dsp error',
        }
        super(SR850, self).__init__(transport, stb=stb, esb=esb)
        # Status Reporting Commands
        self.lia_status = Command(('LIAS?', Register(self.LIA_BYTE)))
        self.lia_status_enable = Command('LIAE?', 'LIAE',
                                         Register(self.LIA_BYTE))
        # Reference and Phase Commands
        self.phase = Command('PHAS?', 'PHAS', Float(min=-360., max=719.999))
        self.reference_mode = Command('FMOD?', 'FMOD',
                                      Enum('internal', 'sweep', 'external'))
        self.frequency = Command('FREQ?', 'FREQ', Float(min=0.001, max=102000))
        self.frequency_sweep = Command('SWPT?', 'SWPT', Enum('linear', 'log'))
        self.start_frequency = Command('SLLM?', 'SLLM',
                                       Float(min=0.001, max=102000))
        self.stop_frequency = Command('SULM?', 'SULM',
                                      Float(min=0.001, max=102000))
        self.reference_slope = Command('RSLP?', 'RSLP',
                                       Enum('sine', 'rising', 'falling'))
        self.harmonic = Command('HARM?', 'HARM', Integer(min=1, max=32767))
        self.amplitude = Command('SLVL?', 'SLVL', Float(min=0.002, max=5.0))
        # Input and Filter Commands
        self.input = Command('ISRC?', 'ISRC', Enum('A', 'A-B', 'I'))
        self.input_gain = Command('IGAN?', 'IGAN', Enum('1 MOhm', '100 MOhm'))
        self.ground = Command('IGND?', 'IGND', Enum('float', 'ground'))
        self.coupling = Command('ICPL?', 'ICPL', Enum('AC', 'DC'))
        self.filter = Command('ILIN?', 'ILIN',
                              Enum('unfiltered', 'notch', '2xnotch', 'both'))
        # Gain and Timeconstant Commands
        self.sensitivity = Command(
            'SENS?', 'SENS',
            Enum(2e-9, 5e-9, 10e-9, 20e-9, 50e-9, 100e-9, 200e-9, 500e-9, 1e-6,
                 2e-6, 5e-6, 10e-6, 20e-6, 50e-6, 100e-6, 200e-6, 500e-6, 1e-3,
                 2e-3, 5e-3, 10e-3, 20e-3, 50e-3, 100e-3, 200e-3, 500e-3, 1))
        self.reserve_mode = Command('RMOD?', 'RMOD',
                                    Enum('max', 'manual', 'min'))
        self.reserve = Command('RSRV?', 'RSRV', Integer(min=0, max=5))
        self.time_constant = Command(
            'OFLT?', 'OFLT',
            Enum(10e-6, 30e-6, 100e-6, 300e-6, 1e-3, 3e-3, 10e-3, 30e-3,
                 100e-3, 300e-3, 1., 3., 10, 30, 100, 300, 1e3, 3e3, 10e3,
                 30e3))
        self.filter_slope = Command('OFSL?', 'OFSL', Enum(6, 12, 18, 24))
        self.syncronous_filtering = Command('SYNC?', 'SYNC', Boolean)
        # Output and Offset Commands
        self.ch1_display = Command(
            'FOUT? 1', 'FOUT 1,',
            Enum('x', 'r', 'theta', 'trace1', 'trace2', 'trace3', 'trace4'))
        self.ch2_display = Command(
            'FOUT? 2', 'FOUT 2,',
            Enum('y', 'r', 'theta', 'trace1', 'trace2', 'trace3', 'trace4'))
        self.x_offset_and_expand = Command(
            'OEXP? 1', 'OEXP 1,',
            (Float(min=-105., max=105.), Integer(min=1, max=256)))
        self.y_offset_and_expand = Command(
            'OEXP? 2', 'OEXP 2,',
            (Float(min=-105., max=105.), Integer(min=1, max=256)))
        self.r_offset_and_expand = Command(
            'OEXP? 3', 'OEXP 3,',
            (Float(min=-105., max=105.), Integer(min=1, max=256)))
        # Trace and Scan Commands
        self.traces = [
            Trace(transport, self._protocol, i) for i in range(1, 5)
        ]
        self.scan_sample_rate = Command(
            'SRAT?', 'SRAT',
            Enum(62.5e-3, 125e-3, 250e-3, 500e-3, 1, 2, 4, 8, 16, 32, 64, 128,
                 256, 512, 'trigger'))
        self.scan_length = Command('SLEN?', 'SLEN', Float(min=1))
        self.scan_mode = Command('SEND?', 'SEND', Enum('shot', 'loop'))
        # Display and Scale Commands
        # XXX Not shure about the difference between ADSP and ATRC command.
        self.active_display = Command('ADSP?', 'ADSP',
                                      Enum('full', 'top', 'bottom'))
        self.selected_display = Command('ATRC?', 'ATRC', Enum('top', 'bottom'))
        self.screen_format = Command('SMOD?', 'SMOD', Enum('single', 'dual'))
        self.monitor_display = Command('MNTR?', 'MNTR',
                                       Enum('settings', 'input/output'))
        self.full_display = Display(transport, self._protocol, 0)
        self.top_display = Display(transport, self._protocol, 1)
        self.bottom_display = Display(transport, self._protocol, 2)
        # Cursor Commands
        self.cursor = Cursor(transport, self._protocol)
        # Mark Commands
        self.marks = MarkList(transport, self._protocol)

        # Aux Input and Output Comnmands
        def aux_in(i):
            """Helper function to create an aux input command."""
            return Command(query=('OAUX? {0}'.format(i), Float))

        self.aux_input = CommandSequence(self._transport, self._protocol,
                                         (aux_in(i) for i in range(1, 5)))
        self.aux_output = tuple(
            Output(transport, self._protocol, i) for i in range(1, 5))
        self.start_on_trigger = Command('TSTR?', 'TSTR', Boolean)
        # Math Commands
        self.math_argument_type = Command('CAGT?', 'CAGT',
                                          Enum('trace', 'constant'))
        self.math_operation = Command(
            'COPR?', 'COPR',
            Enum('+', '-', '*', '/', 'sin', 'cos', 'tan', 'sqrt', '^2', 'log',
                 '10^x'))
        self.math_constant = Command('CARG?', 'CARG', Float)
        self.math_trace_argument = Command('CTRC?', 'CTRC',
                                           Integer(min=1, max=4))
        self.fit_function = Command('FTYP?', 'FTYP',
                                    Enum('line', 'exp', 'gauss'))
        self.fit_params = FitParameters(transport, self._protocol)
        self.statistics = Statistics(transport, self._protocol)
        # Store and Recall File Commands
        # TODO The filename syntax is not validated yet.
        self.filename = Command('FNAM?', 'FNAM', String(max=12))

        # Setup Commands
        self.interface = Command('OUTX?', 'OUTX', Enum('rs232', 'gpib'))
        self.overwrite_remote = Command('OVRM?', 'OVRM', Boolean)
        self.key_click = Command('KCLK?', 'KCLK', Boolean)
        self.alarm = Command('ALRM?', 'ALRM', Boolean)
        # TODO wrapp datetime commands with higher level interface.
        self.hours = Command('THRS?', 'THRS', Integer(min=0, max=23))
        self.minutes = Command('TMIN?', 'TMIN', Integer(min=0, max=59))
        self.seconds = Command('TSEC?', 'TSEC', Integer(min=0, max=59))
        self.month = Command('DMTH?', 'DMTH', Integer(min=1, max=12))
        self.day = Command('DDAY?', 'DDAY', Integer(min=1, max=31))
        self.year = Command('DYRS?', 'DYRS', Integer(min=0, max=99))
        self.plotter_mode = Command('PLTM?', 'PLTM', Enum('rs232', 'gpib'))
        self.plotter_baud_rate = Command('PLTB?', 'PLTB',
                                         Enum(300, 1200, 2400, 4800, 9600))
        self.plotter_address = Command('PLTA?', 'PLTA', Integer(min=0, max=30))
        self.plotting_speed = Command('PLTS?', 'PLTS', Enum('fast', 'slow'))
        self.trace_pen_number = Command('PNTR?', 'PNTR', Integer(min=1, max=6))
        self.grid_pen_number = Command('PNGD?', 'PNGD', Integer(min=1, max=6))
        self.alphanumeric_pen_number = Command('PNAL?', 'PNAL',
                                               Integer(min=1, max=6))
        self.cursor_pen_number = Command('PNCR?', 'PNCR', Integer(min=1,
                                                                  max=6))
        self.printer = Command('PRNT?', 'PRNT', Enum('epson', 'hp', 'file'))
        # Front Panel Controls and Auto Functions.
        # TODO ATRC.

        # Data Transfer Commands
        self.x = Command(('OUTP? 1', Float))
        self.y = Command(('OUTP? 2', Float))
        self.r = Command(('OUTP? 3', Float))
        self.theta = Command(('OUTP? 4', Float))
        self.fast_mode = Command('FAST?', 'FAST', Enum('off', 'dos',
                                                       'windows'))
        # Interface Commands
        self.access = Command('LOCL?', 'LOCL',
                              Enum('local', 'remote', 'lockout'))
Ejemplo n.º 30
0
 def __init__(self, connection, scanner=None):
     super(LS340, self).__init__(connection)
     self.scanner = _get_scanner(connection, scanner) if scanner else None
     self.a = Input(connection, 'A')
     self.b = Input(connection, 'B')
     self.output1 = Output(connection, 1)
     self.output2 = Output(connection, 2)
     # Control Commands
     # ================
     self.loop1 = Loop(connection, 1)
     self.loop2 = Loop(connection, 2)
     self.heater = Heater(connection)
     # System Commands
     # ===============
     self.beeper = Command('BEEP?', 'BEEP', Boolean)
     self.beeping = Command(('BEEPST?', Integer))
     self.busy = Command(('BUSY?', Boolean))
     self.com = Command('COMM?', 'COMM',
                         [Enum('CRLF', 'LFCR', 'CR', 'LF', start=1),
                          Enum(300, 1200, 2400, 4800, 9600, 19200, start=1),
                          Set(1, 2, 3)])
     self.datetime = Command('DATETIME?', 'DATETIME',
                             [Integer(min=1, max=12),
                              Integer(min=1, max=31),
                              Integer,
                              Integer(min=0, max=23),
                              Integer(min=0, max=59),
                              Integer(min=0, max=59),
                              Integer(min=0, max=999)])
     dispfld = [
         String,
         Enum('kelvin', 'celsius', 'sensor units', 'linear', 'min', 'max'),
     ]
     for i in range(1, 9):
         cmd = Command('DISPFLD? {0}'.format(i),
                       'DISPFLD {0},'.format(i),
                       dispfld)
         setattr(self, 'display_field{0}'.format(i), cmd)
     self.mode = Command('MODE?', 'MODE',
                         Enum('local', 'remote', 'lockout', start=1))
     self.key_status = Command(('KEYST?',
                                Enum('no key pressed', 'key pressed')))
     self.high_relay = Command('RELAY? 1', 'RELAY 1',
                               [Enum('off', 'alarms', 'manual'),
                                Boolean])
     self.low_relay = Command('RELAY? 2', 'RELAY 2',
                               [Enum('off', 'alarms', 'manual'),
                                Boolean])
     self.high_relay_status = Command(('RELAYST? 1', Enum('off', 'on')))
     self.low_relay_status = Command(('RELAYST? 2', Enum('off', 'on')))
     self.revision = Command(('REV?', [Integer for _ in range(9)]))
     self.lock = Command('LOCK?', 'LOCK',
                         [Boolean, Integer(min=0, max=999)])
     self.ieee = Command('IEEE?', 'IEEE',
                         [Enum(None, '\r\n', '\n\r', '\r', '\n'),
                          Boolean,
                          Integer(min=0, max=30)])
     dout = [
         Enum('off', 'alarms', 'scanner', 'manual'),
         Register({'DO1': 0, 'DO2': 1, 'DO3': 2, 'DO4': 3, 'DO5': 4})
     ]
     self.digital_output_param = Command('DOUT?', 'DOUT',
                                         dout)
     diost = [
         Register({'DI1': 0, 'DI2': 1, 'DI3': 2, 'DI4': 3, 'DI5': 4}),
         Register({'DO1': 0, 'DO2': 1, 'DO3': 2, 'DO4': 3, 'DO5': 4}),
     ]
     self.digital_io_status = Command(('DIOST?', diost))
     xscan = [
         Enum('off', 'manual', 'autoscan', 'slave'),
         Integer(min=1, max=16),
         Integer(min=0, max=999)
     ]
     self.scanner_parameters = Command('XSCAN?', 'XSCAN', xscan)
     # Curve Commands
     # ==============
     self.std_curve = tuple(
         Curve(connection, i, writeable=False) for i in range(1, 21)
     )
     self.user_curve = tuple(
         Curve(connection, i, writeable=True) for i in range(21, 61)
     )
     # Data Logging Commands
     # =====================
     self.logging = Command('LOG?', 'LOG', Boolean)
     logset_query_t = [
         Enum('invalid', 'readings', 'seconds', start=0),
         Integer(min=0, max=3600),
         Boolean,
         Enum('clear', 'continue')
     ]
     logset_write_t = [
         Enum('readings', 'seconds', start=1),
         Integer(min=1, max=3600),
         Boolean,
         Enum('clear', 'continue')
     ]
     self.logging_params = Command(('LOGSET?', logset_query_t),
                                   ('LOGSET', logset_write_t))
     self.program_status = Command(('PGMRUN?',
                                    [Integer, Enum(*self.PROGRAM_STATUS)]))
     self.programs = tuple(Program(connection, i) for i in range(1, 11))
     for i in range(1, 5):
         setattr(self, 'column{0}'.format(i), Column(connection, i))