-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathiot_node.py
executable file
·42 lines (32 loc) · 1.02 KB
/
iot_node.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
#!/usr/bin/env python3
# Jari Torniainen <[email protected]>
# Andreas Henelius <[email protected]>,
# Finnish Institute of Occupational Health
# Copyright 2015
#
# This code is released under the MIT license
# http://opensource.org/licenses/mit-license.php
#
# Please see the file LICENSE for details
import sys
from midas.node import BaseNode
from midas import utilities as mu
import numpy
# IoT light-level processing node
class IoTNode(BaseNode):
def __init__(self, *args):
""" Initialize ECG node. """
super().__init__(*args)
# Append function handles to the metric_functions-list
self.metric_functions.append(self.mean_lightlevel)
def mean_lightlevel(self, x):
""" Get the mean light level of the specified time-window from the
sensor
"""
return numpy.mean(x['data'][0])
# Run the node from command line
if __name__ == '__main__':
node = mu.midas_parse_config(IoTNode, sys.argv)
if node:
node.start()
node.show_ui()