def addInstrument(self, addr): res = self._rm.open_resource(addr) try: idn = res.query('*idn?')[:-1] if (idn == ''): idn = res.query('ID?') mm = splitResourceID(idn) resadptr = VISAAdapter(mm[1], res) if self._debugOn: print("\t", addr, ":", idn) for icls in res_types: sup = icls.checkSupport(mm[1]) if (sup): self._instruments[sup].append(icls(mm, resadptr)) except visa.Error: idn = "Not known"
rcp = "COM53" com_list = [ #stp, #red, #blk, reduut, blkuut, #rcp ] testclass = SerialPort res = {} addr_ps = "GPIB0::6::INSTR" rm = visa.ResourceManager() try: r = rm.open_resource(addr_ps) mm = splitResourceID(r.query('*idn?')[:-1]) print(mm) adptr = VISAAdapter("TestAdapter", r) ps = PS(mm, adptr) ps.output_state(0) ps.voltage(26) time.sleep(1) ps.output_state(1) except: print("Power Supply Error") print(rm.list_resources()) print(win.listSerialPorts()) for addr in com_list: #print(addr) try:
addr_scp ] res = {} rm = visa.ResourceManager() print(rm.list_resources()) print(win.listSerialPorts()) for addr in addr_list: if (addr is not None): try: r = rm.open_resource(addr) idn = r.query('*idn?')[:-1] if (idn == ''): idn = r.query('ID?') mm = splitResourceID(idn) print(mm) for cl in instruments: sup = cl.checkSupport(mm[1]) if (sup): adptr = VISAAdapter("TestAdapter", r) instr = cl(mm, adptr) res[addr] = [mm, adptr, instr] except: print("GPIB Error at ", addr) print("\nResources:\n") for k, v in res.items(): print(k) if (k == addr_cnt): cnt = res[k][2]