def __init__(self, device, parent=None): super(VirtualDaq, self).__init__(parent) self.digitalIO = drv.Subsystem() self.digitalIO.setProtocol(drv.ObjectWrapperProtocol(VirtualDaq.Dio())) self.digitalIO.state = Cmd("state") self.voltage = drv.Subsystem() self.voltage.setProtocol(drv.ObjectWrapperProtocol(VirtualDaq.Aio())) self.voltage.ai = Cmd("ai") self.voltage.ao = Cmd("ao")
def __init__(self, socket, parent=None): super(Series982, self).__init__(parent) self.setProtocol(XonXoffProtocol(socket)) self.temperature1 = Cmd("C1", access=Access.RO) self.temperature2 = Cmd("C2", access=Access.RO) self.setpoint = Cmd("SP1", minimum=-250, maximum=9999) # assume deg C self.power = Cmd("PWR", access=Access.RO, minimum=0, maximum=100) self.operation = drv.Subsystem(self) self.operation.pid = drv.Subsystem(self.operation) self.operation.pid.proportional = Cmd("PB1") self.operation.pid.integral = Cmd("IT1", minimum=0.00, maximum=99.99) self.operation.pid.derivative = Cmd("DE1", minimum=0.00, maximum=9.99)
def __init__(self): super(VirtualAmtronInstrument, self).__init__() self.laser = drv.Subsystem(self) self.laser.command = drv.Subsystem(self.laser) self.laser.command.setProtocol( drv.ObjectWrapperProtocol(_VirtualCommand())) self.laser.command.laser_state = Cmd("laser_state") self.laser.command.gate_state = Cmd("gate_state") self.laser.interface = drv.Subsystem(self.laser) self.laser.interface.setProtocol( drv.ObjectWrapperProtocol(_VirtualInterface())) self.laser.interface.pilot_laser_state = Cmd("pilot_laser_state")
def __init__(self, socket): super(Maxigauge, self).__init__() self.setProtocol(CommunicationProtocol(socket)) # Controller subsystem self.errors = Cmd("ERR", access=Access.RO, rfunc=_parse_error) self.unit = Cmd("UNI", access=Access.RO, rfunc=lambda msg: {0: "mbar", 1: "Torr", 2: "Pascal"}[int(msg)]) # Display subsystem # UNI # DCB # DCC # DCS # Switching subsystem # SPx # SPS # PUC # Parameters subsystem # LOC # FIL # CAx # OFC # FSR # DGS # SAV # Interfaces subsystem # RSX # BAU # NAD # Gauge subsystem self.gauge = drv.Subsystem(self) # SEN bool # SCx # PRx self.gauge.pressure = Cmd("PR", access=Access.RO, rfunc=_parse_pressure)
def __init__(self, socket): super(Fluke18x, self).__init__() self.setProtocol(CommunicationProtocol(socket)) self.button = drv.Subsystem(self) for name, code in dict(blue=10, hold=11, min_max=12, rel=13, up_arrow=14, shift=15, Hz=16, range=17, down_arrow=18, backlight=19, calibration=20, auto_hold=21, fast_min_max=22, logging=23, cancel=27, wake_up=28, setup=29, save=30).iteritems(): self.button.__setattr__("press_%s" % name, Cmd("SF %i" % code, access=Access.WO)) self.identification = Cmd( "ID", doc="""Return model, S/N and software version information""") self.measure = Cmd("QM", rfunc=_parse_measure, access=Access.RO) self.unit = Cmd("QM", rfunc=_parse_unit, access=Access.RO) self.default_setup = Cmd("DS", access=Access.WO) self.reset = Cmd("RI", access=Access.WO)
def __init__(self, socket=None): super(VirtualInstrument, self).__init__() self.pid = PidSubsystem(self) # Input subsystem self.input = drv.Subsystem(self) self.input.setProtocol(drv.ObjectWrapperProtocol(Input())) self.input.sysout = Cmd("sysout") self.input.measure = Cmd("measure", access=Access.RO) # Output subsystem self.output = drv.Subsystem(self) self.output.setProtocol(drv.ObjectWrapperProtocol(Output())) self.output.input = Cmd("input") self.output.output = Cmd("output", access=Access.RO) self.output.noise = Cmd("noise") # Connections self.input.measure.signal.connect(self.pid.measure.write) self.input.measure.signal.connect( lambda value, node: self.pid.output.read(node)) self.pid.output.signal.connect(self.output.input.write) self.output.output.signal.connect(self.input.sysout.write)
def createController(): """Initialize controller.""" config = ctrlr.Config("watlow") if not config.nodes: config.nodes = [None] if config.virtual: driver = virtual.VirtualInstrument() driver.setup = drv.Subsystem(driver) driver.setup.setProtocol(drv.ObjectWrapperProtocol(_VirtualRamping())) driver.setup.global_ = drv.Subsystem(driver.setup) driver.setup.global_.ramp_init = Cmd("ramp_init") driver.setup.global_.ramp_rate = Cmd("ramp_rate") iface = WatlowController.virtualInstrumentController(config, driver) else: driver = Series988(drv.Serial(config.port)) iface = WatlowController(config, driver) iface.addCommand(driver.temperature1, "TC sample", poll=True, log=True) iface.addCommand(driver.temperature2, "TC heater", poll=True, log=True) iface.addCommand(driver.setpoint, "setpoint", log=True, specialColumn="programmable") iface.addCommand(driver.power, "output", poll=True, log=True) iface.addCommand(driver.operation.pid.a1.gain, "PID P", hide=True, specialColumn="pidp") iface.addCommand(driver.operation.pid.a1.integral, "PID I", hide=True, specialColumn="pidi") iface.addCommand(driver.operation.pid.a1.derivative, "PID D", hide=True, specialColumn="pidd") iface.addCommand(driver.setup.global_.ramp_init, "ramp_init", hide=True, specialColumn="rampinit") iface.addCommand(driver.setup.global_.ramp_rate, "ramp_rate", hide=True, specialColumn="ramprate") iface.editorPrototype.default_factory=QtGui.QSpinBox # Make sure we can read the rate driver.setup.global_.ramp_init.write(1) iface.populate() return iface
def __init__(self, socket, parent=None): super(ScpiRequired, self).__init__(socket, parent) self._scpi = drv.Subsystem(self) self._scpi.setProtocol(ieee.ScpiCommunicationProtocol(socket, self)) # SYSTem self.system = ScpiSubsystem("SYSTem", self._scpi) self.system.error = ScpiSubsystem("ERRor", self.system) self.system.error.next = Cmd("NEXT", access=Access.RO) self.system.version = Cmd("VERSion", rfunc=float, access=Access.RO) # STATus self.status = ScpiSubsystem("STATus", self._scpi) self.status.operation = ScpiSubsystem("OPERation", self.status) self.status.operation.event = Cmd("EVENt", access=Access.RO) self.status.operation.condition = Cmd("CONDition", access=Access.RO) self.status.operation.enable = Cmd("ENABle", access=Access.RW) self.status.questionable = ScpiSubsystem("QUEStionable", self.status) self.status.preset = Cmd("PRESet", access=Access.WO)
def __init__(self, socket): super(Sm700Series, self).__init__() socket.timeout = 1.0 # Termination character Controller -> PSC232: LF or CR # Termination character PSC232 -> Controller: EOT (\x04) socket.newline = "\x04" # DPL self.dpl = drv.Subsystem(self) self.dpl.setProtocol(DplProtocol(socket)) self.dpl.step_mode_voltage = Cmd("SA", rfunc=float, doc="Step mode A channel (voltage)") self.dpl.step_mode_current = Cmd("SB", rfunc=float, doc="Step mode B channel (current)") self.dpl.max_voltage = Cmd("FU", rfunc=float, doc="Input maximum voltage") self.dpl.max_current = Cmd("FI", rfunc=float, doc="Input maximum current") self.dpl.voltage = Cmd("U", "MA?", minimum=0.0, rfunc=float, doc="Output voltage") self.dpl.current = Cmd("I", "MB?", minimum=0.0, rfunc=float, doc="Output current") self.dpl.error = Cmd("ERR?", access=Access.RO, doc="Report last error") self.dpl.identification = Cmd("ID?", access=Access.RO, doc="Report identity of the PSC") self.dpl.scpi = Cmd("SCPI", access=Access.WO, doc="Switch to the SCPI parser") self.dpl.dpl = Cmd("DPL", access=Access.WO, doc="Switch to the DPL parser") # Common commands (488.2) self.common = Ieee4882(socket) # SCPI self.setProtocol(ScpiCommunicationProtocol(socket)) self.channel = Cmd("CH", rfunc=int) self.source = ieee.ScpiSubsystem("SOurce", self) self.source.voltage = Cmd("VOltage", rfunc=float, minimum=0.0) self.source.current = Cmd("CUrrent", rfunc=float, minimum=0.0) self.source.max_voltage = Cmd("VOltage:MAx", rfunc=float) self.source.max_current = Cmd("CUrrent:MAx", rfunc=float) self.source.function = ieee.ScpiSubsystem("FUnction", self.source) self.source.function.enable_remote_shutdown = Cmd("RSD", rfunc=_str2bool) self.source.function.output_a = Cmd("OUtA", rfunc=_str2bool) self.source.function.output_b = Cmd("OUtB", rfunc=_str2bool) self.source.function.output = Cmd("OUTPut", rfunc=_str2bool) self.source.function.lock_frontpanel = Cmd("FRontpanel:Lock", rfunc=_str2bool) self.measure = ieee.ScpiSubsystem("MEasure", self) self.measure.voltage = Cmd("VOltage", access=Access.RO, rfunc=float) self.measure.current = Cmd("CUrrent", access=Access.RO, rfunc=float) self.sense = ieee.ScpiSubsystem("SEnse", self) self.sense.digital = ieee.ScpiSubsystem("DIgital", self.sense) self.sense.digital.data = Cmd("DAta", access=Access.RO) self.sense.digital.extended_data = Cmd("EXtendeddata", access=Access.RO) self.sense.digital.switch = Cmd("SWitch", access=Access.RO) self.remote = ieee.ScpiSubsystem("REMote", self) self.remote.cv = Cmd("CV", rfunc=_str2bool) self.remote.cc = Cmd("CC", rfunc=_str2bool) self.local = ieee.ScpiSubsystem("LOCal", self) self.local.cv = Cmd("CV", rfunc=_str2bool, access=Access.WO) self.local.cc = Cmd("CC", rfunc=_str2bool, access=Access.WO) self.calibration = ieee.ScpiSubsystem("CAlibration", self) self.calibration.voltage = ieee.ScpiSubsystem("VOltage", self.calibration) self.calibration.current = ieee.ScpiSubsystem("CUrrent", self.calibration) self.calibration.voltage.measure = ieee.ScpiSubsystem("MEasure", self.calibration.voltage) self.calibration.current.measure = ieee.ScpiSubsystem("MEasure", self.calibration.current) for subsystem in (self.calibration.voltage, self.calibration.voltage.measure, self.calibration.current, self.calibration.current.measure): subsystem.gain = Cmd("GAin", rfunc=int, minimum=1, maximum=16383) subsystem.offset = Cmd("OFfset", rfunc=int, minimum=0, maximum=254) # PAssword # PAssword:Reset self.custom_string = Cmd("*IDN?", "CU") # SP self.variables = Cmd("VAR", access=Access.RO) self.help = Cmd("HELP", access=Access.RO) # set max current and voltage: try: self.source.voltage.maximum = self.source.max_voltage.read() self.source.current.maximum = self.source.max_current.read() except KeyError: # Ignore exception raised during auto documentation pass
def __init__(self, socket): super(Series988, self).__init__() self.setProtocol(XonXoffProtocol(socket)) self.setpoint = Cmd("SP1", minimum=-250, maximum=9999) self.power = Cmd("PWR", access=Access.RO, doc="power output %") self.temperature1 = Cmd("C1", minimum=-250, maximum=9999, access=Access.RO, doc="input value 1") self.temperature2 = Cmd("C2", minimum=-250, maximum=9999, access=Access.RO, doc="input value 2") # Subsystems self.setup = drv.Subsystem(self) setup_output_table = ( # name cmd minimum maximum """ action OT 0 1 process_range PRC 0 4 hysteresis HYS 0 999 """) self.setup.output1 = drv.Subsystem(self.setup) self.setup.output2 = drv.Subsystem(self.setup) self.setup.global_ = drv.Subsystem(self.setup) subsystemFromCsv(self.setup.output1, setup_output_table, 1) subsystemFromCsv(self.setup.output2, setup_output_table, 2) subsystemFromCsv( self.setup.global_, # name cmd minimum maximum """ ramp_init RP 0 2 ramp_rate RATE 0 9999 """) self.setup.communication = drv.Subsystem(self.setup) self.operation = drv.Subsystem(self) self.operation.system = drv.Subsystem(self.operation) self.operation.system.setpoint2 = Cmd("SP2") self.operation.pid = drv.Subsystem(self.operation) self.operation.pid.a1 = drv.Subsystem(self.operation.pid) self.operation.pid.a2 = drv.Subsystem(self.operation.pid) self.operation.pid.b1 = drv.Subsystem(self.operation.pid) self.operation.pid.b2 = drv.Subsystem(self.operation.pid) for subsystem, pid_unit in ((self.operation.pid.a1, "1A"), (self.operation.pid.a2, "2A"), (self.operation.pid.b1, "1B"), (self.operation.pid.b2, "2B")): for cmd_name, cmd in (("gain", "PB"), ("integral", "IT"), ("derivative", "DE")): setattr(subsystem, cmd_name, Cmd("".join((cmd, str(pid_unit))), rfunc=float)) self.factory = drv.Subsystem(self) self.factory.lockout = drv.Subsystem(self.factory) self.factory.diagnostic = drv.Subsystem(self.factory) self.factory.diagnostic.test_data = Cmd("DATE") self.factory.diagnostic.software_revision = Cmd("SOFT") self.factory.diagnostic.ambient_temperature = Cmd( "AMB", rfunc=_fahrenheit2celsius) self.factory.calibration = drv.Subsystem(self.factory)
def __init__(self, socket): super(CS400, self).__init__(0x00) self.setProtocol(CommunicationProtocol(socket)) # Main subsystem self.errors = Cmd(0x01, rfunc=_parse_bits({ 0x0080: "CAN guarding timeout", 0x0100: "laser on timeout", 0x0200: "firmware config", 0x0400: "hardware config", 0x0800: "initialisation failure", 0x1000: "device overtemp", 0x8000: "wrong command" }), access=Access.RO) self.warnings = Cmd(0x03, rfunc=_parse_bits({0x0080: "startup is delayed"}), access=Access.RO) self.configuration = Cmd(0x05, minimum=0x0, maximum=0x8001) self.firmware = Cmd(0x07, rfunc=partial(mul, 0.001), access=Access.RO) self.operation_mode = Cmd(0x0A, minimum=0, maximum=4) self._gate = Cmd(0x0B, minimum=0, maximum=0xffff) self._command = Cmd(0x0D, minimum=0, maximum=24) self._devstate = Cmd(0x0E, access=Access.RO) self.errors_total = Cmd(0x12, access=Access.RO) self.warnings_total = Cmd(0x13, access=Access.RO) self.timeout_laser_on = Cmd(0x14, minimum=0, maximum=3000, rfunc=partial(mul, 0.1), wfunc=partial(mul, 10.0)) # s self.operation_time = Cmd(0x1A, access=Access.RO) # h # Profile subsystem self.profile = Subsystem(0x01, self) # Parameters, limits and operating modes of the power control system. self.control = Subsystem(0x02, self) self.control.control_mode = Cmd(0x04, minimum=1, maximum=4) self.control.total_current = Cmd(0x05, minimum=0, maximum=3200, rfunc=partial(mul, 0.1), wfunc=partial(mul, 10.0)) # A self.control.total_current_meas = Cmd(0x06, rfunc=partial(mul, 0.1), access=Access.RO) # A self.control.total_power = Cmd(0x07, minimum=0, maximum=40000, rfunc=partial(mul, 0.1), wfunc=partial(mul, 10.0)) # W self.control.total_power_meas = Cmd(0x08, rfunc=partial(mul, 0.1), access=Access.RO) # W self.control.total_power_calc = Cmd(0x0A, rfunc=partial(mul, 0.1), access=Access.RO) # W self.control.pulse_duration = Cmd(0x1A, minimum=10, maximum=65000) self.control.pulse_pause = Cmd(0x1B, minimum=0, maximum=65000) # Laser's measure and calibration values. self.laser = Subsystem(0x05, self) self.laser.errors = Cmd(0x01, rfunc=_parse_bits({ 0x0001: "head humidity too high", 0x0002: "laser fiber broken", 0x0004: "laser fiber shortened", 0x0008: "shutter error", 0x0010: "fiber not plugged", 0x0040: "interlock head on", 0x0080: "interlock head wire", 0x0400: "config hardware error", 0x0800: "laser temp too high", 0x1000: "laser power dev too high" }), access=Access.RO) self.laser.warnings = Cmd(0x03, rfunc=_parse_bits({ 0x0001: "head humidity high", 0x0040: "interlock head on", 0x0100: "laser ervice interval", 0x0200: "laser temp too low", 0x0400: "laser temp high", 0x0800: "laser temp too high" }), access=Access.RO) self.laser.configuration = Cmd(0x05, minimum=0x0, maximum=0xfff) self.laser._serial_number_high = Cmd(0x07, access=Access.RO) self.laser._serial_number_low = Cmd(0x08, access=Access.RO) self.laser.on_time = Cmd(0x09, access=Access.RO) self.laser.service_interval = Cmd(0x0A, access=Access.RO) self.laser.temperature = Cmd(0x0C, rfunc=partial(mul, 0.1), access=Access.RO) # degC self.laser.power = Cmd(0x0D, rfunc=partial(mul, 0.1), access=Access.RO) # W self.laser.head_humidity = Cmd(0x0F, rfunc=partial(mul, 0.1), access=Access.RO) # Interface configurations and states. self.interface = Subsystem(0x06, self) self.interface.errors = Cmd(0x01, rfunc=_parse_bits({ 0x0001: "emergency stop", 0x0002: "emergency stop wire", 0x0004: "emergency stop remote terminal", 0x0008: "emergency wire remote terminal", 0x0010: "emergency stop external", 0x0020: "emergency stop external wire", 0x0040: "interlock external", 0x0080: "interlock external wire", 0x0100: "link error", 0x0200: "emergency stop SPI", 0x0400: "warn light(s) error", 0x1000: "cooler temp", 0x2000: "cooler flow" }), access=Access.RO) self.interface.warnings = Cmd(0x03, rfunc=_parse_bits({ 0x0040: "interlock external", 0x0400: "warn light(s) warning", 0x1000: "cooler temp", 0x2000: "cooler flow" }), access=Access.RO) self.interface.io_config = Cmd(0x05, minimum=0x0, maximum=0xffff) self.interface.io_config_OEM = Cmd(0x06, access=Access.RO) self.interface.io_state = Cmd(0x07, access=Access.RO) self.interface.io_digital_in = Cmd(0x09) self.interface._io_digital_out = Cmd(0x0a, minimum=0x0, maximum=0xffff) self.interface.io_digital_out = drv.Subsystem(self.interface) self.interface.io_digital_out.setProtocol(drv.CommandCallerProtocol()) self.interface.io_digital_out.pilot_laser_state = Cmd( self.__set_pilot_laser_state, self.__get_pilot_laser_state) self.interface.pilot_beam_intensity = Cmd(0x0b, minimum=1, maximum=10) self.interface.PWM_input_offset = Cmd(0x0c, access=Access.RO) self.interface.PWM_input_slope = Cmd(0x0d, access=Access.RO) # Cooler contorller specific registers. self.cooler = Subsystem(0x07, self) self.cooler._errors1 = Cmd(0x01, access=Access.RO) self.cooler._errors2 = Cmd(0x02, access=Access.RO) self.cooler._warnings = Cmd(0x03, access=Access.RO) # Power subsystem self.power = _PowerSubsystem(0x0a, self) # Handle main.CMD, main.DEVSTATE, and main.GATE. self.command = drv.Subsystem(self) self.command.setProtocol(drv.CommandCallerProtocol()) self.command.clear_errors = Cmd(partial(self._command.write, 1), access=Access.WO) self.command.laser_state = Cmd(self.__get_laser_state, self.__set_laser_state) self.command.gate_state = Cmd(self.__get_gate_state, self.__set_gate_state) self.command.is_ready = Cmd(self.__is_ready, access=Access.RO) self.command.is_laser_enabled = Cmd(self.__is_laser_enabled, access=Access.RO) self.command.is_warning_present = Cmd(self.__is_warning_present, access=Access.RO) self.command.is_error_present = Cmd(self.__is_error_present, access=Access.RO)