diff --git a/FofbTool/Operation.py b/FofbTool/Operation.py index 31ed2f5d0954531a98b8f89c084e9e63219854e1..510600c6d1c8221264f0ccc901bd939e05bb8e57 100644 --- a/FofbTool/Operation.py +++ b/FofbTool/Operation.py @@ -39,8 +39,7 @@ def align_ccn(nodename): logger.info("Trying to detect and align FA sequences") logger.debug("Reset offsets on comlbp") - for n in range(4): - prx["comlbp{}_seqoffset".format(n)]=0 + set_comlbp_seqoffset(nodename, 0) # Loop until two consecutives identical measures N=[7,3] @@ -70,9 +69,9 @@ def align_ccn(nodename): if -N > 0x8000: N=N+0x10000 - logger.info("Program sequence offset {} in {}".format(N, nodename)) - for n in range(4): - prx["comlbp{}_seqoffset".format(n)]=N + + set_comlbp_seqoffset(nodename, N) + seqoffset=N logger.debug("Perform autocheck") logger.debug("Latch two sequence numbers without offset") @@ -85,7 +84,20 @@ def align_ccn(nodename): if not N in (-1, 1): logger.warning("Corrected sequence offset measured = {}, something might be wrong. Run it again".format(N)) return False - return True + return seqoffset + +def set_comlbp_seqoffset(nodename, N): + """ Set sequence offset for all comlbp interfaces """ + + prx=FofbTool.Utils.get_prx_from_nodename(nodename) + if prx is None: + logger.error("Failed to align CCN on {}".format(nodename)) + return + + logger.info("Program sequence offset {} in {}".format(N, nodename)) + for n in range(4): + prx["comlbp{}_seqoffset".format(n)]=N + def stop_ccn(nodename): """ diff --git a/FofbTool/Utils.py b/FofbTool/Utils.py index 7dd206663958cb40fddcc423b90594968e9312bd..b273b14fbcab7c92f54c3a7d336b83b411e2c46f 100644 --- a/FofbTool/Utils.py +++ b/FofbTool/Utils.py @@ -315,4 +315,25 @@ def start_all_ccn(): for n,p in FofbTool.Configuration.config["tangopath.fofbnodes"].items(): FofbTool.Operation.start_ccn(n) +def align_all_ccn(cellnodename, force=False): + """ + Launch alignement FA sequence for Electron and Brillance Plus. + """ + + if not check_fofbnotrunning(force): + logger.warning("Not running align ccn because FOFB seems to be running.") + return + + logger.debug("Use {} for sequence alignement".format(cellnodename)) + seqoffset = FofbTool.Operation.align_ccn(cellnodename) + if not seqoffset: + logger.error("Could not align all ccn") + return + + for n,p in FofbTool.Configuration.config["tangopath.fofbnodes"].items(): + if 'cellnode' in n: + try: + FofbTool.Operation.set_comlbp_seqoffset(n, seqoffset) + except (tango.DevFailed, TypeError): + logger.error("Could not set comlbp offset on {}".format(n)) diff --git a/scripts/FofbTool b/scripts/FofbTool index 9dff59edcbe4023a2afb65b1756cb074d0c54ee1..a5f5cef566e0136b035fa38e05b135e532ba4bf9 100755 --- a/scripts/FofbTool +++ b/scripts/FofbTool @@ -62,6 +62,9 @@ if __name__ == '__main__': help="Configuration commands for the Fofb applications blocs."+ " 'all' is for all com and corrector. Default is 'all'") + parser.add_argument("--align-fa", type=str, metavar="cellnode-cXX", + help="Start alignement process for electron and brillance plus FA sequence. The designation of the cellnode must be set as argument.") + parser.add_argument("--start", action="store_true", help="Start command for the CCN and ComBPM applications blocks.") parser.add_argument("--start-combpm", action="store_true", @@ -127,3 +130,6 @@ if __name__ == '__main__': if args.start or args.start_ccn: FofbTool.Utils.start_all_ccn() + if not args.align_fa is None: + FofbTool.Utils.align_all_ccn(args.align_fa, force=args.force) +