diff --git a/FofbTool/Operation.py b/FofbTool/Operation.py index 203c9af42b64993d1c5729d784e42a585c75292e..3208814f53dcdaf86db2a7949b2bdcb9f1dd095e 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