From 3cc7c4a11b97a8d8d0ecc9693c3fdf66a718bbea Mon Sep 17 00:00:00 2001 From: jbruce Date: Thu, 22 Nov 2018 09:48:22 -0500 Subject: [PATCH] - changed time step to one sec in config - added sleep for simulations to accurately reflect a real run --- config.py | 2 +- kiln-controller.py | 14 +++++++------- lib/oven.py | 9 +++++++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/config.py b/config.py index 355a98e..6a7974d 100644 --- a/config.py +++ b/config.py @@ -52,7 +52,7 @@ gpio_sensor_data = 17 spi_sensor_chip_id = 0 ### amount of time, in seconds, to wait between reads of the thermocouple -sensor_time_wait = .5 +sensor_time_wait = 1 ######################################################################## diff --git a/kiln-controller.py b/kiln-controller.py index ae9aa59..2bf1338 100755 --- a/kiln-controller.py +++ b/kiln-controller.py @@ -74,13 +74,13 @@ def handle_control(): ovenWatcher.record(profile) elif msgdict.get("cmd") == "SIMULATE": log.info("SIMULATE command received") - profile_obj = msgdict.get('profile') - if profile_obj: - profile_json = json.dumps(profile_obj) - profile = Profile(profile_json) - simulated_oven = Oven(simulate=True, time_step=0.05) - simulation_watcher = OvenWatcher(simulated_oven) - simulation_watcher.add_observer(wsock) + #profile_obj = msgdict.get('profile') + #if profile_obj: + # profile_json = json.dumps(profile_obj) + # profile = Profile(profile_json) + #simulated_oven = Oven(simulate=True, time_step=0.05) + #simulation_watcher = OvenWatcher(simulated_oven) + #simulation_watcher.add_observer(wsock) #simulated_oven.run_profile(profile) #simulation_watcher.record(profile) elif msgdict.get("cmd") == "STOP": diff --git a/lib/oven.py b/lib/oven.py index 0456d7a..43f0f85 100644 --- a/lib/oven.py +++ b/lib/oven.py @@ -64,7 +64,9 @@ class Oven (threading.Thread): self.time_step = time_step self.reset() if simulate: - self.temp_sensor = TempSensorSimulate(self, 0.5, self.time_step) + self.temp_sensor = TempSensorSimulate(self, + self.time_step, + self.time_step) if sensor_available: self.temp_sensor = TempSensorReal(self.time_step) else: @@ -161,7 +163,10 @@ class Oven (threading.Thread): else: GPIO.output(config.gpio_heat, GPIO.HIGH) time.sleep(self.time_step * value) - GPIO.output(config.gpio_heat, GPIO.LOW) + GPIO.output(config.gpio_heat, GPIO.LOW) + else: + #for runs that are simulations + time.sleep(self.time_step * value) else: self.heat = 0.0 if gpio_available: