def runCommand(nameRequired, chRequired): if len(nameRequired) < 5: return #find required device usbDev = None listOfDevices = usbtmc.getDeviceList() for dn in listOfDevices: d = usbtmc.UsbTmcDriver(dn) name = d.getName() if name == None: continue if len(str(name)) == 0: continue name = name[:-1] print(name) if name == nameRequired: usbDev = dn #print( "SUCCESS" + str(dn) ) break #Exit if required device not found if usbDev == None: print("Error powerOff : could not find required device. Exiting") return #get device interface object d = usbtmc.UsbTmcDriver(usbDev) #print d.getName() if chRequired[0] == 1: w("INST CH1", d) w(":OUTP? CH1", d) print d.read() w("VOLT?", d) print d.read() w("CURR?", d) print d.read() w(":MEAS:CURR? CH1", d) print d.read() if chRequired[1] == 1: w("INST CH2", d) w(":OUTP? CH2", d) print d.read() w("VOLT?", d) print d.read() w("CURR?", d) print d.read() w(":MEAS:CURR? CH2", d) print d.read() if chRequired[2] == 1: w("INST CH2", d) w(":OUTP? CH2", d) print d.read() w("VOLT?", d) print d.read() w("CURR?", d) print d.read() w(":MEAS:CURR? CH3", d) print d.read()
def __init__(self, device = None): if(device == None): listOfDevices = usbtmc.getDeviceList() if(len(listOfDevices) == 0): raise ValueError("There is no device to access") self.device = listOfDevices[0] else: self.device = device self.initScope()
import usbtmc import time listOfDevices = usbtmc.getDeviceList() print(str(listOfDevices)) for dn in listOfDevices: d = usbtmc.UsbTmcDriver(dn) name = d.getName() print(str(name))
def discoverFG(): nameQ = '*IDN?' #what's connected? query. lod = usbtmc.getDeviceList() print lod if len(lod) == 3: d = [ usbtmc.UsbTmcDriver(lod[0]), usbtmc.UsbTmcDriver(lod[1]), usbtmc.UsbTmcDriver(lod[2]) ] d[0].write(nameQ) d[1].write(nameQ) d[2].write(nameQ) time.sleep(0.2) if d[0].read() == '': scID = lod[0] scDr = d[0] fgID1 = lod[1] fgDr1 = d[1] fgID2 = lod[2] fgDr2 = d[2] elif d[1].read() == '': scID = lod[1] scDr = d[1] fgID1 = lod[0] fgDr1 = d[0] fgID2 = lod[2] fgDr2 = d[2] else: scID = lod[2] scDr = d[2] fgID1 = lod[0] fgDr1 = d[0] fgID2 = lod[1] fgDr2 = d[1] elif len(lod) == 2: d = [usbtmc.UsbTmcDriver(lod[0]), usbtmc.UsbTmcDriver(lod[1])] d[0].write(nameQ) d[1].write(nameQ) time.sleep(0.2) if d[0].read() == '': scID = lod[0] scDr = d[0] fgID1 = lod[1] fgDr1 = d[1] fgID2 = None fgDr2 = None elif d[1].read() == '': scID = lod[1] scDr = d[1] fgID1 = lod[0] fgDr1 = d[0] fgID2 = None fgDr2 = None else: scID = None scDr = None fgID2 = lod[1] fgID2 = d[1] fgID1 = lod[0] fgDr1 = d[0] elif len(lod) == 1: d = usbtmc.UsbTmcDriver(lod) d.write(nameQ) time.sleep(0.2) if d.read() == '': scID = lod scDr = d fgID1 = None fgDr1 = None fgID2 = None fgDr2 = None else: fgID1 = lod fgDr1 = d fgID2 = None fgDr2 = None scID = None scDr = None else: fgID1 = None fgDr1 = None fgID2 = None fgDr2 = None scID = None scDr = None return fgID1, fgDr1, fgID2, fgDr2, scID, scDr
parser = OptionParser() parser.add_option("-p", "--plot", action="store_false", help="Shows the window with the plot") parser.add_option("-1", "--hideChannel1", action="store_true", default=False, help="Hides Channel 1 in the plot") parser.add_option("-2", "--hideChannel2", action="store_true", default=False, help="Hides Channel 2 in the plot") parser.add_option("-i", "--informations", action="store_false", help="Prints scope informations") parser.add_option("-s", "--savePlot", metavar="filename", help="Saves the plot into a image") parser.add_option("-t", "--title", metavar="title", help="Set the title of the plot") parser.add_option("-d", "--hideDate", action="store_true", default=False, help="Hides the date in the plot") parser.add_option("-r", "--restart", action="store_true", default=False, help="Restart require after plot") (options, args) = parser.parse_args() """ Example program to plot the Y-T data from Channel 1""" listOfDevices = usbtmc.getDeviceList() systemArguments = sys.argv """Initialize our scope""" if len(listOfDevices) == 0: print "You need one or more devices" pass choosenDevice = listOfDevices[0] scope = rigolScope.RigolScope(choosenDevice) if options.informations != None: print "Device: ", choosenDevice