-
Notifications
You must be signed in to change notification settings - Fork 10
/
testCSVConfig.py
69 lines (50 loc) · 1.65 KB
/
testCSVConfig.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
61
62
63
64
65
66
import csv, sys
print sys.platform
print sys.copyright
print ">>>"
print sys.version
# print sys.path
# print sys.modules
print "--------------------------------------------"
class Sensors():
sensors = []
def __init__(self):
self.sensors = []
def __init__(self, f):
if f:
self.readconfig(f)
def find(self, sensornum)
for sensor in self.sensors:
if sensor.sensornum = sensornum:
return sensor
sensor = Sensor(sensornum)
self.sensors.append(sensor)
return history
def readconfig(self, f)
configReader = csv.reader(open('sensorconfig.csv', 'rb'))
for row in configReader:
sensornum = row[0]
sensor = self.find(sensornum)
sensor.desc = row[1]
sensor.xid = row[2]
sensor.tlogkey = row[3]
sensor.plogkey = row[4]
sensor.pchmin = row[5]
sensor.pchmax = row[6]
def __str__(self):
s = ""
for sensor in self.sensors:
s += sensor.__str__()
return s
class Sensor():
#id, desc, xid, tlogkey, plogkey, pchmin, pchmax
sensorid = 0
desc = ""
xid = 0
tlogkey = ""
plogkey = ""
pchmin = ""
pchmax = ""
def __str__(self):
return "[ id#: %d, 5mintimer: %f, lasttime; %f, 5minwatthr: %f, daywatthr = %f]" % (self.sensornum, self.fiveminutetimer, self.lasttime, self.cumulative5mwatthr, self.dayswatthr)
return "[ id#: %d, desc: %f, lasttime: %f, 5minwatthr: %f, daywatthr = %f]" % (self.sensornum, self.fiveminutetimer, self.lasttime, self.cumulative5mwatthr, self.dayswatthr)