示例#1
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)])
示例#2
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)])
示例#3
0
文件: ls340.py 项目: utopianf/slave
    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)
示例#4
0
 def __init__(self, transport, protocol, idx, length):
     super(Curve, self).__init__(transport, protocol)
     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')
示例#5
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'))
示例#6
0
    def __init__(self, transport, protocol):
        assert isinstance(protocol, VAT590Protocol)

        self._transport = transport
        self._protocol = protocol

        self.PID_controller = Command('i:02', 's:02', String)

        self.interface_config = Command(
            'i:20',
            's:20',
            BitSequence([
                (1, Mapping(BAUD_RATE)),  # Baud rate
                (1, Mapping(PARITY_BIT)),  # Parity bit
                (1, Mapping(DATA_LENGTH)),  # Data length
                (1, Mapping(STOP_BITS)),  # Number of stop bits
                (1, Mapping({'Reserved': '0'})),
                (1, Mapping(DIGITAL_INPUT)),  # Digital input OPEN valve
                (1, Mapping(DIGITAL_INPUT)),  # Digital input CLOSED valve
                (1, Mapping({'Reserved': '0'}))
            ]))

        self._device_status = Command((
            'i:30',
            BitSequence([
                (1, Mapping(OPERATION_MODE)),  # Operation mode
                (1, Mapping(STATUS)),  # Status
                (1, Mapping(POWER_FAILURE_BATTERY)),  # Power failure option
                (1, Mapping(OPERATION))  # Operation
            ])))

        self._assembly = Command(
            'i:76',
            'i:76',
            BitSequence([
                (6, String()),  # Position
                (1, Mapping(PRESSURE_READING)),  # Pressure reading
                (7, String()),  # Pressure
                (1, Mapping(OPERATION_MODE)),  # Operation mode
                (1, Mapping(STATUS)),  # Status
                (1, Mapping(WARNING))  # Warning
            ]))

        self._warnings = Command((
            'i:51',
            BitSequence([
                (1, Mapping(SERVICE)),  # Service
                (1, Mapping(LEARN_DATA)),  # Learn data set
                (1, Mapping(POWER_FAILURE_BATTERY)),  # Power failure battery
                (1, Mapping(COMPRESSED_AIR_SUPPLY))  # Compressed air supply
            ])))

        self._valve_configuration = Command(
            'i:04',
            's:04',
            BitSequence([
                (1, Mapping(CLOSE_OPEN)),  # VALVE_POWER_UP
                (1, Mapping(CLOSE_OPEN)),  # VALVE_POWER_FAILURE
                (1, Mapping(NO_YES)),  # EXTERNAL_ISOLATION_VALVE_FUNCTION
                (1, Mapping(NO_YES)),  # CONTROL_STROKE_LIMITATION
                (1, Mapping(VALVE_FAILURE_POSITION)
                 ),  # NETWORK_FAILURE_END_POSITION
                (1, Mapping(VALVE_FAILURE_POSITION)),  # SLAVE_OFFLINE_POSITION
                (1, Mapping(SYNCHRONIZATION_START)),
                (1, Mapping(SYNCHRONIZATION_MODE)),
            ]))

        self._errors = Command(('i:50',
                                Mapping({
                                    'No errors': '00000000',
                                    'Sensor 1 signal converter failure.':
                                    '01000000',
                                    'Firmware memory failure.': '00010000'
                                })))

        self._range_config = Command(
            'i:21',
            's:21',
            BitSequence([
                (1, String()),  # Position range
                (7, String()),  # Pressure range
            ]))

        self._sensor_configuration = Command(
            'i:01', 's:01',
            BitSequence([(1, String()), (1, String()), (6, String())]))

        self._sensor_reading = Command('i:64', 'i:64', String)
        self._sensor_offset = Command('i:60', 'i:60', String)
        self._speed = Command('i:68', 'V:', String)
        self._pressure = Command('P:', 'S:', String)
        self._position = Command('A:', 'R:', String)
        self._identification = Command(('i:83', String))
        self._firmware_number = Command(('i:84', String))
        self._firmware_config = Command(('i:82', String))
        self._pressure_alignment = Command('c:6002', 'c:6002', String)
        self._zero = ('Z:', String)
        self._learn = ('L:0', String)

        # write only commands
        self._hold = ('H:', String)
        self._reset = ('c:82', String)
        self._close = ('C:', String)
        self._open = ('O:', String)
        self._access_mode = ('c:01', String)