From 52c1297dd6c1a5ab346426e31976958f7a1f2f1e Mon Sep 17 00:00:00 2001 From: LorenzoMonti Date: Fri, 6 May 2022 10:46:30 +0200 Subject: [PATCH 1/2] minor fixes in remote_mark script --- src/remote_mark/remote_mark.py | 66 +++++++++++++++++----------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/src/remote_mark/remote_mark.py b/src/remote_mark/remote_mark.py index f16ae06..70000ce 100644 --- a/src/remote_mark/remote_mark.py +++ b/src/remote_mark/remote_mark.py @@ -19,7 +19,7 @@ def set_dat64f(dat_host, dat_port, timeout, db): with telnetlib.Telnet(dat_host, dat_port, timeout) as session: session.write(b"att?\n") - print(session.read_until(b'\r\n').decode('ascii')) + print("\n\tDAT64F attenuator: " + session.read_until(b'\r\n').decode('ascii')) ################################################## # Siglent SDP 3003X # @@ -38,14 +38,14 @@ def SocketConnect(): #create an AF_INET, STREAM socket (TCP) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) except socket.error: - print ('Failed to create socket.') + print ('\tFailed to create socket.') sys.exit() try: #Connect to remote server sock.connect((siglent_ip , siglent_port)) except socket.error: - print ('failed to connect to ip ' + siglent_ip) + print ('\tfailed to connect to ip ' + siglent_ip) return sock def SocketSend(Sock, cmd): @@ -56,7 +56,7 @@ def SocketSend(Sock, cmd): time.sleep(1) except socket.error: #Send failed - print ('Send failed') + print ('\tSend failed') sys.exit() def SocketQuery(Sock, cmd): @@ -93,58 +93,60 @@ def set_siglent(switch): """ SocketClose(sock) - print('Query complete. Exiting program') - sys.exit + print('\tSiglent SDP 3003X: ' + switch_string + "\n") + if __name__ == '__main__': - - dat_host = "localhost" #"192.168.60.73" + dat_local = "192.168.60.73" + dat_remote = "localhost" dat_port = 10001 timeout = 1000 - siglent_ip = "localhost" #"192.168.60.72" + siglent_local = "192.168.60.72" + siglent_remote = "localhost" siglent_port = 5025 - count = 0 - + + dat_host = "" + siglent_ip = "" + + interface = input("select interface: (1) for local inteface, (2) for remote interface: ") + if interface == '1': + dat_host = dat_local + siglent_ip = siglent_local + elif interface == '2': + dat_host = dat_remote + siglent_ip = siglent_remote + else: + print("No available interfaces, try again...") + sys.exit() - """ - "Track Siglent ATT - "PC OFF 8 - "PC+m ON 8 - "PH ON 3.5 - "PH+m OFF 3.5 - "PC OFF 8 - """ #PC input("Press Enter to continue with PC") - set_dat64f(dat_host, dat_port, timeout, 8) + set_dat64f(dat_host, dat_port, timeout, 63) time.sleep(1) set_siglent('OFF') - print("PC done") + print("\tPC done\n") #PC+m input("Press Enter to continue with PC+m") - set_dat64f(dat_host, dat_port, timeout, 8) + set_dat64f(dat_host, dat_port, timeout, 63) time.sleep(1) set_siglent('ON') - print("PC+m done") + print("\tPC+m done\n") #PH+m input("Press Enter to continue with PH+m") - set_dat64f(dat_host, dat_port, timeout, 3) + set_dat64f(dat_host, dat_port, timeout, 21.5) time.sleep(1) set_siglent('ON') - print("PH+m done") + print("\tPH+m done\n") #PH input("Press Enter to continue with PH") - set_dat64f(dat_host, dat_port, timeout, 3) + set_dat64f(dat_host, dat_port, timeout, 21.5) time.sleep(1) set_siglent('OFF') - print("PH done") + print("\tPH done\n") #PC input("Press Enter to continue with PC") - set_dat64f(dat_host, dat_port, timeout, 8) + set_dat64f(dat_host, dat_port, timeout, 63) time.sleep(1) set_siglent('OFF') - print("PC done") - - - \ No newline at end of file + print("\tPC done\n") \ No newline at end of file -- GitLab From c2dd479ffe57abfc37460db8f3084fbb60b5f3d1 Mon Sep 17 00:00:00 2001 From: LorenzoMonti Date: Wed, 11 May 2022 16:33:19 +0200 Subject: [PATCH 2/2] remote mark script improved --- src/remote_mark/remote_mark.py | 43 ++++++++++------------------------ 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/src/remote_mark/remote_mark.py b/src/remote_mark/remote_mark.py index 70000ce..4c8e201 100644 --- a/src/remote_mark/remote_mark.py +++ b/src/remote_mark/remote_mark.py @@ -97,6 +97,7 @@ def set_siglent(switch): if __name__ == '__main__': + # network settings dat_local = "192.168.60.73" dat_remote = "localhost" dat_port = 10001 @@ -109,6 +110,12 @@ if __name__ == '__main__': dat_host = "" siglent_ip = "" + # arguments for attenuator and power supply + experimentlist = ["PC", "PC+m", "PH+m", "PH", "PC"] + dat64list = [63, 63, 21.5, 21.5, 63] + siglentlist = ["OFF", "ON", "ON", "OFF", "OFF"] + + interface = input("select interface: (1) for local inteface, (2) for remote interface: ") if interface == '1': dat_host = dat_local @@ -120,33 +127,9 @@ if __name__ == '__main__': print("No available interfaces, try again...") sys.exit() - #PC - input("Press Enter to continue with PC") - set_dat64f(dat_host, dat_port, timeout, 63) - time.sleep(1) - set_siglent('OFF') - print("\tPC done\n") - #PC+m - input("Press Enter to continue with PC+m") - set_dat64f(dat_host, dat_port, timeout, 63) - time.sleep(1) - set_siglent('ON') - print("\tPC+m done\n") - #PH+m - input("Press Enter to continue with PH+m") - set_dat64f(dat_host, dat_port, timeout, 21.5) - time.sleep(1) - set_siglent('ON') - print("\tPH+m done\n") - #PH - input("Press Enter to continue with PH") - set_dat64f(dat_host, dat_port, timeout, 21.5) - time.sleep(1) - set_siglent('OFF') - print("\tPH done\n") - #PC - input("Press Enter to continue with PC") - set_dat64f(dat_host, dat_port, timeout, 63) - time.sleep(1) - set_siglent('OFF') - print("\tPC done\n") \ No newline at end of file + for i in range(5): + input("Press Enter to continue with " + experimentlist[i]) + set_dat64f(dat_host, dat_port, timeout, dat64list[i]) + time.sleep(1) + set_siglent(siglentlist[i]) + print("\t" + experimentlist[i] + " done\n") \ No newline at end of file -- GitLab