- changed time step to one sec in config

- added sleep for simulations to accurately reflect a real run
This commit is contained in:
jbruce 2018-11-22 09:48:22 -05:00
parent e2ae5eac65
commit 3cc7c4a11b
3 changed files with 15 additions and 10 deletions

View File

@ -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
########################################################################

View File

@ -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":

View File

@ -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: