Newer
Older
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import re
# =============================================================================
# The following attributes will be populated when first needed.
# =============================================================================
# List of attributes tangopath in TDB
TDBLIST = []
# List of attributes tangopath in TDB
HDBLIST = []
# List of tango devices
DEVLIST = []
###############################################################################
## USEFULL FUNCTION
###############################################################################
def searchattr(prx, attr, ignorecase=True):
"""
Search in a tango device proxy for an attribute name.
PARAMETERS
----------
prx: tango.DeviceProxy
Proxy to the device.
attr: string
String to search for.
ignorecase: bool
Case insensitive.
"""
if ignorecase:
return [a for a in prx.get_attribute_list() if attr.lower() in a.lower()]
else:
return [a for a in prx.get_attribute_list() if attr in a]
def searcharch(attr, db, ignorecase=True):
"""
Search for an attribute in the archiver list.
PARAMETERS
----------
attr: string
String to search for.
db: string
Which database, "H", "T"
ignorecase: bool
Case insensitive.
RETURNS
-------
"""
global ARCHLIST
if ARCHLIST is None:
# Populate archlist
ARCHLIST=dict()
for db in "HT":
ARCHLIST[db] = tango.DeviceProxy("archiving/{}dbextractor/1".format(db)).getcurrentarchivedatt()
if ignorecase:
return [a for a in ARCHLIST[db] if attr.lower() in a.lower()]
else:
return [a for a in prx.get_attribute_list() if attr in a]
###############################################################################
## POPULATE ATTRIBUTE FUNCTIONS
###############################################################################
# =============================================================================
def populate_tdblist():
"""
Fill the global list of TDB archived attributes.
"""
global TDBLIST
TDBLIST= tango.DeviceProxy("archiving/tdbextractor/1").getcurrentarchivedatt()
# =============================================================================
def populate_hdblist():
"""
Fill the global list of HDB archived attributes.
"""
global HDBLIST
HDBLIST= tango.DeviceProxy("archiving/hdbextractor/1").getcurrentarchivedatt()
# =============================================================================
def populate_devlist():
"""
Fill the global list of devices.
"""
DB = tango.Database()
for domain in DB.get_device_domain("*"):
for family in DB.get_device_family(domain+"/*"):
for member in DB.get_device_member(domain+"/"+family+"/*"):
DEVLIST.append(domain+"/"+family+"/"+member)
# =============================================================================
def populate_devlist2():
"""
Fill the global list of devices.
"""
DB = tango.Database()
DEVLIST = [dev for dev in DB.get_device_exported("*")]