Skip to content
Snippets Groups Projects
Commit 29032d7b authored by BRONES Romain's avatar BRONES Romain
Browse files

feat: Use FofbManager for synchronization

* This behave like the well known interface
* It add sync LBP before the first trigger
parent 15ea42a7
No related branches found
No related tags found
No related merge requests found
......@@ -505,19 +505,11 @@ def electron_stop_com(bpmlist):
def sync_all_bpm():
"""
Synchronize all BPM electronics, Electron and Brillance Plus.
This will use the timing system (central and local board).
This will use the FofbManager, but add sync on LiberaBrillancePlus before and sequence alignement after.
"""
EVN=66 # Event number
# Get FofbManager proxy, only for its properties
p = tango.DeviceProxy(FofbTool.Configuration.config["tangopath"]["fofb-manager"])
bpmlist = [n.split(':')[2] for n in p.get_property("bpmlist")['bpmlist']]
bpmidlist = [(int(n.split(':')[0]), n.split(':')[2]) for n in p.get_property("bpmlist")['bpmlist'] if 'LIBERA' in n]
tlocal = tango.Group('tlocal')
tlocal.add([n.split(':')[2] for n in p.get_property('TimingBoardList')['TimingBoardList'] if "LOCAL" in n])
# Get FofbManager proxy
FofbManager = tango.DeviceProxy(FofbTool.Configuration.config["tangopath"]["fofb-manager"])
# Set a group of Libera Brillance Plus EVRX board, from FofbTool configuration
lbpevrx = tango.Group('lbpevrx')
......@@ -526,26 +518,27 @@ def sync_all_bpm():
tcentral = tango.DeviceProxy(FofbTool.Configuration.config["tangopath"]["timing-central"])
# ---------------------------------------------------------------------------------------------------------------
# Init BPMs, stop first and put for each the ID number
# Step 1 : Init BPMs
logger.info("Configure Libera Electron with FofbManager")
electron_stop_com(bpmlist)
lastlog = FofbManager.logs[-1]
electron_init_fa(bpmidlist)
FofbManager.StartStep01ConfigLiberaCom() # Non blocking call, shame
# ---------------------------------------------------------------------------------------------------------------
# Write event number
# Wait for the logs to contain the magic words...
while True:
# Read the logs, crop to get only from the last log read
readlogs = FofbManager.logs
readlogs = readlogs[readlogs.index(lastlog):]
lastlog = readlogs[-1]
logger.info("Set Event Number on local timing board, BpmTriggerEvent")
r=tlocal.write_attribute("bpm.trigEvent", EVN)
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
if '[INFO] FOFB com. successfully configured on Libera bpms' in "".join(readlogs):
break
time.sleep(1)
# ---------------------------------------------------------------------------------------------------------------
# Prepare bpm for trigger reception
electron_sync_next_trigger(bpmlist)
# ---------------------------------------------------------------------------------------------------------------
# Step 2 : Synchronize bpm
logger.info("Prepare Libera Brillance Plus to start on next trigger")
r=lbpevrx.write_attribute("synchronize", 0)
......@@ -554,42 +547,36 @@ def sync_all_bpm():
logger.error("Failed to write synchronize on LBP EVRX {}".format(_r.dev_name()))
return
# ---------------------------------------------------------------------------------------------------------------
# Wait 2 seconds and Fire the soft event
time.sleep(2)
logger.info("Fire the trigger")
tcentral.write_attribute("softEventAdress", EVN)
tcentral.firesoftevent()
logger.info("Synchronize Libera Electron with FofbManager")
FofbManager.StartStep02SynchronizeLibera() # Non blocking call, shame
time.sleep(2)
# Wait for the logs to contain the magic words...
while True:
# Read the logs, crop to get only from the last log read
readlogs = FofbManager.logs
readlogs = readlogs[readlogs.index(lastlog):]
lastlog = readlogs[-1]
# ---------------------------------------------------------------------------------------------------------------
# Start electron on next trigger
if '[INFO] Libera bpms successfully triggered' in "".join(readlogs):
break
time.sleep(1)
electron_start_next_trigger(bpmlist)
# ---------------------------------------------------------------------------------------------------------------
# Wait 2 seconds and Fire the soft event
time.sleep(2)
logger.info("Fire the trigger")
tcentral.write_attribute("softEventAdress", EVN)
tcentral.firesoftevent()
time.sleep(2)
# Step 3 : Start communication
logger.info("Start Libera Electron with FofbManager")
FofbManager.StartStep03StartLiberaCom() # Non blocking call, shame
# ---------------------------------------------------------------------------------------------------------------
# Write event number back to 3
# Wait for the logs to contain the magic words...
while True:
# Read the logs, crop to get only from the last log read
readlogs = FofbManager.logs
readlogs = readlogs[readlogs.index(lastlog):]
lastlog = readlogs[-1]
logger.info("Set Event Number back to 3 on local timing board, BpmTriggerEvent")
r=tlocal.write_attribute("bpm.trigEvent", 3)
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
if '[INFO] FOFB com. successfully started on Libera bpms' in "".join(readlogs):
break
time.sleep(1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment