-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrateTest.py
More file actions
38 lines (30 loc) · 1.11 KB
/
rateTest.py
File metadata and controls
38 lines (30 loc) · 1.11 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
#"module" is not the final name for this interface
#every data generating device (camera, microphone, thermometer)
#should have its own module class which implements setup and
#poll functions
import random
import time
#dummy class representing a generic sensor, not required
class exampleSensor():
def read_data(self):
data = [random.randint(0, 9999) for i in range(0, 10)]
return data
class exampleModule():
module_name = "example" #put the name of your sensor/project here
sensor = None
polling_interval = .5 #time between polls in seconds
last_poll = time.monotonic()
def __init__(self):
print(f"instance of {self.module_name} created")
def setup(self):
self.sensor = exampleSensor()
#don't need to modify this
def wrap_poll(self):
if ((time.monotonic() - self.last_poll) > self.polling_interval):
self.last_poll = time.monotonic()
self.polling_interval = self.polling_interval/2
return self.poll()
return None
def poll(self):
print(self.polling_interval)
return self.polling_interval