diff --git a/brewpi.py b/brewpi.py index 13bc6ca..e1337ce 100755 --- a/brewpi.py +++ b/brewpi.py @@ -26,8 +26,6 @@ if __name__ == '__main__': # Plant pot_params = config['Plant'] pot = Pot(DT, pot_params, 20) - if "sim" in config['Controller']['sensor_name']: - pot.set_on_changed("temp", ChangedFloat(sensor.set_fake_temp, prec=3).set) taskmgr.add(PotTask(pot, DT_TASK, dispatcher.msgio_get("Pot"))) # Heater @@ -39,10 +37,8 @@ if __name__ == '__main__': # Temperature Controller tc_params = config['TempCtrl'] tc = PidFactory.create(config['Controller']['pid_type'], DT, tc_params) - tc.set_on_changed("y", heater_task.actor) tc_task = TcTask(tc, DT_TASK, dispatcher.msgio_get("TempCtrl")) taskmgr.add(tc_task) - sensor.set_on_changed("temp", ChangedFloat(tc.set_theta_ist, prec=2).set) # Stirrer stirrer = StirrerFactory.create(config['Controller']['stirrer_name'], DT, config['Stirrer']) @@ -52,6 +48,13 @@ if __name__ == '__main__': # Tracer taskmgr.add(TracerTask(sensor, heater, tc, DT_TASK, dispatcher.msgio_get("Tracer"))) + # Assign data flow + tc.set_on_changed("y", heater_task.actor) + sensor.set_on_changed("temp", ChangedFloat(tc.set_theta_ist, prec=2).set) + if "sim" in config['Controller']['sensor_name']: + pot.set_on_changed("temp", ChangedFloat(sensor.set_fake_temp, prec=3).set) + sensor.set_fake_temp(pot.temp) + # Message dispatcher h_dispatcher = taskmgr.start() h_server = server.listen("0.0.0.0", 8765) diff --git a/components/pid/temp_controller.py b/components/pid/temp_controller.py index 5b9eb64..f40b61a 100644 --- a/components/pid/temp_controller.py +++ b/components/pid/temp_controller.py @@ -17,7 +17,7 @@ class TempController(APid): APid.__init__(self) self.pid_hold = Pid(dt) self.pid_rate = Pid(dt) - self.theta_ist_set = 20 + self.theta_ist_set = 0 self.theta_soll_set = 0 self.heatrate_ist_set = 0 self.heatrate_soll_set = 1.0 diff --git a/components/pid/temp_controller_smith.py b/components/pid/temp_controller_smith.py index 3c0f932..7f275c9 100644 --- a/components/pid/temp_controller_smith.py +++ b/components/pid/temp_controller_smith.py @@ -17,7 +17,7 @@ class TempController(APid): APid.__init__(self) self.pid_hold = Pid(dt) self.pid_rate = Pid(dt) - self.theta_ist_set = 20 + self.theta_ist_set = 0 self.theta_soll_set = 0 self.heatrate_ist_set = 0 self.heatrate_soll_set = 1.0 diff --git a/components/plant/pot.py b/components/plant/pot.py index 48e423f..2c00b2a 100644 --- a/components/plant/pot.py +++ b/components/plant/pot.py @@ -16,7 +16,7 @@ class Pot(APlant): self.L = params['L'] self.Td = params['Td'] self.kn = params['kn'] - self.temp = 0 + self.temp = params['theta'] self.temp_intermediate = params['theta'] self.theta_amb = theta_amb