From 78c4a33d1c6c56a6d32f0d05aebfad558b1182f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Romain=20BRON=C3=88S?= <romain.brones@synchrotron-soleil.fr>
Date: Wed, 14 Aug 2024 14:50:30 +0200
Subject: [PATCH] Sync operation now return a boolean

---
 FofbTool/Operation.py | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/FofbTool/Operation.py b/FofbTool/Operation.py
index 6e95e90..90c811d 100644
--- a/FofbTool/Operation.py
+++ b/FofbTool/Operation.py
@@ -567,7 +567,7 @@ def sync_bpm(bpmidlist, lbpevrx, timinglocal, timingcentral):
     bpmidlist: list of tuple
         list of tuple (ID, tangopath) to put on Libera Electron
     lbpevrx: list
-        list of LBP Evrx tango path
+        list of LBP Evrx tango path. Can be an empty array.
     timinglocal: list
         list of Timing local itango path to set event
     timingcentral: str
@@ -590,9 +590,11 @@ def sync_bpm(bpmidlist, lbpevrx, timinglocal, timingcentral):
     # ---------------------------------------------------------------------------------------------------------------
     # Init BPMs, stop first and put for each the ID number
 
-    electron_stop_com(bpmlist)
+    if not electron_stop_com(bpmlist):
+        return False
 
-    electron_init_fa(bpmidlist)
+    if not electron_init_fa(bpmidlist):
+        return False
 
     # ---------------------------------------------------------------------------------------------------------------
     # Write event number
@@ -602,19 +604,20 @@ def sync_bpm(bpmidlist, lbpevrx, timinglocal, timingcentral):
     for _r in r:
         if _r.has_failed():
             logger.error("Failed to set Event Number on local timing board {}, bpm.trigEvent".format(_r.dev_name()))
-            return
+            return False
 
     # ---------------------------------------------------------------------------------------------------------------
     # Prepare bpm for trigger reception
 
-    electron_sync_next_trigger(bpmlist)
+    if not electron_sync_next_trigger(bpmlist):
+        return False
 
     logger.info("Prepare Libera Brillance Plus to start on next trigger")
     r=glbpevrx.write_attribute("synchronize", 0)
     for _r in r:
         if _r.has_failed():
             logger.error("Failed to write synchronize on LBP EVRX {}".format(_r.dev_name()))
-            return
+            return False
 
     # ---------------------------------------------------------------------------------------------------------------
     # Wait 2 seconds and Fire the soft event
@@ -630,7 +633,8 @@ def sync_bpm(bpmidlist, lbpevrx, timinglocal, timingcentral):
     # ---------------------------------------------------------------------------------------------------------------
     # Start electron on next trigger
 
-    electron_start_next_trigger(bpmlist)
+    if not electron_start_next_trigger(bpmlist):
+        return False
 
     # ---------------------------------------------------------------------------------------------------------------
     # Wait 2 seconds and Fire the soft event
@@ -652,6 +656,6 @@ def sync_bpm(bpmidlist, lbpevrx, timinglocal, timingcentral):
     for _r in r:
         if _r.has_failed():
             logger.error("Failed to set Event Number on local timing board {}, bpm.trigEvent".format(_r.dev_name()))
-            return
-
+            return False
 
+    return True
-- 
GitLab