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

refactor comlbp operation

parent 8f5461cd
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,6 @@ import tango ...@@ -10,7 +10,6 @@ import tango
import logging import logging
import numpy as np import numpy as np
import time import time
import FofbTool.Utils
# Get the module logger # Get the module logger
...@@ -315,64 +314,70 @@ def ack_combpm(node_tangopath): ...@@ -315,64 +314,70 @@ def ack_combpm(node_tangopath):
# OPERATIONS ON COMLBP # OPERATIONS ON COMLBP
################################################################################################### ###################################################################################################
def stop_comlbp(cellnodename): def stop_comlbp(node_tangopath):
""" """
Stop the communication with LBP on the specified cellnode. Stop the communication with LBP on the specified cellnode.
PARAMETERS PARAMETERS
---------- ----------
cellnodename: str node_tangopath: str
The target fofbnode, ie 'cellnode-c09' The target fofbnode tango path, ie 'ans/dg/fofb-cellnode-c09'
""" """
prx=FofbTool.Utils.get_prx_from_nodename(cellnodename) try:
if prx is None: prx=tango.DeviceProxy(node_tangopath)
logger.error("Failed to stop ComLBP on {}".format(p)) prx.ping()
return except tango.DevFailed:
logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath))
return None
logger.info("Stopping ComLBP on {}".format(cellnodename)) logger.info("Stopping ComLBP on {}".format(node_tangopath))
for n in range(4): for n in range(4):
prx["comlbp{}_control".format(n)] = 1 prx["comlbp{}_control".format(n)] = 1
time.sleep(1) time.sleep(1)
for n in range(4): for n in range(4):
prx["comlbp{}_control".format(n)] = 0 prx["comlbp{}_control".format(n)] = 0
def start_comlbp(cellnodename): def start_comlbp(node_tangopath):
""" """
Start the communication with LBP on the specified cellnode. Start the communication with LBP on the specified cellnode.
PARAMETERS PARAMETERS
---------- ----------
cellnodename: str node_tangopath: str
The target fofbnode, ie 'cellnode-c09' The target fofbnode tango path, ie 'ans/dg/fofb-cellnode-c09'
""" """
prx=FofbTool.Utils.get_prx_from_nodename(cellnodename) try:
if prx is None: prx=tango.DeviceProxy(node_tangopath)
logger.error("Failed to start ComLBP on {}".format(p)) prx.ping()
return except tango.DevFailed:
logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath))
return None
logger.info("Starting ComLBP on {}".format(cellnodename)) logger.info("Starting ComLBP on {}".format(node_tangopath))
for n in range(4): for n in range(4):
prx["comlbp{}_control".format(n)] = 0x10 prx["comlbp{}_control".format(n)] = 0x10
def reset_comlbp(cellnodename): def reset_comlbp(node_tangopath):
""" """
Reset the communication with LBP on the specified cellnode. Reset the communication with LBP on the specified cellnode.
PARAMETERS PARAMETERS
---------- ----------
cellnodename: str node_tangopath: str
The target fofbnode, ie 'cellnode-c09' The target fofbnode tango path, ie 'ans/dg/fofb-cellnode-c09'
""" """
prx=FofbTool.Utils.get_prx_from_nodename(cellnodename) try:
if prx is None: prx=tango.DeviceProxy(node_tangopath)
logger.error("Failed to reset ComLBP on {}".format(p)) prx.ping()
return except tango.DevFailed:
logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath))
return None
logger.info("Reset ComLBP on {}".format(cellnodename)) logger.info("Reset ComLBP on {}".format(node_tangopath))
for n in range(4): for n in range(4):
prx["comlbp{}_control".format(n)] = 0x3 prx["comlbp{}_control".format(n)] = 0x3
......
...@@ -258,8 +258,8 @@ def stop_all_comlbp(force=False): ...@@ -258,8 +258,8 @@ def stop_all_comlbp(force=False):
for n,p in FofbTool.Configuration.config["tangopath.fofbnodes"].items(): for n,p in FofbTool.Configuration.config["tangopath.fofbnodes"].items():
if 'cellnode' in n: if 'cellnode' in n:
try: try:
FofbTool.Operation.reset_comlbp(n) FofbTool.Operation.reset_comlbp(p)
FofbTool.Operation.stop_comlbp(n) FofbTool.Operation.stop_comlbp(p)
except (tango.DevFailed, TypeError): except (tango.DevFailed, TypeError):
logger.error("Could not stop cpmlbp on {}".format(n)) logger.error("Could not stop cpmlbp on {}".format(n))
...@@ -300,7 +300,7 @@ def start_all_comlbp(): ...@@ -300,7 +300,7 @@ def start_all_comlbp():
for n,p in FofbTool.Configuration.config["tangopath.fofbnodes"].items(): for n,p in FofbTool.Configuration.config["tangopath.fofbnodes"].items():
if 'cellnode' in n: if 'cellnode' in n:
try: try:
FofbTool.Operation.start_comlbp(n) FofbTool.Operation.start_comlbp(p)
except (tango.DevFailed, TypeError): except (tango.DevFailed, TypeError):
logger.error("Could not start LBP on {}".format(n)) logger.error("Could not start LBP on {}".format(n))
......
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