-
Notifications
You must be signed in to change notification settings - Fork 9
/
_SetupGroups.py
60 lines (50 loc) · 2.37 KB
/
_SetupGroups.py
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
#!/usr/bin/env python
#-----------------------------------------------------------------------------
# Title : PySMuRF Group Setup Utility
#-----------------------------------------------------------------------------
# File : _SmurfPublisher.py
# Created : 2019-10-31
#-----------------------------------------------------------------------------
# Description:
# Setup groups for variables & devices
#-----------------------------------------------------------------------------
# This file is part of the smurf software platform. It is subject to
# the license terms in the LICENSE.txt file found in the top-level directory
# of this distribution and at:
# https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
# No part of the smurf software platform, including this file, may be
# copied, modified, propagated, or distributed except according to the terms
# contained in the LICENSE.txt file.
#-----------------------------------------------------------------------------
import pyrogue
def setupGroups(root, VariableGroups):
"""
Set variable groups.
Args
----
VariableGroups : dict
Each entry must have the form '<Rogue device or Variable>' : {'groups' : [<list of groups>], 'pollInterval': <poll interval> }
The 'groups' entry provides a list of groups to add the
Device/Variable to. If the path points to a device, the group
will be added recursively to all devices and variables deeper
in the path. The 'pollInterval' entry provides an optional
value which will be used to update the polling interface if
the path points to a variable. The poll interval value is in
seconds. Use None to leave interval unchanged, 0 to disable
polling. If this argument is 'None' then nothing will be
done.
"""
if VariableGroups:
for k,v in VariableGroups.items():
# Get node
n = root.getNode(k)
# Did we find the node?
if n is not None:
# Add to each group
for grp in v['groups']:
n.addToGroup(grp)
# Update poll interval if provided.
if v['pollInterval'] is not None and n.isinstance(pyrogue.BaseVariable):
n.pollInterval = v['pollInterval']
else:
print(f"setupGroups: Warning: {k} not found!")