-
Notifications
You must be signed in to change notification settings - Fork 0
/
design_ideas.txt
60 lines (47 loc) · 2.76 KB
/
design_ideas.txt
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
Can collect from different kinds of sensors.
define different sensors as loadable classes
must have some kind of unique id
class must know how to find its "bus" to retrieve values
class can have their own sections in the config file for config data
Config file has section for sensors. Each sensor lists its type (class used) and ID.
A file object will load up all the sensor objects.
Define output files
what sensors go in the files?
What is the reporting interval
Virtual sensors/averages
Adjustments?
A sensor that is an average over the reporting interval?
An average is 12 samples over an interval (interval can be 1 hour, 15 minutes, 5 minutes, etc)
Differnt intervals, so:
All internal, so we use threads?
Somewhat external, so we use cron jobs.
Doesn't work for average values.
Will have to be threaded.
Different threads for different files...?
Each file will have to run a thread to collect not only the main sensors, but also the sensors that have to be averaged.
So each file object will spawn two threads: one for the interval collections, and one for average collections.
Threads must be queryable without stopping.
Threads must be able to shutdown cleanly with very short notice.
We want decent resolution, so threads would probably wake up every second and check what they're supposed to do
Would also enable quick shutdowns.
The file object would write the values to the file, so there would be no file contention.
Files and versioning
On startup, the file objects will have to check their files to make sure they match the column config they were given. If not, the current file will have to be renamed, and a new file created. The files will have backup extension, like logfile.log.1, with the number being *higher* the older the file is.
Alternative idea: Have two differnt kinds of rows in the data files. A "HEADER" row and a "DATA" row, allowing you to change column definitions on the fly. However, this would not be condusive to importing into a spreadsheet.
for datasource in datasources: LoopingCall(checkdata, datasource).start(60); then datasource.checkdata would have a thing: self.checkthedata().addCallback(self.done) and self.done would contain:for listener in self.listeners: listener.heyyouigotsomedata(data)
class SerialProtocol(LineReceiver):
def __init__(self):
self.d = None
def check(self):
self.sendLine("hey you, you serial port device, this is a wakeup call, gimme data now")
self.d = Deferred()
def lineReceived(self, line):
if self.d:
self.d.callback(self.parsedata(line))
self.d = None
def parsedata(self, line):
return line.split()
then you would do something like:
def igotthedatanow(data):
print data
sp.check().addCallback(igotthedatanow)