I have now finished my script an have changee the title of this topic accordingly:
This is a script to measure certain values with 2 gates (Updates might follow):
import telnetlib
import time
class POP3Telnet:
def __init__(self, host, port):
self.tel = telnetlib.Telnet(host, port)
#self.lese_daten()
def close(self):
self.tel.close()
def lese_daten(self):
return self.tel.read_until(b"\n", 2)
def kommando(self, kom):
self.tel.write(("{}\r\n".format(kom)).encode())
time.sleep(0.02) # May need adjusting
return
host = "169.254.143.210"
port = 5024
user = ""
passwd = ""
gate_1A = -35
gate_1B = 35
gate_2A = 400
gate_2B = 8000
pop = POP3Telnet(host, port)
# Read and discard useless Messages
pop.lese_daten().decode()
pop.lese_daten().decode()
pop.kommando(":HISTOR:FRAM 1")
for x in range(0,80000):
x = x + 1 # starts from 0
# print time
pop.kommando(":HISTOR:TIME?")
print("{} {} ".format(x, pop.lese_daten().decode().strip('\n').replace(' ','')), end="")
# Measure first gate measure no. 2
pop.kommando(":MEAS:GATE:GA {}E-9".format(gate_1A))
pop.kommando(":MEAS:GATE:GB {}E-9".format(gate_1B))
pop.kommando(":MEAS:ADV:P2:VAL?")
data = pop.lese_daten().decode().strip('\n')
if data.find('*') >= 0:
print("-", end="")
else:
print(float(data), end="")
print(" ", end="")
# Measure second gate measure no. 1
pop.kommando(":MEAS:GATE:GB {}E-9".format(gate_2B)) # MOVE FURTHEST GATE FIRST! A cant overtake B !
pop.kommando(":MEAS:GATE:GA {}E-9".format(gate_2A))
pop.kommando(":MEAS:ADV:P1:VAL?")
data = pop.lese_daten().decode().strip('\n')
if data.find('*') >= 0:
print("-", end="")
else:
print(float(data), end="")
print("")
# Move on in frames
pop.kommando(":HISTOR:FRAM {}".format(x+1)) # set next frame
pop.kommando(":HISTOR:FRAM?")
if float(pop.lese_daten().decode()) == x: # no more frames!
break
pop.kommando("QUIT")
pop.close()