Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
###################################################################################################
# Utilities
###################################################################################################
#
# This file contains usefull function and attributes to simplify life
#
###################################################################################################
import tango
import logging
import DeviceAttributeConfiguration
# Get the module logger
logger = logging.getLogger("FofbTool")
tangopath_nodes = {
"centralnode":"ans/dg/fofb-centralnode",
"cellnode-c01":"ans/dg/fofb-cellnode-c01",
"cellnode-c06":"ans/dg/fofb-cellnode-c06",
"cellnode-c09":"ans/dg/fofb-cellnode-c09",
"cellnode-c14":"ans/dg/fofb-cellnode-c14",
}
tangopath = {
"fofb-watcher":"ans/dg/fofb-watcher",
"fofb-command":"ans/dg/fofb-command",
"fofb-manager":"ans/dg/fofb-manager",
"bpm-manager":"ans/dg/bpm-manager",
}.update(tangopath_nodes)
def init_opcua():
"""
Run init on all OPCUA devices. Catch DevFailed and inform via log.
"""
for i,(n,p) in enumerate(tangopath_nodes.items()):
logger.info("Perform init() on {} '{}'".format(n,p))
try:
tango.DeviceProxy(p).init()
except tango.DevFailed as e:
logger.error("Could not perform init() '{}', got DevFailed.".format(p))
logger.debug(str(e))
def init_watcher():
"""
Run init on Fofb-Watcher, waiting for its completion then init on the FofbCommand.
"""
wprx=tango.DeviceProxy(tangopath["fofb-watcher"])
wprx.set_timeout_millis(30000)
logger.info("Perform init() on Fofb-Watcher. This takes nearly a minute.")
try:
wprx.init()
except tango.DevFailed as e:
logger.error("Could not perform init() on Fofb-Watcher.")
logger.info("Perform init() on Fofb-Command.")
tango.DeviceProxy(tangopath["fofb-command"]).init()
def confds_opcua():
"""
Apply attribute configuration on all OPCUA devices. Catch DevFailed and inform via log.
"""
for i,(n,p) in enumerate(tangopath_nodes.items()):
try:
prx = tango.DeviceProxy(p)
except tango.DevFailed as e:
logger.error("Could not get proxy '{}', got DevFailed.".format(p))
logger.debug(str(e))
break
try:
if 'central' in n:
DeviceAttributeConfiguration.set_attr_config_centralnode(prx)
else:
DeviceAttributeConfiguration.set_attr_config_cellnode(prx)
except tango.DevFailed as e:
logger.error("Could not set attribute configuration for '{}', got DevFailed.".format(p))
logger.debug(str(e))