From b0307f2e07e72afd744ecb1889fd43f374da0a79 Mon Sep 17 00:00:00 2001 From: John Pickup Date: Wed, 21 Jun 2023 21:43:49 +0100 Subject: [PATCH] display errors --- lib/oven.py | 7 ++++++- lib/ovenDisplay.py | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/oven.py b/lib/oven.py index a215f76..22b9754 100644 --- a/lib/oven.py +++ b/lib/oven.py @@ -269,7 +269,6 @@ class Oven(threading.Thread): self.start_time = datetime.datetime.now() - datetime.timedelta(milliseconds = self.runtime * 1000) def update_runtime(self): - runtime_delta = datetime.datetime.now() - self.start_time if runtime_delta.total_seconds() < 0: runtime_delta = datetime.timedelta(0) @@ -578,6 +577,8 @@ class Profile(): return (prev_point, next_point) def get_target_temperature(self, time): + #log.info("time = " + str(time)) + #log.info("duration = " + str(self.get_duration())) if time > self.get_duration(): return 0 @@ -620,12 +621,15 @@ class PID(): output = 0 out4logs = 0 dErr = 0 + status = '' if error < (-1 * config.pid_control_window): + status = "kiln outside pid control window, max cooling" log.info("kiln outside pid control window, max cooling") output = 0 # it is possible to set self.iterm=0 here and also below # but I dont think its needed elif error > (1 * config.pid_control_window): + status = "kiln outside pid control window, max heating" log.info("kiln outside pid control window, max heating") output = 1 else: @@ -659,6 +663,7 @@ class PID(): 'kd': self.kd, 'pid': out4logs, 'out': output, + 'status': status, } return output diff --git a/lib/ovenDisplay.py b/lib/ovenDisplay.py index 5df4ed2..894e8f0 100644 --- a/lib/ovenDisplay.py +++ b/lib/ovenDisplay.py @@ -106,16 +106,20 @@ class OvenDisplay(threading.Thread): displayhatmini.set_led(1.0, 0.0, 0.0) else: displayhatmini.set_led(0.0, 0.0, 1.0) + message = '' if (oven_state['totaltime'] is not None and oven_state['runtime'] is not None): total_time = oven_state['totaltime'] run_time = oven_state['runtime'] time_left = total_time - run_time time_left_str = str(datetime.timedelta(seconds=round(time_left))) - self.text('Remaining: ' + time_left_str, (10, 195), fnt25, (255, 255, 255)) + message = 'Remaining: ' + time_left_str; + if (oven_state['pidstats'] is not None and oven_state['pidstats']['status'] is not None): + message = 'ERROR: ' + oven_state['pidstats']['status'] + self.text(message, (10, 195), fnt25, (255, 255, 255)) displayhatmini.display() def send(self,oven_state_json): - log.info(oven_state_json) + #log.info(oven_state_json) oven_state = json.loads(oven_state_json) self.update_display(oven_state)