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

Merge branch sync LBP without FofbManager

* We do not use FofbManager anymore for sync
parents dedd63d8 f32b2594
No related branches found
No related tags found
No related merge requests found
...@@ -44,19 +44,19 @@ def align_ccn(nodename): ...@@ -44,19 +44,19 @@ def align_ccn(nodename):
# Loop until two consecutives identical measures # Loop until two consecutives identical measures
N=[7,3] N=[7,3]
while N[-2] != N[-1]: 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") logger.debug("Latch two sequence numbers without offset")
prx.ccnpack0_control=1 # let it roll a bit to collect data 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 prx.ccnpack0_control=2 # latch it
time.sleep(2) time.sleep(2)
N.append(prx.ccnpack0_latchedseq1-prx.ccnpack0_latchedseq2) N.append(prx.ccnpack0_latchedseq1-prx.ccnpack0_latchedseq2)
logger.debug("seq ({}, {}, {})".format(prx.ccnpack0_latchedseq1, prx.ccnpack0_latchedseq2, N[-1])) 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] N=N[-1]
...@@ -505,38 +505,46 @@ def electron_stop_com(bpmlist): ...@@ -505,38 +505,46 @@ def electron_stop_com(bpmlist):
def sync_all_bpm(): def sync_all_bpm():
""" """
Synchronize all BPM electronics, Electron and Brillance Plus. Synchronize all BPM electronics, Electron and Brillance Plus.
This will use the FofbManager, but add sync on LiberaBrillancePlus before and sequence alignement after. This will use the timing system (central and local board).
""" """
# Get FofbManager proxy EVN=240 # Event number
FofbManager = tango.DeviceProxy(FofbTool.Configuration.config["tangopath"]["fofb-manager"])
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])
# Set a group of Libera Brillance Plus EVRX board, from FofbTool configuration # Set a group of Libera Brillance Plus EVRX board, from FofbTool configuration
lbpevrx = tango.Group('lbpevrx') lbpevrx = tango.Group('lbpevrx')
lbpevrx.add(FofbTool.Configuration.config["tangopath"]["lbpevrx"].split()) lbpevrx.add(FofbTool.Configuration.config["tangopath"]["lbpevrx"].split())
# --------------------------------------------------------------------------------------------------------------- tcentral = tango.DeviceProxy(FofbTool.Configuration.config["tangopath"]["timing-central"])
# Step 1 : Init BPMs
logger.info("Configure Libera Electron with FofbManager")
lastlog = FofbManager.logs[-1] # ---------------------------------------------------------------------------------------------------------------
# Init BPMs, stop first and put for each the ID number
FofbManager.StartStep01ConfigLiberaCom() # Non blocking call, shame electron_stop_com(bpmlist)
# Wait for the logs to contain the magic words... electron_init_fa(bpmidlist)
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]
if '[INFO] FOFB com. successfully configured on Libera bpms' in "".join(readlogs): # ---------------------------------------------------------------------------------------------------------------
break # Write event number
time.sleep(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
# --------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------
# Step 2 : Synchronize bpm # Prepare bpm for trigger reception
electron_sync_next_trigger(bpmlist)
logger.info("Prepare Libera Brillance Plus to start on next trigger") logger.info("Prepare Libera Brillance Plus to start on next trigger")
r=lbpevrx.write_attribute("synchronize", 0) r=lbpevrx.write_attribute("synchronize", 0)
...@@ -545,36 +553,42 @@ def sync_all_bpm(): ...@@ -545,36 +553,42 @@ def sync_all_bpm():
logger.error("Failed to write synchronize on LBP EVRX {}".format(_r.dev_name())) logger.error("Failed to write synchronize on LBP EVRX {}".format(_r.dev_name()))
return return
logger.info("Synchronize Libera Electron with FofbManager") # ---------------------------------------------------------------------------------------------------------------
FofbManager.StartStep02SynchronizeLibera() # Non blocking call, shame # Wait 2 seconds and Fire the soft event
# Wait for the logs to contain the magic words... time.sleep(2)
while True: logger.info("Fire the trigger")
# Read the logs, crop to get only from the last log read
readlogs = FofbManager.logs
readlogs = readlogs[readlogs.index(lastlog):]
lastlog = readlogs[-1]
if '[INFO] Libera bpms successfully triggered' in "".join(readlogs): tcentral.write_attribute("softEventAdress", EVN)
break tcentral.firesoftevent()
time.sleep(1)
time.sleep(2)
# --------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------
# Step 3 : Start communication # Start electron on next trigger
logger.info("Start Libera Electron with FofbManager") electron_start_next_trigger(bpmlist)
FofbManager.StartStep03StartLiberaCom() # Non blocking call, shame
# Wait for the logs to contain the magic words... # ---------------------------------------------------------------------------------------------------------------
while True: # Wait 2 seconds and Fire the soft event
# Read the logs, crop to get only from the last log read
readlogs = FofbManager.logs
readlogs = readlogs[readlogs.index(lastlog):]
lastlog = readlogs[-1]
if '[INFO] FOFB com. successfully started on Libera bpms' in "".join(readlogs): time.sleep(2)
break logger.info("Fire the trigger")
time.sleep(1)
tcentral.write_attribute("softEventAdress", EVN)
tcentral.firesoftevent()
time.sleep(2)
# ---------------------------------------------------------------------------------------------------------------
# Write event number back to 3
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment