fxes. working Zeiss-1000+EMCCD sequence
This commit is contained in:
@@ -192,6 +192,8 @@ def focussing_app(parser, init_seq_func, set_focus_func, get_image_func):
|
||||
if args.verbose:
|
||||
print("\n\tThe best focus value: {:g}".format(result["focus_value"]))
|
||||
|
||||
ret_code = 0
|
||||
|
||||
if not args.do_not_set:
|
||||
if args.verbose:
|
||||
print("\n\tSet focus to the best value ...", end="")
|
||||
|
||||
@@ -18,6 +18,7 @@ import subprocess as sp
|
||||
import numpy as np
|
||||
import socket
|
||||
import pathlib as pl
|
||||
import time
|
||||
|
||||
|
||||
def init_seq(seq_kwds):
|
||||
@@ -45,13 +46,28 @@ def set_focus(foc_val):
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.connect(("ztcs.sao.ru", 4444))
|
||||
|
||||
sock.send("goto={:g}".format(foc_val))
|
||||
resp = sock.recv(20)
|
||||
bt = bytearray("goto={:g}".format(foc_val), 'utf8')
|
||||
|
||||
sock.send(bt)
|
||||
resp = sock.recv(20).decode('utf8')
|
||||
|
||||
if resp != "OK":
|
||||
sock.close()
|
||||
return 1
|
||||
|
||||
tp_start = time.monotonic()
|
||||
|
||||
while True:
|
||||
time.sleep(0.5)
|
||||
sock.send(b'status')
|
||||
resp = sock.recv(20).decode('utf8')
|
||||
if resp == 'OK':
|
||||
break;
|
||||
|
||||
if (time.monotonic()-tp_start) > 30.0:
|
||||
sock.close() # timeout!
|
||||
return 2
|
||||
|
||||
sock.close()
|
||||
|
||||
return 0
|
||||
@@ -61,7 +77,7 @@ def set_focus(foc_val):
|
||||
# Assumes Andor IXon EMCCD server is listenning UNIX socket on localhost
|
||||
#
|
||||
def get_image(filename, exp_time):
|
||||
cmd = ["ixonultra_cmdclient", "-A", "CCD", "-T", "{:g}".format(exp_time), filename]
|
||||
cmd = ["ixonultra_cmdclient", "-A", "CCD", "-p", "1", "--hs", "0", "-T", "{:g}".format(exp_time), filename]
|
||||
|
||||
ret = sp.run(cmd, stdout=sp.PIPE, stderr=sp.PIPE)
|
||||
return ret.returncode
|
||||
|
||||
@@ -23,7 +23,8 @@ def set_focus(foc_val):
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.connect(("ztcs.sao.ru", 4444))
|
||||
|
||||
sock.send("goto={:g}".format(foc_val))
|
||||
print(foc_val)
|
||||
sock.send("goto={:f}".format(foc_val))
|
||||
resp = sock.recv(20)
|
||||
|
||||
if resp != "OK":
|
||||
@@ -36,7 +37,7 @@ def set_focus(foc_val):
|
||||
|
||||
|
||||
def get_image(filename, exp_time):
|
||||
cmd = ["ixonultra_cmdclient", "-A", "CCD", "-T", "{:g}".format(exp_time), filename]
|
||||
cmd = ["ixonultra_cmdclient", "-A", "CCD", "-p", "1", "--hs", "0", "-T", "{:g}".format(exp_time), filename]
|
||||
|
||||
ret = sp.run(cmd, stdout=sp.PIPE, stderr=sp.PIPE)
|
||||
return ret.returncode
|
||||
@@ -175,7 +176,7 @@ if __name__ == "__main__":
|
||||
if args.verbose:
|
||||
print("\tThe best focus value: {:g}".format(result["focus_value"]))
|
||||
|
||||
if not args.do_no_set:
|
||||
if not args.do_not_set:
|
||||
if args.verbose:
|
||||
print("\n\tSet focus to the best value ...", end="")
|
||||
set_focus(result["focus_value"])
|
||||
@@ -185,3 +186,4 @@ if __name__ == "__main__":
|
||||
print("DONE.")
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user