From f403c3a5d010e2beed5c6d94c18b38992a095b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Bron=C3=A8s?= <romain.brones@synchrotron-soleil.fr> Date: Thu, 6 Jun 2024 16:44:46 +0200 Subject: [PATCH] feat(comlbp): Add operation and configuration of comlbp blocks --- FofbTool/Configuration.py | 22 ++++++++ FofbTool/Operation.py | 108 +++++++++++++++++++++++++++++++++++++- FofbTool/Utils.py | 2 +- 3 files changed, 130 insertions(+), 2 deletions(-) diff --git a/FofbTool/Configuration.py b/FofbTool/Configuration.py index da5fbbd..755e60c 100644 --- a/FofbTool/Configuration.py +++ b/FofbTool/Configuration.py @@ -158,6 +158,28 @@ def cellnode_configure_combpm(cellnodename, bpmallowed=None): logger.info("Configuration of ComBpm done on {}.".format(p)) return True +################################################################################################### +# CONFIGURE COM LBP +################################################################################################### + +def cellnode_configure_comlbp(cellnodename, bpmallowed=None): + """ + Configure the comlbp block of a CellNode. + For now, nothing done + + PARAMETERS + ---------- + cellnodename: str + The target cellnode, ie 'cellnode-c09' + + RETURN + ------ + success: boolean + True if configuration is a success + """ + + logger.info("Configuration of ComLBP done on {}.".format(p)) + return True ################################################################################################### # CONFIGURE CCN: COM CELLNODES diff --git a/FofbTool/Operation.py b/FofbTool/Operation.py index c759d9d..a5e86dc 100644 --- a/FofbTool/Operation.py +++ b/FofbTool/Operation.py @@ -21,6 +21,44 @@ logger = logging.getLogger("FofbTool") # OPERATIONS ON CCN ################################################################################################### +def align_ccn(nodename): + """ + Align FA sequence number on a cellnode + + PARAMETERS + ---------- + nodename: str + The target fofbnode, ie 'cellnode-c09' or 'centralnode' + """ + prx=FofbTool.Utils.get_prx_from_nodename(nodename) + if prx is None: + logger.error("Failed to align CCN on {}".format(nodename)) + return + + logger.debug("Latch two sequence numbers without offset") + for n in range(4): + prx["comlbp{}_seqoffset".format(n)]=0 + prx.ccnpack0_control=0 + time.sleep(2) + prx.ccnpack0_control=2 + time.sleep(1) + N=prx.ccnpack0_latchedseq2-prx.ccnpack0_latchedseq1 + + logger.debug("seq ({}, {}, {})".format(prx.ccnpack0_latchedseq2, prx.ccnpack0_latchedseq1, N)) + + if N in (-1, 0, 1): + logger.warning("Sequence offset measured = {}, something might be wrong".format(N)) + + # handle rollover + if N<0: + N+=65536 + if N>0x7FFF: + N=0xFFFF-N + + logger.info("Program sequence offset {} in {}".format(N, nodename)) + for n in range(4): + prx["comlbp{}_seqoffset".format(n)]=-N + def stop_ccn(nodename): """ Stop the communication with cellnode on the specified fofbnode. @@ -130,7 +168,7 @@ def ack_ccn(nodename): prx["ccnunpack{}_reset_error".format(n)] = False ################################################################################################### -# OPERATIONS ON CCN +# OPERATIONS ON COMBPM ################################################################################################### def stop_combpm(cellnodename): @@ -194,6 +232,74 @@ def ack_combpm(cellnodename): time.sleep(1) prx["combpm_reset_error"] = False +################################################################################################### +# OPERATIONS ON COMLBP +################################################################################################### + +def stop_comlbp(cellnodename): + """ + Stop the communication with LBP on the specified cellnode. + + PARAMETERS + ---------- + cellnodename: str + The target fofbnode, ie 'cellnode-c09' + + """ + prx=FofbTool.Utils.get_prx_from_nodename(cellnodename) + if prx is None: + logger.error("Failed to stop ComLBP on {}".format(p)) + return + + logger.info("Stopping ComLBP on {}".format(cellnodename)) + for n in range(4): + prx["comlbp{}_control".format(n)] = 0 + +def start_comlbp(cellnodename): + """ + Start the communication with LBP on the specified cellnode. + + PARAMETERS + ---------- + cellnodename: str + The target fofbnode, ie 'cellnode-c09' + + """ + prx=FofbTool.Utils.get_prx_from_nodename(cellnodename) + if prx is None: + logger.error("Failed to start ComLBP on {}".format(p)) + return + + logger.info("Starting ComLBP on {}".format(cellnodename)) + for n in range(4): + prx["comlbp{}_control".format(n)] = 0x10 + + +def reset_comlbp(cellnodename): + """ + Reset the communication with LBP on the specified cellnode. + + PARAMETERS + ---------- + cellnodename: str + The target fofbnode, ie 'cellnode-c09' + + """ + prx=FofbTool.Utils.get_prx_from_nodename(cellnodename) + if prx is None: + logger.error("Failed to reset ComLBP on {}".format(p)) + return + + logger.info("Reset ComLBP on {}".format(cellnodename)) + for n in range(4): + prx["comlbp{}_control".format(n)] = 0x3 + + time.sleep(1) + for n in range(4): + prx["comlbp{}_control".format(n)] = 0x0 + + + ################################################################################################### # OPERATIONS ON BPM ELECTRONICS ################################################################################################### diff --git a/FofbTool/Utils.py b/FofbTool/Utils.py index 0b7d875..ecf70df 100644 --- a/FofbTool/Utils.py +++ b/FofbTool/Utils.py @@ -272,7 +272,7 @@ def start_all_combpm(): def start_all_ccn(): """ - Apply stop and reset commands on all fofbnodes. + Apply start commands on all fofbnodes. """ -- GitLab