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