kopia lustrzana https://github.com/jbruce12000/kiln-controller
Fixes to picoreflowd and change to localhost in index.html
rodzic
332dca18f3
commit
cd2065dd4e
|
|
@ -1 +1,8 @@
|
|||
*.pyc
|
||||
*~
|
||||
\#*
|
||||
.#*
|
||||
*.swp
|
||||
.DStore/
|
||||
thumbs.db
|
||||
|
||||
|
|
|
|||
|
|
@ -4,3 +4,10 @@ picoReflow
|
|||
Turns a Raspberry Pi into a universal, web enabled Reflow Oven Controller.
|
||||
|
||||
Based on MAX 31855 Cold-Junction K-Type Thermocouple and Raspberry Pi GPIO driven Solid State Relays.
|
||||
|
||||
|
||||
Python Requirements:
|
||||
|
||||
- dev-python/bottle
|
||||
- dev-python/gevent
|
||||
- dev-python/gevent-websocket
|
||||
|
|
|
|||
|
|
@ -12,24 +12,37 @@ oven.start()
|
|||
wsocks = []
|
||||
wsocks_control = []
|
||||
|
||||
def notifyAll(message):
|
||||
message_json = json.dumps(message)
|
||||
print "sending to %d clients: %s"%(len(wsocks),message_json)
|
||||
for wsock in wsocks:
|
||||
if wsock:
|
||||
try:
|
||||
wsock.send(message_json)
|
||||
except:
|
||||
print "Could not write to socket!"
|
||||
wsocks.remove(wsock)
|
||||
else:
|
||||
wsocks.remove(wsock)
|
||||
|
||||
class OvenWatcher(threading.Thread):
|
||||
def __init__(self,oven):
|
||||
threading.Thread.__init__(self)
|
||||
self.oven = oven
|
||||
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
oven_state = self.oven.get_state()
|
||||
notifyAll(oven_state)
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
ovenWatcher = OvenWatcher(oven)
|
||||
ovenWatcher.start()
|
||||
|
||||
@app.route('/run')
|
||||
def start_oven():
|
||||
oven.run_profile("abc")
|
||||
|
||||
|
||||
return "Starting"
|
||||
|
||||
@app.route('/control')
|
||||
|
|
@ -39,7 +52,7 @@ def handle_control():
|
|||
wsock = env.get('wsgi.websocket')
|
||||
if not wsock:
|
||||
abort(400, 'Expected WebSocket request.')
|
||||
|
||||
|
||||
wsocks_control.append(wsock)
|
||||
while True:
|
||||
try:
|
||||
|
|
@ -53,7 +66,7 @@ def handle_control():
|
|||
oven.abort_run()
|
||||
except WebSocketError:
|
||||
break
|
||||
|
||||
|
||||
|
||||
@app.route('/status')
|
||||
def handle_websocket():
|
||||
|
|
@ -62,7 +75,7 @@ def handle_websocket():
|
|||
wsock = env.get('wsgi.websocket')
|
||||
if not wsock:
|
||||
abort(400, 'Expected WebSocket request.')
|
||||
|
||||
|
||||
wsocks.append(wsock)
|
||||
while True:
|
||||
try:
|
||||
|
|
@ -71,18 +84,7 @@ def handle_websocket():
|
|||
except WebSocketError:
|
||||
break
|
||||
|
||||
def notifyAll(message):
|
||||
message_json = json.dumps(message)
|
||||
print "sending to %d clients: %s"%(len(wsocks),message_json)
|
||||
for wsock in wsocks:
|
||||
if wsock:
|
||||
try:
|
||||
wsock.send(message_json)
|
||||
except:
|
||||
print "Could not write to socket!"
|
||||
wsocks.remove(wsock)
|
||||
else:
|
||||
wsocks.remove(wsock)
|
||||
|
||||
def main():
|
||||
server = WSGIServer(("0.0.0.0", 8080), app,
|
||||
handler_class=WebSocketHandler)
|
||||
|
|
|
|||
|
|
@ -177,8 +177,8 @@ function updateProgress(percentage){
|
|||
}
|
||||
|
||||
|
||||
var s = new WebSocket("ws://10.1.1.110:8080/status");
|
||||
var c = new WebSocket("ws://10.1.1.110:8080/control");
|
||||
var s = new WebSocket("ws://localhost:8080/status");
|
||||
var c = new WebSocket("ws://localhost:8080/control");
|
||||
|
||||
|
||||
c.onmessage = function(e)
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue