From 17d79d305580e6c972d2fee7492111f52ca5eeeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20BRON=C3=88S?= <romain.brones@synchrotron-soleil.fr> Date: Tue, 6 Aug 2024 15:28:17 +0200 Subject: [PATCH] Improve sequence offset seeking --- FofbTool/Operation.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/FofbTool/Operation.py b/FofbTool/Operation.py index 203c9af..3208814 100644 --- a/FofbTool/Operation.py +++ b/FofbTool/Operation.py @@ -66,7 +66,16 @@ def align_ccn(node_tangopath, comlbpif=0): time.sleep(2+np.random.uniform()) prx.ccnpack0_control=2 # latch it time.sleep(2) - N.append(prx.ccnpack0_latchedseq1-prx.ccnpack0_latchedseq2) + + _N = prx.ccnpack0_latchedseq1-prx.ccnpack0_latchedseq2 + + # handle diff going from 17 bits to 16bits offset + if _N > 0x7FFF: + _N=_N-0x10000 + if -_N > 0x8000: + _N=_N+0x10000 + + N.append(_N) logger.debug("seq ({}, {}, {})".format(prx.ccnpack0_latchedseq1, prx.ccnpack0_latchedseq2, N[-1])) @@ -76,12 +85,6 @@ def align_ccn(node_tangopath, comlbpif=0): if N in (-1, 0, 1): logger.warning("Sequence offset measured = {}, something might be wrong".format(N)) - # handle diff going from 17 bits to 16bits offset - if N > 0x7FFF: - N=N-0x10000 - if -N > 0x8000: - N=N+0x10000 - logger.debug("Setting sequence offset to {}".format(N)) prx["comlbp{}_seqoffset".format(comlbpif)]=N -- GitLab