kopia lustrzana https://github.com/jamesgao/kiln_controller
Fixes to make new code work with actual device
rodzic
01149be0ce
commit
42af7b85aa
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import stepper
|
||||
import time
|
||||
import random
|
||||
|
@ -21,8 +22,8 @@ class TempLog(object):
|
|||
self.fname = os.path.join(paths.log_path, fname+suffix+".log")
|
||||
with open(self.fname, 'w') as fp:
|
||||
fp.write("time\ttemp\n")
|
||||
for time, temp in history:
|
||||
fp.write("%f\t%f\n"%(time, temp))
|
||||
for t, temp in history:
|
||||
fp.write("%f\t%f\n"%(t, temp))
|
||||
self.next = time.time() + interval
|
||||
self.interval = interval
|
||||
self._buffer = []
|
||||
|
@ -35,8 +36,8 @@ class TempLog(object):
|
|||
self._buffer.append(data)
|
||||
if time.time() > self.next:
|
||||
with open(self.fname, 'a') as fp:
|
||||
for time, temp in self._buffer:
|
||||
fp.write("%f\t%f\n"%(time, temp))
|
||||
for t, temp in self._buffer:
|
||||
fp.write("%f\t%f\n"%(t, temp))
|
||||
self._buffer = []
|
||||
self.next = time.time() + self.interval
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ class MainHandler(ManagerHandler):
|
|||
|
||||
class DataRequest(ManagerHandler):
|
||||
def get(self):
|
||||
self.set_header("Content-Type", "application/json")
|
||||
data = list(self.manager.history)
|
||||
output = [dict(time=ts.time, temp=ts.temp) for ts in data]
|
||||
self.write(json.dumps(output))
|
||||
|
@ -128,7 +129,7 @@ class WebApp(object):
|
|||
if __name__ == "__main__":
|
||||
try:
|
||||
import manager
|
||||
kiln = manager.Manager(simulate=True)
|
||||
kiln = manager.Manager(simulate=False)
|
||||
app = WebApp(kiln)
|
||||
kiln._send = app.send
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ class Breakout(object):
|
|||
|
||||
def get(self):
|
||||
time.sleep(.25)
|
||||
return self.device.temperature
|
||||
return tempsample(time.time(), self.device.temperature)
|
||||
|
||||
@property
|
||||
def temperature(self):
|
||||
|
@ -120,4 +120,4 @@ class Monitor(threading.Thread):
|
|||
|
||||
if __name__ == "__main__":
|
||||
monitor = Monitor()
|
||||
monitor.start()
|
||||
monitor.start()
|
||||
|
|
Ładowanie…
Reference in New Issue