Пример #1
0
def retrieve_data_single(ip, port, fname):
    executor = SocketExecutor(ip, port, expect_reply=False, endline="\n")
    executor.execute_command(":FORM:DATA ASC") # Set data to ASCII

    data = executor.ask(":CALC1:DATA:FDAT?")
    data = data.split(",")
    data = [float(i) for i in data]
    write_vector(data, fname + "_freqdata.csv")

    freq_data = executor.ask(":SENS1:FREQ:DATA?")
    freq_data = freq_data.split(",")
    freq_data = [float(i) for i in freq_data]
    write_vector(freq_data, fname + "_freqdata.csv")

    executor.close()
Пример #2
0
def poll_for_data(ip, port, ui, active):
    executor = SocketExecutor(ip, port)
    while True:
        executor.execute_command("SP")
        is_ready = executor.get_data()
        is_ready = is_ready.replace("\0","")
        if 0b00000001 & int(is_ready):
            # Data is ready. Break out of this loop 
            break
        time.sleep(1)
    # Retrieve data and save it to file
    for element in active:
        print "Run once per channel"
        combo = element['combo']
        ch = int(str(combo.objectName())[3:4])
        template = "DO 'CH{ch}T'"
        cmd = template.format(ch=ch)
        data = executor.ask(cmd)
        with open(str(ui.fileField.text())+ str(ch) + ".csv",'w+') as f:
            data = data.split(",")
            for line in data:
                f.write(line+"\r\n")

    executor.close()