Ejemplo n.º 1
0
 def __init__(self, ppr=None, *args, **kw):
     super(ParallelPoll, self).__init__(*args, **kw)
     ppr = _construct_register(ppr, PARALLEL_POLL_REGISTER)
     # The first 8 bits represent the status byte.
     ppr.update(self._stb)
     self._ppr = ppr
     self.parallel_poll_enable = Command('*PRE?', 'PRE', Register(ppr))
     self.individual_status = Command(('*IST?', Boolean))
Ejemplo n.º 2
0
 def __init__(self, connection, cfg, idx):
     super(Range, self).__init__(connection, cfg)
     self.idx = idx = int(idx)
     if not idx in range(0, 5):
         raise ValueError('Invalid range index.'
                          ' Must be one of {0}'.format(range(0, 5)))
     self.limit = Command('RANGE? {0}'.format(idx),
                          'RANGE {0} '.format(idx), Float(fmt='{0:.4f}'))
     self.rate = Command('RATE? {0}'.format(idx), 'RATE {0}'.format(idx),
                         Float(min=1e-4, max=100., fmt='{0:.4f}'))
Ejemplo n.º 3
0
    def __init__(self, connection, esb=None, stb=None, *args, **kw):
        super(IEC60488, self).__init__(connection, *args, **kw)
        self._esb = esb = _construct_register(esb, EVENT_STATUS_BYTE)
        self._stb = stb = _construct_register(stb, STATUS_BYTE)

        self.event_status = Command(('*ESR?', Register(esb)))
        self.event_status_enable = Command('*ESE?', '*ESE', Register(esb))
        self.status = Command(('*STB?', Register(stb)))
        self.operation_complete = Command(('*OPC?', Boolean))
        self.identification = Command(
            ('*IDN?', [String, String, String, String]))
Ejemplo n.º 4
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]
         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.º 5
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)]
     cmd = Command(('CRVPT?', response_t, data_t),
                   connection=self.connection)
     # Since indices in LS304 start at 1, it must be added.
     return cmd.query((self.idx, item + 1))
Ejemplo n.º 6
0
 def __init__(self, connection, idx):
     super(Relay, self).__init__(connection)
     idx = int(idx)
     self.config = Command(
         'RELAY? {0}'.format(idx),
         'RELAY {0},'.format(idx),
         [
             Enum('off', 'on', 'alarm', 'zone'),
             Enum('scan', range(1, 17)),
             Enum('low', 'high', 'both')
         ]
     )
     self.status = Command(('RELAYST? {0}'.format(idx), Boolean))
Ejemplo n.º 7
0
 def __init__(self, connection):
     super(Heater, self).__init__(connection)
     self.manual_output = Command('MOUT?', 'MOUT', Float)
     self.output = Command(('HTR?', Float))
     self.range = Command(
         'HTRRNG?',
         'HTRRNG',
         Enum('off', '31.6 uA', '100 uA', '316 uA', '1 mA',
              '3.16 mA', '10 mA', '31.6 mA', '100 mA')
     )
     self.status = Command(
         ('HTRST?', Enum('no error', 'heater open error'))
     )
Ejemplo n.º 8
0
 def __init__(self, connection, cfg, shim):
     super(Shim, self).__init__(connection, cfg)
     if not shim in SHIMS:
         raise ValueError('Invalid shim identifier, '
                          'must be one of {0}'.format(SHIMS))
     self._shim = shim = str(shim)
     self.limit = Command('SLIM?', 'SLIM', Float(min=-30., max=30.))
     state = {
         True: '{0} Enabled'.format(shim),
         False: '{0} Disabled'.format(shim)
     }
     self.status = Command(('SHIM?', Mapping(state)))
     self.current = Command('IMAG? {0}'.format(shim),
                            'IMAG {0}'.format(shim), UnitFloat)
Ejemplo n.º 9
0
 def __init__(self, connection, channel):
     super(Output, self).__init__(connection)
     if not channel in (1, 2):
         raise ValueError('Invalid Channel number. Valid are either 1 or 2')
     self.channel = channel
     mode = 'off', 'channel', 'manual', 'zone'
     mode = mode + ('still',) if channel == 2 else mode
     self.analog = Command('ANALOG? {0}'.format(channel),
                           'ANALOG {0},'.format(channel),
                           [Enum('unipolar', 'bipolar'),
                            Enum(*mode),
                            Enum('kelvin', 'ohm', 'linear', start=1),
                            Float, Float, Float])
     self.value = Command(('AOUT? {0}'.format(channel), Float))
Ejemplo n.º 10
0
 def __init__(self, connection, channel):
     super(Output, self).__init__(connection)
     if not channel in (1, 2):
         raise ValueError('Invalid Channel number. Valid are either 1 or 2')
     self.channel = channel
     self.analog = Command('ANALOG? {0}'.format(channel),
                           'ANALOG {0},'.format(channel),
                           [Boolean,
                            Enum('off', 'input', 'manual', 'loop'),
                            #INPUT,
                            Enum('kelvin', 'celsius', 'sensor', 'linear',
                                 start=1),
                            Float, Float, Float])
     self.value = Command(('AOUT? {0}'.format(channel), Float))
Ejemplo n.º 11
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.º 12
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_, connection=self.connection)
Ejemplo n.º 13
0
 def __init__(self, connection, location):
     super(Display, self).__init__(connection)
     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.º 14
0
 def __init__(self, connection, idx, writeable, length=None):
     super(Curve, self).__init__(connection)
     self.idx = idx = int(idx)
     self.__length = length or 200
     # curves 1-20 are internal and not writeable.
     self._writeable = writeable
     self.header = Command('CRVHDR? {0}'.format(idx),
                           'CRVHDR {0},'.format(idx) if writeable else None,
                           [String(max=15),
                            String(max=10),
                            Enum('mV/K', 'V/K', 'Ohm/K',
                                 'logOhm/K', 'logOhm/logK', start=1),
                            Float(min=0.),
                            Enum('negative', 'positive', start=1)])
Ejemplo n.º 15
0
 def __init__(self):
     super(MockInstrument, self).__init__(MockConnection())
     self.string = Command('STRING?', 'STRING', String)
     self.integer = Command('INTEGER?', 'INTEGER', Integer)
     self.float = Command('FLOAT?', 'FLOAT', Float)
     self.mapping = Command('MAPPING?', 'MAPPING',
                            Mapping({
                                'elite': 1337,
                                'notelite': 1338
                            }))
     self.read_only = Command(('STRING?', String))
     self.write_only = Command(write=('STRING', String))
     self.list = Command('LIST?', 'LIST', [Integer, Integer])
Ejemplo n.º 16
0
 def __init__(self, connection, idx, length):
     super(Curve, self).__init__(connection)
     self.idx = idx = int(idx)
     self.header = Command(
         'CRVHDR? {0}'.format(idx),
         'CRVHDR {0},'.format(idx),
         [
             String(max=15),
             String(max=10),
             Enum('Ohm/K', 'logOhm/K', start=3),
             Float(min=0.),Enum('negative', 'positive', start=1)
         ]
     )
     if length > 0:
         self.__length = int(length)
     else:
         raise ValueError('length must be a positive integer > 0')
Ejemplo n.º 17
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:
            cmd = Command(write=('*PCB', Integer(min=0, max=30)),
                          connection=self.connection)
            cmd.write(primary)
        else:
            type_ = [Integer(min=0, max=30), Integer(min=0, max=30)]
            cmd = Command(write=('*PCB', type_), connection=self.connection)
            cmd.write((primary, secondary))
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:
            cmd = Command(write=('*PCB', Integer(min=0, max=30)),
                          connection=self.connection)
            cmd.write(primary)
        else:
            type_ = [Integer(min=0, max=30), Integer(min=0, max=30)]
            cmd = Command(write=('*PCB', type_),
                          connection=self.connection)
            cmd.write((primary, secondary))
Ejemplo n.º 19
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.º 20
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.º 21
0
 def __init__(self, *args, **kw):
     super(Macro, self).__init__(*args, **kw)
     self.macro_commands_enabled = Command(('*EMC?', Boolean))
Ejemplo n.º 22
0
 def ask_fn(self):
     cmd = Command(('FN?', Boolean), connection=self.connection)
     return cmd.query()
Ejemplo n.º 23
0
 def ask_fn(self):
     cmd = Command(('FN?', Boolean), connection=self.connection)
     return cmd.query()
Ejemplo n.º 24
0
 def write_fn(self):
     cmd = Command(write='FN', connection=self.connection)
     cmd.write()
Ejemplo n.º 25
0
 def __init__(self, *args, **kw):
     super(ObjectIdentification, self).__init__(*args, **kw)
     self.macro_commands_enabled = Command(('*OPT?', String))
Ejemplo n.º 26
0
    def __init__(self, connection, shims=None, channel=None):
        stb = {
            0: 'sweep mode active',
            1: 'standby mode active',
            2: 'quench condition present',
            3: 'power module failure',
            7: 'menu mode',
        }
        if not channel in (None, 1, 2):
            raise ValueError('Invalid channel. Must be either None, 1 or 2.')
        if channel:
            # if single channel mode is required, set the channel on every
            # command to avoid errors.
            cfg = {'program header prefix': 'CHAN {0};'.format(channel)}
        else:
            cfg = {}
        super(MPS4G, self).__init__(connection, stb=stb, cfg=cfg)
        if shims:
            if isinstance(shims, basestring):
                shims = [shims]
            for shim in list(shims):
                setattr(self, str(shim), Shim(connection, self._cfg, shim))

        if channel:
            # Channel is read only if channel is fixed
            self.channel = Command(('CHAN?', Set(1, 2)))
        else:
            self.channel = Command('CHAN?', 'CHAN', Set(1, 2))

        self.error = Command('ERROR?', 'ERROR', Boolean)
        self.current = Command('IMAG?', 'IMAG', UnitFloat)
        self.output_current = Command(('IOUT?', UnitFloat))
        # Custom format string to fix bug in firmware. The `;` must be appended
        self.lower_limit = Command('LLIM?', 'LLIM', UnitFloat(fmt='{0:.4f};'))
        self.mode = Command(('MODE?', String))
        self.name = Command('NAME?', 'NAME', String)
        self.switch_heater = Command('PSHTR?', 'PSHTR',
                                     Mapping({
                                         True: 'ON',
                                         False: 'OFF'
                                     }))
        for idx in range(0, 5):
            rng = Range(connection, self._cfg, idx)
            setattr(self, 'range{0}'.format(idx), rng)
        # Custom format string to fix bug in firmware. The `;` must be appended
        self.upper_limit = Command('ULIM?', 'ULIM', UnitFloat(fmt='{0:.4f};'))
        self.unit = Command('UNITS?', 'UNITS', Set('A', 'G'))
        self.voltage_limit = Command('VLIM?', 'VLIM', UnitFloat(min=0.,
                                                                max=10.))
        self.magnet_voltage = Command(('VMAG?', UnitFloat(min=-10., max=10.)))
        self.output_voltage = Command(('VMAG?', UnitFloat(min=-12.8,
                                                          max=12.8)))
        self.sweep_status = Command(('SWEEP?', String))
Ejemplo n.º 27
0
    def __init__(self, connection):
        cfg = {
             'program data separator': ',',
        }
        super(SR7225, self).__init__(connection, cfg=cfg)
        # Signal channel
        # ==============
        self.current_mode = Command('IMODE', 'IMODE',
                                    Enum('off', 'high bandwidth', 'low noise'))
        self.voltage_mode = Command(
            'VMODE',
            'VMODE',
            Enum('test', 'A', 'A-B', start=1)
        )
        self.fet = Command('FET', 'FET', Enum('bipolar', 'fet'))
        self.grounding = Command('FLOAT', 'FLOAT', Enum('ground', 'float'))
        self.coupling = Command('CP', 'CP', Enum('ac', 'dc'))
        volt_sens = Enum(
            '2 nV', '5 nV', '10 nV', '20 nV', '50 nV', '100 nV', '200 nV',
            '500 nV', '1 uV', '2 uV', '5 uV', '10 uV', '20 uV', '50 uV',
            '100 uV', '200 uV', '500 uV', '1 mV', '2 mV', '5 mV', '10 mV',
            '20 mV', '50 mV', '100 mV', '200 mV', '500 mV', '1 V',
            start=1
        )
        self._voltage_sensitivity = Command('SEN', 'SEN', volt_sens)
        highbw_sens = Enum(
            '2 fA', '5 fA', '10 fA', '20 fA', '50 fA', '100 fA', '200 fA',
            '500 fA', '1 pA', '2 pA', '5 pA', '10 pA', '20 pA', '50 pA',
            '100 pA', '200 pA', '500 pA', '1 nA', '2 nA', '5 nA', '10 nA',
            '20 nA', '50 nA', '100 nA', '200 nA', '500 nA', '1 uA',
            start=1
        )
        self._highbandwidth_sensitivity = Command('SEN', 'SEN', highbw_sens)
        lownoise_sens = Enum(
            '2 fA', '5 fA', '10 fA', '20 fA', '50 fA', '100 fA', '200 fA',
            '500 fA', '1 pA', '2 pA', '5 pA', '10 pA', '20 pA', '50 pA',
            '100 pA', '200 pA', '500 pA', '1 nA', '2 nA', '5 nA', '10 nA',
            start=7
        )
        self._lownoise_sensitivity = Command('SEN', 'SEN', lownoise_sens)
        self.ac_gain = Command('ACGAIN', 'ACGAIN',
                               Enum('0 dB', '10 dB', '20 dB', '30 dB', '40 dB',
                                    '50 dB', '60 dB', '70 db', '80 dB', '90 dB'
                                    ))
        self.auto_ac_gain = Command('AUTOMATIC', 'AUTOMATIC', Boolean)
        self.line_filter = Command('LF', 'LF',
                                   [Enum('off', 'notch', 'double', 'both'),
                                    Enum('60Hz', '50Hz')])
        self.sample_frequency = Command('SAMPLE', 'SAMPLE',
                                        Integer(min=0, max=2))

        # Reference Channel
        # =================
        self.reference = Command('IE', 'IE', Enum('internal', 'rear', 'front'))
        self.harmonic = Command('REFN', 'REFN', Integer(min=1, max=32))
        self.reference_phase = Command('REFP.', 'REFP.',
                                       Float(min=-360., max=360.))
        self.reference_frequency = Command(('FRQ.', Float))

        # Signal channel output filters
        # =============================
        self.slope = Command('SLOPE', 'SLOPE',
                             Enum('6dB', '12dB', '18dB', '24dB'))
        self.time_constant = Command('TC', 'TC', Enum(*self.TIME_CONSTANT))
        self.sync = Command('SYNC', 'SYNC', Boolean)

        # Signal Channel Output Amplifiers
        # ================================
        self.x_offset = Command('XOF', 'XOF', Boolean,
                                Integer(min=-30000, max=30000))
        self.y_offset = Command('YOF', 'YOF', Boolean,
                                Integer(min=-30000, max=30000))
        self.expand = Command('EX', 'EX',
                              Enum('off', 'x', 'y', 'both'))
        self.channel1_output = Command('CH 1', 'CH 1 ',
                                       Enum('x', 'y', 'r', 'phase1', 'phase2',
                                            'noise', 'ratio', 'log ratio'))
        self.channel2_output = Command('CH 2', 'CH 2 ',
                                       Enum('x', 'y', 'r', 'phase1', 'phase2',
                                            'noise', 'ratio', 'log ratio'))

        # Instrument Outputs
        # ==================
        self.x = Command('X.', type_=Float)
        self.y = Command('Y.', type_=Float)
        self.xy = Command('XY.', type_=[Float, Float])
        self.r = Command('MAG.', type_=Float)
        self.theta = Command('PHA.', type_=Float)
        self.r_theta = Command('MP.', type_=[Float, Float])
        self.ratio = Command('RT.', type_=Float)
        self.log_ratio = Command('LR.', type_=Float)
        self.noise = Command('NHZ.', type_=Float)
        self.noise_bandwidth = Command('ENBW.', type_=Float)
        self.noise_output = Command('NN.', type_=Float)
        self.star = Command('STAR', 'STAR',
                            Enum('x', 'y', 'r', 'theta',
                                 'adc1', 'xy', 'rtheta', 'adc12'))
        # Internal oscillator
        # ===================
        self.amplitude = Command('OA.', 'OA.', Float(min=0., max=5.))
        self.amplitude_start = Command('ASTART.', 'ASTART.',
                                       Float(min=0., max=5.))
        self.amplitude_stop = Command('ASTOP.', 'ASTOP.',
                                      Float(min=0., max=5.))
        self.amplitude_step = Command('ASTEP.', 'ASTEP.',
                                      Float(min=0., max=5.))
        self.sync_oscillator = Command('SYNCOSC', 'SYNCOSC', Boolean)
        self.frequency = Command('OF.', 'OF.', Float(min=0, max=1.2e5))
        self.frequency_start = Command('FSTART.', 'FSTART.',
                                       Float(min=0, max=1.2e5))
        self.frequency_stop = Command('FSTOP.', 'FSTOP.',
                                       Float(min=0, max=1.2e5))
        self.frequency_step = Command('FSTEP.', 'FSTEP.',
                                      [Float(min=0, max=1.2e5),
                                       Enum('log', 'linear')])
        self.sweep_rate = Command('SRATE.', 'SRATE.',
                                  Float(min=0.05, max=1000))
        # Auxiliary Outputs
        # ================
        self.dac1 = Command('DAC. 1', 'DAC. 1 ', Float(min=-12., max=12.))
        self.dac2 = Command('DAC. 2', 'DAC. 2 ', Float(min=-12., max=12.))
        self.output_port = Command('BYTE', 'BYTE', Integer(min=0, max=255))
        # Auxiliary Inputs
        # ================
        self.adc1 = Command('ADC. 1', type_=Float)
        self.adc2 = Command('ADC. 2', type_=Float)
        self.adc_trigger_mode = Command('TADC', type_=Integer(min=0, max=13))
        self.burst_time = Command('BURSTTPP', 'BURSTTPP',
                                  Integer(min=25, max=5000))
        # Output Data Curve Buffer
        # ========================
        cb = Register(dict((v, k) for k, v in self.CURVE_BUFFER.iteritems()))
        self.curve_buffer_settings = Command('CBD', 'CBD', cb)
        self.curve_buffer_length = Command('LEN', 'LEN', Integer(min=0))
        self.storage_intervall = Command('STR', 'STR', Integer(min=0, max=1e9))
        self.event_marker = Command('EVENT', 'EVENT',
                                    Integer(min=0, max=32767))
        status_byte = Register(
            dict((v, k) for k, v in self.STATUS_BYTE.iteritems())
        )
        self.measurement_status = Command(('M', [Enum('no activity',
                                                      'td running',
                                                      'tdc running',
                                                      'td halted',
                                                      'tdc halted'),
                                                 Integer,
                                                 status_byte,
                                                 Integer]))
        # Computer Interfaces
        # ===================
        rs = Register(dict((v, k) for k, v in self.RS232.iteritems()))
        self.rs232 = Command('RS', 'RS', [Enum(*self.BAUD_RATE), rs])
        self.gpib = Command('GP', 'GP',
                            [Integer(min=0, max=31),
                             Enum('CR', 'CR echo', 'CRLF', 'CRLF echo',
                                  'None', 'None echo')])
        self.delimiter = Command('DD', 'DD', Set(13, *range(31, 126)))
        self.status = Command('ST', type_=status_byte)
        overload_byte = {
            'ch1 output overload': 1,
            'ch2 output overload': 2,
            'y output overload': 3,
            'x output overload': 4,
            'input overload': 6,
            'reference unlock': 7,
        }
        self.overload_status = Command('N', type_=Register(overload_byte))
        self.status_enable = Command('MSK', 'MSK', status_byte)
        self.remote = Command('REMOTE', 'REMOTE', Boolean)
        # Instrument identification
        # =========================
        self.identification = Command('ID', type_=String)
        self.revision = Command('REV', type_=String)
        self.version = Command('VER', type_=String)
        # Frontpanel
        # ==========
        self.lights = Command('LTS', 'LTS', Boolean)
Ejemplo n.º 28
0
 def __init__(self, *args, **kw):
     super(StoredSetting, self).__init__(*args, **kw)
     self.__recall = Command(write=('*RCL', Integer(min=0)))
     self.__save = Command(write=('*SAV', Integer(min=0)))
Ejemplo n.º 29
0
 def write_fn(self):
     cmd = Command(write='FN', connection=self.connection)
     cmd.write()
Ejemplo n.º 30
0
 def __init__(self, connection, idx):
     super(Input, self).__init__(connection)
     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({
             'cs overload': 0,  # current source overload
             'vcm overload': 1,  # voltage common mode overload
             'vmix overload': 2,  # differential overload
             'vdif overload': 3,  # mixer overload
             'range over': 4,
             'range under': 5,
             'temp over': 6,
             'temp under': 7,
         })
     ))
     self.resistance = Command(('RDGR?', 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.º 31
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.º 32
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))
Ejemplo n.º 33
0
    def __init__(self, connection, scanner=None):
        super(LS370, self).__init__(connection)
        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'), 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({'DO1': 0, 'DO2': 1, 'DO3': 2, 'DO4': 3, 'DO5': 4}),
        )
        self.displays = tuple(Display(connection, 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(connection, 1), Output(connection, 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.scanner = scanner
        self.setpoint = Command('SETP?', 'SETP', Float)
        self.still = Command('STILL?', 'STILL', Float)
        self.all_curves = Curve(connection, 0, 200)
        self.user_curve = tuple(Curve(connection, 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_, connection=self.connection)

        self.zones = CommandSequence(make_zone(i) for i in xrange(1, 11))