def compact_status(): # warning ":MEAS" turns on the channel! date_string = time.strftime("%Y-%m-%d+%X") current_string = query_quiet(":MEASure:CURRent?") voltage_string = query_quiet(":MEASure:VOLTage?") info("%s, %s, %s" % (date_string, current_string, voltage_string))
def print_header(): info("#date, current (A), voltage (V)")
def show_status(): mode = get_mode() if mode=="VOLT": info("voltage mode") if check()=="1": info("output enabled") get_i() get_v() else: info("output disabled") get_ilim() get_vlim() else: info("current mode") if check()=="1": info("output enabled") get_i() get_v() else: info("output disabled") get_ilim() get_vlim()
def identify(): message = "*IDN?" response = scpi.query(message) info(response + " at " + ip)
def query(message, prefix="", suffix=""): response = query_quiet(message) info(prefix + response + suffix) return response
create_new_logfile_with_string("control_smu") b2901a.setip(ip) b2901a.connect() if len(sys.argv) > 1: command = "" #debug(str(len(sys.argv))) for arg in sys.argv[1:]: #debug(arg) match = re.search("(on|off)", arg, re.IGNORECASE) if match: command = match.group(1) debug("matched " + command) if not command == "": match = re.search("on", command, re.IGNORECASE) if match: info("turning on") b2901a.set_ilim_v(ilim, v) b2901a.on() match = re.search("off", command, re.IGNORECASE) if match: info("turning off") b2901a.off() else: #b2901a.identify() #b2901a.show_status() b2901a.print_header() while True: b2901a.compact_status() sys.stdout.flush() time.sleep(1)