Line 67... |
Line 67... |
67 |
|
67 |
|
68 |
try: |
68 |
try: |
69 |
before = time.time()-interval |
69 |
before = time.time()-interval |
70 |
while True: |
70 |
while True: |
71 |
|
71 |
|
72 |
filename = path + time.strftime("%Y%m%d%H", time.gmtime()) +"_"+ stationName + "_data.csv" |
72 |
filename = path + time.strftime("%Y%m%d%H", time.gmtime()) +"0000_"+ stationName + "_data.csv" |
73 |
now = time.time() |
73 |
now = time.time() |
74 |
|
74 |
|
75 |
if (now - before >= interval - 2.5): # 0.5*5 channels= 2.5s |
75 |
if (now - before >= interval - 2.5): # 0.5*5 channels= 2.5s |
76 |
with open(filename, "a") as f: |
76 |
with open(filename, "a") as f: |
77 |
|
77 |
|
Line 96... |
Line 96... |
96 |
channel5 = sensor2.readCurrent(); |
96 |
channel5 = sensor2.readCurrent(); |
97 |
|
97 |
|
98 |
|
98 |
|
99 |
sys.stdout.write("%s \t %0.3f \t %0.3f \t %0.3f \t %0.3f \t %0.3f \n" % (datetime.datetime.now().isoformat(), channel1, channel2, channel3, channel4, channel5)) |
99 |
sys.stdout.write("%s \t %0.3f \t %0.3f \t %0.3f \t %0.3f \t %0.3f \n" % (datetime.datetime.now().isoformat(), channel1, channel2, channel3, channel4, channel5)) |
100 |
|
100 |
|
101 |
f.write("%d\t%0.3f\t%0.3f\t%0.3f\t%0.3f\t%0.3f\n" % (time.time(), channel1, channel2, channel3, channel4, channel5)) |
101 |
f.write("%d;%0.3f;%0.3f;%0.3f;%0.3f;%0.3f\n" % (time.time(), channel1, channel2, channel3, channel4, channel5)) |
102 |
f.flush() |
102 |
f.flush() |
103 |
|
103 |
|
104 |
sys.stdout.flush() |
104 |
sys.stdout.flush() |
105 |
before = time.time() |
105 |
before = time.time() |
106 |
else: |
106 |
else: |