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

Refactor CCN operations

parent a5f7119e
No related branches found
No related tags found
No related merge requests found
......@@ -101,114 +101,134 @@ def align_ccn(node_tangopath, comlbpif=0):
return None
return seqoffset
def stop_ccn(nodename):
def stop_ccn(node_tangopath, ccnif=[]):
"""
Stop the communication with cellnode on the specified fofbnode.
PARAMETERS
----------
nodename: str
The target fofbnode, ie 'cellnode-c09' or 'centralnode'
node_tangopath: str
The target fofbnode tango path, ie 'ans/dg/fofb-cellnode-c09'
ccnif: list(int)
List of the interface to stop. If empty, all the possible interface will be stopped.
"""
prx=FofbTool.Utils.get_prx_from_nodename(nodename)
if prx is None:
logger.error("Failed to stop CCN on {}".format(nodename))
return
try:
prx=tango.DeviceProxy(node_tangopath)
prx.ping()
except tango.DevFailed:
logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath))
return None
if len(ccnif) == 0:
ccnif = [int(a[7]) for a in prx.get_attribute_list() if "ccnpack" in a if "control" in a]
logger.info("Stopping CCN on {}".format(nodename))
nint=1
if 'central' in nodename:
nint = 4
for n in range(nint):
logger.info("Stopping CCN on {}".format(node_tangopath))
for n in ccnif:
prx["ccnpack{}_control".format(n)] = False
prx["ccnunpack{}_control".format(n)] = False
def reset_ccn(nodename):
def reset_ccn(node_tangopath, ccnif=[]):
"""
Reset the communication with cellnode on the specified fofbnode.
PARAMETERS
----------
nodename: str
The target fofbnode, ie 'cellnode-c09' or 'centralnode'
node_tangopath: str
The target fofbnode tango path, ie 'ans/dg/fofb-cellnode-c09'
ccnif: list(int)
List of the interface to stop. If empty, all the possible interface will be stopped.
"""
prx=FofbTool.Utils.get_prx_from_nodename(nodename)
if prx is None:
logger.error("Failed to reset CCN on {}".format(nodename))
return
logger.info("Reset CCN on {}".format(nodename))
nint=1
if 'central' in nodename:
nint = 4
for n in range(nint):
try:
prx=tango.DeviceProxy(node_tangopath)
prx.ping()
except tango.DevFailed:
logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath))
return None
if len(ccnif) == 0:
ccnif = [int(a[6]) for a in prx.get_attribute_list() if "ccneth" in a if "gt_reset" in a]
logger.info("Reset CCN on {}".format(node_tangopath))
for n in ccnif:
prx["ccneth{}_reset".format(n)] = 0x60000001 # impossible to write 0xE0000001
prx["ccneth{}_gt_reset".format(n)] = 1
time.sleep(2)
for n in range(nint):
for n in ccnif:
prx["ccneth{}_gt_reset".format(n)] = 0
prx["ccneth{}_reset".format(n)] = 0
ack_ccn(nodename)
ack_ccn(node_tangopath, ccnif)
def start_ccn(nodename):
def start_ccn(node_tangopath, ccnif=[]):
"""
Start the communication with cellnode on the specified fofbnode.
PARAMETERS
----------
nodename: str
The target fofbnode, ie 'cellnode-c09' or 'centralnode'
node_tangopath: str
The target fofbnode tango path, ie 'ans/dg/fofb-cellnode-c09'
ccnif: list(int)
List of the interface to stop. If empty, all the possible interface will be stopped.
"""
prx=FofbTool.Utils.get_prx_from_nodename(nodename)
if prx is None:
logger.error("Failed to start CCN on {}".format(nodename))
return
try:
prx=tango.DeviceProxy(node_tangopath)
prx.ping()
except tango.DevFailed:
logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath))
return None
logger.info("Starting CCN on {}".format(nodename))
if len(ccnif) == 0:
ccnif = [int(a[7]) for a in prx.get_attribute_list() if "ccnpack" in a if "control" in a]
ack_ccn(nodename)
logger.info("Starting CCN on {}".format(node_tangopath))
nint=1
if 'central' in nodename:
nint = 4
for n in range(nint):
prx["ccnpack{}_control".format(n)] = True
prx["ccnunpack{}_control".format(n)] = True
ack_ccn(node_tangopath, ccnif)
def ack_ccn(nodename):
for n in ccnif:
prx["ccnpack{}_control".format(n)] = 1
prx["ccnunpack{}_control".format(n)] = 1
def ack_ccn(node_tangopath, ccnif=[]):
"""
Start the communication with cellnode on the specified fofbnode.
PARAMETERS
----------
nodename: str
The target fofbnode, ie 'cellnode-c09' or 'centralnode'
node_tangopath: str
The target fofbnode tango path, ie 'ans/dg/fofb-cellnode-c09'
ccnif: list(int)
List of the interface to stop. If empty, all the possible interface will be stopped.
"""
prx=FofbTool.Utils.get_prx_from_nodename(nodename)
if prx is None:
logger.error("Failed to ack CCN on {}".format(nodename))
return
try:
prx=tango.DeviceProxy(node_tangopath)
prx.ping()
except tango.DevFailed:
logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath))
return None
if len(ccnif) == 0:
ccnif = [int(a[7]) for a in prx.get_attribute_list() if "ccnpack" in a if "control" in a]
logger.info("Ack CCN error on {}".format(nodename))
nint=1
if 'central' in nodename:
nint = 4
for n in range(nint):
logger.info("Ack CCN error on {}".format(node_tangopath))
for n in ccnif:
prx["ccnpack{}_reset_error".format(n)] = True
prx["ccnunpack{}_reset_error".format(n)] = True
time.sleep(1)
for n in range(nint):
for n in ccnif:
prx["ccnpack{}_reset_error".format(n)] = False
prx["ccnunpack{}_reset_error".format(n)] = False
......
......@@ -276,8 +276,8 @@ def stop_all_ccn(force=False):
return
for n,p in FofbTool.Configuration.config["tangopath.fofbnodes"].items():
FofbTool.Operation.stop_ccn(n)
FofbTool.Operation.reset_ccn(n)
FofbTool.Operation.stop_ccn(p)
FofbTool.Operation.reset_ccn(p)
......@@ -313,7 +313,7 @@ def start_all_ccn():
"""
for n,p in FofbTool.Configuration.config["tangopath.fofbnodes"].items():
FofbTool.Operation.start_ccn(n)
FofbTool.Operation.start_ccn(p)
def align_all_ccn(cellnodename, force=False):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment