From e29f363ed8d5f340b0acac36ced41f1313e9c825 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Romain=20BRON=C3=88S?= <romain.brones@synchrotron-soleil.fr>
Date: Wed, 7 Aug 2024 14:18:05 +0200
Subject: [PATCH] Fix Operation sync argument

* Use only one list of tuple (BPMID, BPMPATH )
* Pass tango path and not groups or deviceproxy
---
 FofbTool/Operation.py | 29 +++++++++++++++++++----------
 FofbTool/Utils.py     | 12 ++++--------
 2 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/FofbTool/Operation.py b/FofbTool/Operation.py
index 7ee96f7..c1abb47 100644
--- a/FofbTool/Operation.py
+++ b/FofbTool/Operation.py
@@ -556,26 +556,35 @@ def electron_stop_com(bpmlist):
 #    OPERATIONS FOR LBP and Electron SYNCHRONIZATION
 ###################################################################################################
 
-def sync_bpm(bpmlist, bpmidlist, lbpevrx, tlocal, tcentral):
+def sync_bpm(bpmidlist, lbpevrx, timinglocal, timingcentral):
     """
     Synchronize all BPM electronics, Electron and Brillance Plus.
     This will use the timing system (central and local board).
 
     PARAMETERS:
     -----------
-    bpmlist: list
-        list of Libera Electron tango path
-    bpmidlist: list
-        list of ID to put on Libera Electron
+    bpmidlist: list of tuple
+        list of tuple (ID, tangopath) to put on Libera Electron
     lbpevrx: list
-        list of LBP Evrx tanfo path
-    tlocal: list
-        list of Timing local board to set event
-    tcentral: str
+        list of LBP Evrx tango path
+    timinglocal: list
+        list of Timing local itango path to set event
+    timingcentral: str
         Tango path of timing central
 
     """
     EVN=240 # Event number
+    bpmlist = [b[1] for b in bpmidlist]
+
+
+    tlocal = tango.Group('tlocal')
+    tlocal.add(timinglocal)
+
+    tcentral = tango.DeviceProxy(timingcentral)
+
+    glbpevrx = tango.Group('lbpevrx')
+    glbpevrx.add(lbpevrx)
+
 
     # ---------------------------------------------------------------------------------------------------------------
     # Init BPMs, stop first and put for each the ID number
@@ -600,7 +609,7 @@ def sync_bpm(bpmlist, bpmidlist, lbpevrx, tlocal, tcentral):
     electron_sync_next_trigger(bpmlist)
 
     logger.info("Prepare Libera Brillance Plus to start on next trigger")
-    r=lbpevrx.write_attribute("synchronize", 0)
+    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()))
diff --git a/FofbTool/Utils.py b/FofbTool/Utils.py
index c43e87d..1d5b6c9 100644
--- a/FofbTool/Utils.py
+++ b/FofbTool/Utils.py
@@ -460,17 +460,13 @@ def sync_all_bpm():
 
     db = tango.Database()
 
-    bpmlist = [n.split(':')[2] for n in db.get_property("FOFB", "bpmlist")['bpmlist'] if ":LIBERA:" in n]
     bpmidlist = [(int(n.split(':')[0]), n.split(':')[2]) for n in db.get_property("FOFB", "bpmlist")['bpmlist'] if 'LIBERA' in n]
 
-    tlocal = tango.Group('tlocal')
-    tlocal.add([n.split(':')[2] for n in db.get_property("FOFB", 'TimingBoardList')['TimingBoardList'] if "LOCAL" in n])
+    tlocal = [n.split(':')[2] for n in db.get_property("FOFB", 'TimingBoardList')['TimingBoardList'] if "LOCAL" in n]
 
-    # Set a group of Libera Brillance Plus EVRX board, from FofbTool configuration
-    lbpevrx = tango.Group('lbpevrx')
-    lbpevrx.add(config["tangopath"]["lbpevrx"].split())
+    lbpevrx = config["tangopath"]["lbpevrx"].split()
 
-    tcentral = tango.DeviceProxy(config["tangopath"]["timing-central"])
+    tcentral = config["tangopath"]["timing-central"]
 
-    FofbTool.Operation.sync_bpm(bpmlist, bpmidlist, lbpevrx, tlocal, tcentral)
+    FofbTool.Operation.sync_bpm(bpmidlist, lbpevrx, tlocal, tcentral)
 
-- 
GitLab