Exemplo n.º 1
0
    @message(r':?SYST:ERR\?')
    def query_system_error(self):
        return '0, "no error"'

    @message(r':?SYST:ZCH\?')
    def query_system_zerocheck(self):
        return format(type(self).zero_check, 'd')

    @message(r':?SYST:ZCH\s+(OFF|ON)')
    def write_system_zerocheck(self, value):
        type(self).zero_check = {'OFF': False, 'ON': True}[value]

    @message(r':?SENS:FUNC\?')
    def query_sense_function(self):
        return '"CURR:DC"'

    @message(r':?INIT')
    def write_init(self):
        pass

    @message(r':?READ\?')
    def query_read(self):
        return format(random.uniform(0.000001, 0.0001))

    @message(r':?FETC[H]\?')
    def query_fetch(self):
        return format(random.uniform(0.000001, 0.0001))

if __name__ == "__main__":
    run(K6517BHandler)
Exemplo n.º 2
0
"""Keithley 2700 emulator."""

import random
import time

from comet.emulator.emulator import message, run
from comet.emulator.iec60488 import IEC60488Handler
from comet.emulator.keithley.k2400 import SystemMixin, MeasureMixin

__all__ = ['K2700Handler']


class K2700Handler(IEC60488Handler, SystemMixin, MeasureMixin):
    """Generic Keithley 2700 series compliant request handler."""

    identification = "Spanish Inquisition Inc., Model 2700, 12345678, v1.0"


if __name__ == "__main__":
    run(K2700Handler)
Exemplo n.º 3
0
    def query_get_a13(self, channel):
        return fake_analog_channel(channel, -100., +200.)

    @message(r'(A\?)')
    def query_get_a14(self, channel):
        return fake_analog_channel(channel, -80., +200.)

    @message(r'a[1-7]\s(-?\d+.\d)')
    def query_set_a15(self, value):
        return 'a'

    @message(r'S')
    def query_get_s(self):
        return 'S11110100\x06'

    @message(r'P')
    def query_get_p(self):
        return 'P000'

    @message(r'(P\d{3})')
    def query_set_p(self, program):
        return program

    @message(r'a[0-6]\s+\d+\.\d+')
    def query_set_a(self):
        return 'a'


if __name__ == "__main__":
    run(ITCHandler)
Exemplo n.º 4
0
    @message(r':SYST:ERR\?')
    def query_system_error(self):
        return '0, "no error"'

    @message(r':?FETC[H]?\?')
    def query_fetch(self):
        return '{:E},{:E}'.format(random.random(), random.random())

    @message(r':CORR:METH\?')
    def query_correction_method(self):
        return type(self).correction_method

    @message(r':CORR:METH\s+SING')
    def write_correction_method_single(self):
        type(self).correction_method = 0

    @message(r':CORR:METH\s+MULT')
    def write_correction_method_multi(self):
        type(self).correction_method = 1

    @message(r':CORR:USE:CHAN\?')
    def query_correction_channel(self):
        return type(self).correction_channel

    @message(r':CORR:USE:CHAN\s+(\d+)')
    def write_correction_channel(self, value):
        type(self).correction_channel = int(value)

if __name__ == "__main__":
    run(E4980AHandler)
Exemplo n.º 5
0
    @message(r'print\(smua\.source\.output\)')
    def query_source_output(self):
        return format(float(type(self).output), 'E')

    @message(r'smua\.source\.output\s*\=\s*(\d+)')
    def write_source_outout(self, value):
        type(self).output = int(value)


class K2657AHandler(IEC60488Handler, BeeperMixin, ErrorQueueMixin,
                    MeasureMixin, SourceMixin):

    identification = "Spanish Inquisition Inc., Model 2657A, 12345678, v1.0"

    smua_sense = 0

    @message(r'print\(smua\.sense\)')
    def query_smua_sense(self):
        return format(float(type(self).smua_sense), 'E')

    @message(r'smua\.sense\s*\=\s*(\d+)')
    def write_smua_sense(self, value):
        d = {'LOCAL': 0, 'REMOTE': 1, 'CALA': 2}
        if value in d:
            value = d[value]
        type(self).smua_sense = value


if __name__ == "__main__":
    run(K2657AHandler)
Exemplo n.º 6
0
        time.sleep(random.uniform(.5, 1.0))
        vdc = random.uniform(.00025, .001)
        return format(vdc, 'E')

class K6514Handler(IEC60488Handler, SystemMixin, MeasureMixin):
    """Generic Keithley 6514 series compliant request handler."""

    identification = "Spanish Inquisition Inc., Model 6514, 12345678, v1.0"

    zero_check = False
    sense_function = 'VOLT'

    @message(r':?SYST:ZCH\s+(0|1|ON|OFF)')
    def write_zero_check(self, value):
        type(self).zero_check = {'0': False, '1': True, 'OFF': False, 'ON': True}[value]

    @message(r':?SYST:ZCH\?')
    def query_zero_check(self):
        return {False: '0', True: '1'}[type(self).zero_check]

    @message(r':?SENS:FUNC [\'\"](VOLT|CURR)(?:\:DC)?[\'\"]')
    def write_sense_function(self, value):
        type(self).sense_function = value

    @message(r':?SENS:FUNC\?')
    def query_sense_function(self):
        return f"\"{type(self).sense_function}:DC\""

if __name__ == "__main__":
    run(K6514Handler)
Exemplo n.º 7
0
        pass

    @message(r'eventlog.clear\(\)')
    @message(r'status.clear\(\)')
    @message(r'\*CLS')
    def write_cls(self):
        pass

    @message(r'waitcomplete\(\)')
    def query_waitcomplete(self):
        pass

    @message(r'print\(\[\[1\]\]\)')
    @message(r'\*OPC\?')
    def query_opc(self):
        return "1"

    @message(r'opc\(\)')
    @message(r'\*OPC')
    def write_opc(self):
        pass

    @message(r'print\(status\.standard\.event\)')
    @message(r'\*ESR\?')
    def query_esr(self):
        return format(random.randint(0, 1))


if __name__ == "__main__":
    run(TSPHandler)
Exemplo n.º 8
0
import random

from comet.emulator.emulator import message, run
from comet.emulator.corvus.venus1 import Venus1Handler


class PQCVenus1Handler(Venus1Handler):

    table_limits = (0.0, 0.0, 0.0, 1000000.0, 100000.0, 25000.0)

    getcaldone = 3

    @classmethod
    @message(r'(.*)\s+setlimit')
    def setlimit(cls, value):
        a1, b1, c1, a2, b2, c2 = map(float, value.split())
        cls.table_limits = a1, b1, c1, a2, b2, c2

    @classmethod
    @message(r'getlimit')
    def getlimit(cls):
        a1, b1, c1, a2, b2, c2 = cls.table_limits
        return cls.read_termination.join(
            (f"{a1:.6f} {b1:.6f}", f"{c1:.6f} {a2:.6f}", f"{b2:.6f} {c2:.6f}"))


if __name__ == '__main__':
    run(PQCVenus1Handler)
Exemplo n.º 9
0
"""Keithley 2410 emulator."""

from comet.emulator.emulator import message, run
from .k2400 import K2400Handler

__all__ = ['K2410Handler']


class K2410Handler(K2400Handler):
    """Generic Keithley 2400 series compliant request handler."""

    identification = "Spanish Inquisition Inc., Model 2410, 43768438, v1.0"


if __name__ == "__main__":
    run(K2410Handler)
Exemplo n.º 10
0
    format_elements = 'VOLT', 'CURR', 'FOO', 'STAT', 'TIME'

    output_state = 0

    @message(r':?SYST:ERR\?')
    def query_system_error(self):
        return '0,"no error"'

    @message(r':?OUTP\?')
    @message(r':?OUTP:STAT\?')
    def query_output(self):
        return type(self).output_state

    @message(r':?OUTP\s+(0|1|OFF|ON)')
    @message(r':?OUTP:STAT\s+(0|1|OFF|ON)')
    def write_output(self, state):
        type(self).output_state = {
            '0': 0,
            '1': 1,
            'OFF': 0,
            'ON': 1
        }.get(state, 0)

    @message(r':?FORM:ELEM\?')
    def query_format_elements(self):
        return ','.join(type(self).format_elements)


if __name__ == "__main__":
    run(K2400Handler)
Exemplo n.º 11
0
class PQCEnvironmentBoxHandler(EnvironmentBoxHandler):

    test_led = False

    map_on_off = {'OFF': False, 'ON': True}

    message_ok = "OK"

    @classmethod
    def pc_data(cls):
        pc_data = super().pc_data()
        pc_data[1] = random.uniform(55.0, 60.0)
        pc_data[2] = random.uniform(22.0, 23.0)
        pc_data[33] = random.uniform(21.5, 22.5)
        return pc_data

    @classmethod
    @message(r'GET:TEST_LED \?')
    def get_test_led(cls):
        return cls.test_led

    @classmethod
    @message(r'SET:TEST_LED (ON|OFF)')
    def set_test_led(cls, value):
        cls.test_led = cls.map_on_off.get(value, False)
        return cls.message_ok


if __name__ == '__main__':
    run(PQCEnvironmentBoxHandler)
Exemplo n.º 12
0
        return f'{cls.x_unit}'

    @message(r'2 getunit')
    def query_getunit_y(self):
        cls = type(self)
        return f'{cls.y_unit}'

    @message(r'3 getunit')
    def query_getunit_z(self):
        cls = type(self)
        return f'{cls.z_unit}'

    @message(r'(\d) 1 setunit')
    def write_setunit_x(self, value):
        cls = type(self)
        cls.x_unit = int(value)

    @message(r'(\d) 2 setunit')
    def write_setunit_y(self, value):
        cls = type(self)
        cls.y_unit = int(value)

    @message(r'(\d) 3 setunit')
    def write_setunit_z(self, value):
        cls = type(self)
        cls.z_unit = int(value)


if __name__ == "__main__":
    run(Venus1Handler)
Exemplo n.º 13
0
__all__ = ['IEC60488Handler']

class IEC60488Handler(RequestHandler):
    """Generic IEC60488 compliant instrument request handler."""

    identification = "Generic IEC60488 Instrument, Spanish Inquisition Inc."

    @message(r'\*IDN\?')
    def query_idn(self):
        return type(self).identification

    @message(r'\*CLS')
    def write_cls(self):
        pass

    @message(r'\*OPC\?')
    def query_opc(self):
        return "1"

    @message(r'\*OPC')
    def write_opc(self):
        pass

    @message(r'\*ESR\?')
    def query_esr(self):
        return format(random.randint(0, 1))

if __name__ == "__main__":
    run(IEC60488Handler)
Exemplo n.º 14
0
    @message(r':?BIAS:POL:VOLT\?')
    @message(r':?BIAS:POL:VOLT:LEV\?')
    def get_bias_polarity_voltage_level(self):
        return format(random.random() / 100., 'E')

    @message(r':?BIAS:VOLT:LEV\?')
    def get_bias_voltage_level(self):
        return format(type(self).bias_voltage_level, 'E')

    @message(r':?BIAS:VOLT:LEV\s+(.*)')
    def set_bias_voltage_level(self, value):
        type(self).bias_voltage_level = float(value)

    @message(r':?BIAS:STAT\?')
    def get_bias_state(self):
        return int(type(self).bias_state)

    @message(r':?BIAS:STAT\s+(0|1|ON|OFF)')
    def set_bias_state(self, value):
        type(self).bias_state = {
            '0': False,
            '1': True,
            'OFF': False,
            'ON': True
        }[value]


if __name__ == '__main__':
    run(PQCE4980AHandler)
Exemplo n.º 15
0
    @message(r'SET:PROBCARD_LIGHT (ON|OFF)')
    def query_set_probecard_light(self, value):
        type(self).probecard_light = value == 'ON'
        return 'OK'

    @message(r'GET:PROBCARD_CAM ?')
    def query_get_probecard_camera(self):
        return int(type(self).probecard_camera)

    @message(r'SET:PROBCARD_CAM (ON|OFF)')
    def query_set_probecard_camera(self, value):
        type(self).probecard_camera = value == 'ON'
        return 'OK'

    @message(r'GET:DISCHARGE_TIME ?')
    def query_get_discharge_time(self):
        return format(type(self).discharge_time)

    @message(r'SET:DISCHARGE AUTO')
    def query_set_discharge_auto(self):
        return 'OK'

    @message(r'SET:CTRL (ON|OFF)')
    def query_set_pid_control(self, value):
        type(self).pid_control = value == 'ON'
        return 'OK'


if __name__ == "__main__":
    run(EnvironmentBoxHandler)
Exemplo n.º 16
0
    @message(r'print\(channel\.getclose\(([^\)]+)\)\)')
    def query_channel_getclose(self, values):
        if not type(self).closed_channels:
            return 'nil'
        return ';'.join(type(self).closed_channels)

    @message(r'channel\.close\(([^\)]+)\)')
    def write_channel_close(self, values):
        channels = values.strip('"').split(',')
        type(self).closed_channels = channels

    @message(r'channel\.open\(([^\)]+)\)')
    def write_channel_open(self, values):
        channels = values.strip('"').split(',')
        if channels == ['allslots']:
            type(self).closed_channels.clear()
        else:
            for channel in channels:
                if channel in type(self).closed_channels:
                    type(self).closed_channels.remove(channel)


class K707BHandler(IEC60488Handler, ChannelMixin):

    identification = "Spanish Inquisition Inc., Model 707B, 12345678, v1.0"


if __name__ == "__main__":
    run(K707BHandler)
Exemplo n.º 17
0
from comet.emulator.emulator import message, run
from comet.emulator.iec60488 import IEC60488Handler

__all__ = ['K2470Handler']


class K2470Handler(IEC60488Handler):
    """Generic Keithley 2470 series compliant request handler."""

    identification = "Spanish Inquisition Inc., Model 2470, 12345678, v1.0"

    beeper_state = False

    @message(r'print\(beeper\)')
    def query_beeper_state(self):
        return int(type(self).beeper_state)

    @message(r'beeper\s+=\s+(0|1|false|true)')
    def write_beeper_state(self, value):
        type(self).beeper_state = {
            '0': False,
            '1': True,
            'false': False,
            'true': True
        }[value]


if __name__ == "__main__":
    run(K2470Handler)
Exemplo n.º 18
0
    @message(r'GET:RAM \?')
    def query_get_ram(self):
        return format(self.memory_bytes)

    @message(r'GET:TEMP ALL')
    def query_get_temp_all(self):
        values = []
        for i in range(self.channels):
            values.append(format(random.uniform(22.0, 26.0), '.1f'))
        return ",".join(values)

    @message(r'GET:TEMP (\d+)')
    def query_get_temp(self, value):
        return format(random.uniform(22.0, 26.0), '.1f')

    @message(r'SET:REL_(ON|OFF) (\d+|ALL)')
    def query_set_rel(self, state, value):
        return "OK"

    @message(r'GET:REL (\d+)')
    def query_get_rel(self, value):
        return "0"

    @message(r'GET:REL ALL')
    def query_get_rel_all(self):
        return ",".join(["0"] * self.channels + 4)


if __name__ == "__main__":
    run(ShuntBoxHandler)