add pause and resume to api

pull/186/head
jbruce12000 2024-06-30 11:44:45 -04:00
rodzic 8c9d3881dc
commit df7ee9e234
4 zmienionych plików z 30 dodań i 7 usunięć

Wyświetl plik

@ -18,3 +18,11 @@ post a memo
stats for currently running schedule
curl -X GET http://0.0.0.0:8081/api/stats
pause a run (maintain current temperature until resume)
curl -d '{"cmd":"pause"}' -H "Content-Type: application/json" -X POST http://0.0.0.0:8081/api
resume a paused run
curl -d '{"cmd":"resume"}' -H "Content-Type: application/json" -X POST http://0.0.0.0:8081/api

Wyświetl plik

@ -84,6 +84,14 @@ def handle_api():
oven.run_profile(profile, startat=startat, allow_seek=allow_seek)
ovenWatcher.record(profile)
if bottle.request.json['cmd'] == 'pause':
log.info("api pause command received")
oven.state = 'PAUSED'
if bottle.request.json['cmd'] == 'resume':
log.info("api resume command received")
oven.state = 'RUNNING'
if bottle.request.json['cmd'] == 'stop':
log.info("api stop command received")
oven.abort_run()

Wyświetl plik

@ -541,6 +541,14 @@ class Oven(threading.Thread):
self.automatic_restart()
time.sleep(1)
continue
if self.state == "PAUSED":
self.start_time = self.get_start_time()
self.update_runtime()
self.update_target_temp()
self.heat_then_cool()
self.reset_if_emergency()
self.reset_if_schedule_ended()
continue
if self.state == "RUNNING":
self.update_cost()
self.save_automatic_restart_state()
@ -806,7 +814,7 @@ class PID():
log.info("kiln outside pid control window, max heating")
output = 1
if config.throttle_below_temp and config.throttle_percent:
if ispoint <= config.throttle_below_temp:
if setpoint <= config.throttle_below_temp:
output = config.throttle_percent/100
log.info("max heating throttled at %d percent below %d degrees to prevent overshoot" % (config.throttle_percent,config.throttle_below_temp))
else:

Wyświetl plik

@ -502,9 +502,6 @@ $(document).ready(function()
ws_status.onmessage = function(e)
{
console.log("received status data")
console.log(e.data);
x = JSON.parse(e.data);
if (x.type == "backlog")
{
@ -528,11 +525,11 @@ $(document).ready(function()
if(state!="EDIT")
{
state = x.state;
if (state!=state_last)
{
if(state_last == "RUNNING")
if(state_last == "RUNNING" && state != "PAUSED" )
{
console.log(state);
$('#target_temp').html('---');
updateProgress(0);
$.bootstrapGrowl("<span class=\"glyphicon glyphicon-exclamation-sign\"></span> <b>Run completed</b>", {
@ -579,7 +576,9 @@ $(document).ready(function()
if (heat_rate > 9999) { heat_rate = 9999; }
if (heat_rate < -9999) { heat_rate = -9999; }
$('#heat_rate').html(heat_rate);
$('#heat').html('<div class="bar" style="height:'+x.pidstats.out*70+'%;"></div>')
if (typeof x.pidstats !== 'undefined') {
$('#heat').html('<div class="bar" style="height:'+x.pidstats.out*70+'%;"></div>')
}
if (x.cool > 0.5) { $('#cool').addClass("ds-led-cool-active"); } else { $('#cool').removeClass("ds-led-cool-active"); }
if (x.air > 0.5) { $('#air').addClass("ds-led-air-active"); } else { $('#air').removeClass("ds-led-air-active"); }
if (x.temperature > hazardTemp()) { $('#hazard').addClass("ds-led-hazard-active"); } else { $('#hazard').removeClass("ds-led-hazard-active"); }