From 32909f153b55abfd7b158ce2a9bc07bcc5d7ac91 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Romain=20BRON=C3=88S?= <romain.brones@synchrotron-soleil.fr>
Date: Mon, 24 Jun 2024 15:02:51 +0200
Subject: [PATCH] fix(align): Add random wait for align

* This avoid sampling twice at a not proper time
* Also change evetn number for synchro
---
 FofbTool/Operation.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/FofbTool/Operation.py b/FofbTool/Operation.py
index 510600c..922588a 100644
--- a/FofbTool/Operation.py
+++ b/FofbTool/Operation.py
@@ -44,19 +44,19 @@ def align_ccn(nodename):
     # Loop until two consecutives identical measures
     N=[7,3]
     while N[-2] != N[-1]:
+        if len(N) > 7:
+            logger.error("Could not measure sequence offset.")
+            return False
+
         logger.debug("Latch two sequence numbers without offset")
         prx.ccnpack0_control=1 # let it roll a bit to collect data
-        time.sleep(2)
+        time.sleep(2+np.random.uniform())
         prx.ccnpack0_control=2 # latch it
         time.sleep(2)
         N.append(prx.ccnpack0_latchedseq1-prx.ccnpack0_latchedseq2)
 
         logger.debug("seq ({}, {}, {})".format(prx.ccnpack0_latchedseq1, prx.ccnpack0_latchedseq2, N[-1]))
 
-        if len(N) > 5:
-            logger.error("Could not measure sequence offset.")
-            return False
-
 
     N=N[-1]
 
@@ -508,7 +508,7 @@ def sync_all_bpm():
     This will use the timing system (central and local board).
 
     """
-    EVN=66 # Event number
+    EVN=240 # Event number
 
     # Get FofbManager proxy, only for its properties
     p = tango.DeviceProxy(FofbTool.Configuration.config["tangopath"]["fofb-manager"])
-- 
GitLab