fxes. working Zeiss-1000+EMCCD sequence

This commit is contained in:
2025-08-24 19:39:54 +03:00
parent cd49a9044f
commit 66c10e2f31
3 changed files with 26 additions and 6 deletions

View File

@@ -192,6 +192,8 @@ def focussing_app(parser, init_seq_func, set_focus_func, get_image_func):
if args.verbose: if args.verbose:
print("\n\tThe best focus value: {:g}".format(result["focus_value"])) print("\n\tThe best focus value: {:g}".format(result["focus_value"]))
ret_code = 0
if not args.do_not_set: if not args.do_not_set:
if args.verbose: if args.verbose:
print("\n\tSet focus to the best value ...", end="") print("\n\tSet focus to the best value ...", end="")

View File

@@ -18,6 +18,7 @@ import subprocess as sp
import numpy as np import numpy as np
import socket import socket
import pathlib as pl import pathlib as pl
import time
def init_seq(seq_kwds): def init_seq(seq_kwds):
@@ -45,13 +46,28 @@ def set_focus(foc_val):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("ztcs.sao.ru", 4444)) sock.connect(("ztcs.sao.ru", 4444))
sock.send("goto={:g}".format(foc_val)) bt = bytearray("goto={:g}".format(foc_val), 'utf8')
resp = sock.recv(20)
sock.send(bt)
resp = sock.recv(20).decode('utf8')
if resp != "OK": if resp != "OK":
sock.close() sock.close()
return 1 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() sock.close()
return 0 return 0
@@ -61,7 +77,7 @@ def set_focus(foc_val):
# Assumes Andor IXon EMCCD server is listenning UNIX socket on localhost # Assumes Andor IXon EMCCD server is listenning UNIX socket on localhost
# #
def get_image(filename, exp_time): 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) ret = sp.run(cmd, stdout=sp.PIPE, stderr=sp.PIPE)
return ret.returncode return ret.returncode

View File

@@ -23,7 +23,8 @@ def set_focus(foc_val):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("ztcs.sao.ru", 4444)) 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) resp = sock.recv(20)
if resp != "OK": if resp != "OK":
@@ -36,7 +37,7 @@ def set_focus(foc_val):
def get_image(filename, exp_time): 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) ret = sp.run(cmd, stdout=sp.PIPE, stderr=sp.PIPE)
return ret.returncode return ret.returncode
@@ -175,7 +176,7 @@ if __name__ == "__main__":
if args.verbose: if args.verbose:
print("\tThe best focus value: {:g}".format(result["focus_value"])) 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: if args.verbose:
print("\n\tSet focus to the best value ...", end="") print("\n\tSet focus to the best value ...", end="")
set_focus(result["focus_value"]) set_focus(result["focus_value"])
@@ -185,3 +186,4 @@ if __name__ == "__main__":
print("DONE.") print("DONE.")
sys.exit(0) sys.exit(0)