From 81f2a37aaee579c4f90f2c241718444d1eda6a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Balzarotti?= Date: Tue, 21 Feb 2023 14:02:07 +0100 Subject: [PATCH] live reload recipe/actuator changes --- app.py | 13 ++++++++++++- dist/server.js | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 87e3bdf..8f2c551 100644 --- a/app.py +++ b/app.py @@ -131,10 +131,21 @@ def run_recipes(): sleep(1) def read_sensors(): + periodi_counter = 0 + scantime = 0.5 + periodic_state_every_s = 5 + periodic_state_every_loop = int(periodic_state_every_s/scantime) while True: sensors.read() socketio.emit('sensors', (sensors.get(),)) - sleep(0.5) + if periodic_counter % periodic_state_every == 0: + ## peridoic refresh other data, too, like: + # - current phase (time in this phase) + # - actuators (consumption) + # Issuing a full state update is easiest + updateState() + periodi_counter += 1 + sleep(scantime) import threading if __name__ == '__main__': diff --git a/dist/server.js b/dist/server.js index 4ec4202..1835e53 100644 --- a/dist/server.js +++ b/dist/server.js @@ -284,6 +284,10 @@ function dismiss_modal() { applyState(state); } +function reload_recipes() { + socket.emit('reload recipes'); +} + function render_load_recipe(data) { let html = document.getElementById("load-recipe"); if (html === null) return;