-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnode_funcs.py
More file actions
42 lines (32 loc) · 1.12 KB
/
node_funcs.py
File metadata and controls
42 lines (32 loc) · 1.12 KB
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
#
# Common functions used by nodes
try:
import polyinterface
except ImportError:
import pgc_interface as polyinterface
LOGGER = polyinterface.LOGGER
def add_functions_as_methods(functions):
def decorator(Class):
for function in functions:
setattr(Class, function.__name__, function)
return Class
return decorator
# Wrap all the setDriver calls so that we can check that the
# value exist first.
def update_driver(self, driver, value, force=False, prec=3):
try:
self.setDriver(driver, round(float(value), prec), True, force, self.uom[driver])
LOGGER.debug('setDriver (%s, %f)' %(driver, float(value)))
except:
LOGGER.warning('Missing data for driver ' + driver)
def get_saved_log_level(self):
if 'customData' in self.polyConfig:
if 'level' in self.polyConfig['customData']:
return self.polyConfig['customData']['level']
return 0
def save_log_level(self, level):
level_data = {
'level': level,
}
self.poly.saveCustomData(level_data)
functions = (update_driver, get_saved_log_level, save_log_level)