""" operte with IT65xx power suppliers! control power supplier using pyvisa """ import pyvisa from PythonTap import * from System import Double, String import OpenTap class IT65xx: """IT65xx power supplier class!""" instance = "" def __init__(self, resoure_address): """initialise the instrument, return handle!""" rm = pyvisa.ResourceManager() self.instance = rm.open_resource(resoure_address) if self.instance is not None: self.instance.read_termination = "\n" self.instance.write_termination = "\n" return def config_voltage_current(self, voltage, current): """Set the output voltage and current!""" # set voltage self.instance.write("CURR ", str(current)) self.instance.write("VOLT ", str(voltage)) return def read_voltage_current(self): """read the voltage and current!""" voltage = self.instance.query("MEAS:VOLT?") current = self.instance.query("MEAS:CURR?") return [voltage, current] def output_on_off(self, onoff): """Set output on or off!""" if onoff == 1: self.instance.write("OUTP 1") else: self.instance.write("OUTP 0") return @Attribute(OpenTap.DisplayAttribute, "Power Suppliers", "Power suppliers instruments", "IT65xx") class py_IT65XX(Instrument): def __init__(self): "Set up the properties, methods and default values of the instrument." super(py_IT65XX, self).__init__() # The base class initializer must be invoked. self.count = 0; self.visa_address = self.AddProperty("visa_address", "", String) self.visa_address.AddAttribute(OpenTap.DisplayAttribute, "VISA Address", "The VISA Address of the instrument.") self.Name = "IT65xx" self.RegisterMethod("config_voltage_current", None).AddArgument("voltage", Double).AddArgument("current", Double); #Expose config_voltage_current in the API. self.RegisterMethod("read_voltage_current", None); #Expose read_voltage_current in the API. self.RegisterMethod("output_on_off", None).AddArgument("onoff", bool); #Expose output_on_off in the API. def config_voltage_current(self,voltage, current): self.psu.config_voltage_current(voltage, current) self.Info("IT65XX configure voltage and current executed") def read_voltage_current(self): self.psu.read_voltage_current() self.voltage = self.psu.voltage self.current = self.psu.current self.Info("IT65XX read voltage and current executed") def output_on_off(self,onoff): self.psu.output_on_off(onoff) self.Info("IT65XX switch voltage executed") def Open(self): """Called by TAP when the test plan starts.""" self.psu = IT65xx(self.visa_address) self.Info("IT65XX initialized") def Close(self): """Called by TAP when the test plan ends.""" self.Info("IT65XX Closed")