Remove TracerTask
Its brewpi.mat output had no consumer - the GUI never subscribed to the 'Tracer' channel, and SudLogTask's run-scoped JSON logs now cover the same sensor/heater/tc data for actual analysis. Drop the task, its DT_TASK_TRACER interval, and the wiring in server/brewpi.py. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DkkuG48uHFCGKe6dPSERFk
This commit is contained in:
+1
-5
@@ -13,7 +13,7 @@ from components.plant import Pot
|
|||||||
from components.actor import HeaterFactory, StirrerFactory
|
from components.actor import HeaterFactory, StirrerFactory
|
||||||
from components.sud import Sud
|
from components.sud import Sud
|
||||||
from components.sud_forecast import SudForecastEstimator
|
from components.sud_forecast import SudForecastEstimator
|
||||||
from tasks import TaskManager, TempSensorTask, HeaterTask, PotTask, TcTask, StirrerTask, TracerTask, SudTask, SudLogTask
|
from tasks import TaskManager, TempSensorTask, HeaterTask, PotTask, TcTask, StirrerTask, SudTask, SudLogTask
|
||||||
|
|
||||||
import argparse as ap
|
import argparse as ap
|
||||||
|
|
||||||
@@ -67,7 +67,6 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
DT = config['Controller']['dt']
|
DT = config['Controller']['dt']
|
||||||
DT_TASK = 1.0 / config['Controller']['sim_warp_factor']
|
DT_TASK = 1.0 / config['Controller']['sim_warp_factor']
|
||||||
DT_TASK_TRACER = DT_TASK / DT
|
|
||||||
theta_amb = config['ambient_temperature']
|
theta_amb = config['ambient_temperature']
|
||||||
plant_sim = "sim" in config['Controller']['plant_name']
|
plant_sim = "sim" in config['Controller']['plant_name']
|
||||||
|
|
||||||
@@ -111,9 +110,6 @@ if __name__ == '__main__':
|
|||||||
# tasks/sud_log.py.
|
# tasks/sud_log.py.
|
||||||
taskmgr.add(SudLogTask(sud, tc, heater, heater_task, sud_task, DT_TASK))
|
taskmgr.add(SudLogTask(sud, tc, heater, heater_task, sud_task, DT_TASK))
|
||||||
|
|
||||||
# Tracer
|
|
||||||
taskmgr.add(TracerTask(sensor, heater, tc, DT_TASK_TRACER, dispatcher.msgio_get("Tracer")))
|
|
||||||
|
|
||||||
# Assign data flow
|
# Assign data flow
|
||||||
# Assign tc control value to heater
|
# Assign tc control value to heater
|
||||||
tc.set_on_changed("y", heater_task.actor)
|
tc.set_on_changed("y", heater_task.actor)
|
||||||
|
|||||||
@@ -4,6 +4,5 @@ from tasks.heater import *
|
|||||||
from tasks.stirrer import *
|
from tasks.stirrer import *
|
||||||
from tasks.pot import *
|
from tasks.pot import *
|
||||||
from tasks.tempctrl import *
|
from tasks.tempctrl import *
|
||||||
from tasks.tracer import *
|
|
||||||
from tasks.sud import *
|
from tasks.sud import *
|
||||||
from tasks.sud_log import *
|
from tasks.sud_log import *
|
||||||
|
|||||||
+4
-3
@@ -21,9 +21,10 @@ class SudLogTask(ATask):
|
|||||||
power_eff - see client/brewpi_gui.py's PlotCanvas.sample()), plus
|
power_eff - see client/brewpi_gui.py's PlotCanvas.sample()), plus
|
||||||
the forecast curve it's compared against (tasks/sud.py's SudTask.
|
the forecast curve it's compared against (tasks/sud.py's SudTask.
|
||||||
forecast_t/forecast_theta), for the whole duration of a Sud run -
|
forecast_t/forecast_theta), for the whole duration of a Sud run -
|
||||||
for later offline analysis. One pair of JSON files per run, not the
|
for later offline analysis. One pair of JSON files per run, scoped
|
||||||
ever-growing, continuously-rewritten .mat tasks/tracer.py's
|
to that run alone - unlike a continuously-rewritten trace file that
|
||||||
TracerTask already produces independently of any Sud run.
|
keeps growing independently of whether a Sud run is even in
|
||||||
|
progress.
|
||||||
|
|
||||||
A fresh, uniquely-named pair of logs starts the moment a run
|
A fresh, uniquely-named pair of logs starts the moment a run
|
||||||
actually starts (Sud.state leaves IDLE/DONE) and is written out
|
actually starts (Sud.state leaves IDLE/DONE) and is written out
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
import time
|
|
||||||
import asyncio
|
|
||||||
from tasks import ATask
|
|
||||||
from ws.message import MsgIo
|
|
||||||
from components import ATemperatureSensor
|
|
||||||
from components import AHeater
|
|
||||||
from components import APid
|
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
import scipy.io
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
class TracerTask(ATask):
|
|
||||||
def __init__(self, sensor: ATemperatureSensor, heater: AHeater, temp_ctrl: APid, interval, msg_handler: MsgIo, path= './logs'):
|
|
||||||
ATask.__init__(self, interval)
|
|
||||||
if not os.path.exists(path):
|
|
||||||
os.makedirs(path)
|
|
||||||
|
|
||||||
self.msg_handler = msg_handler
|
|
||||||
msg_handler.set_recv_handler(self.recv)
|
|
||||||
|
|
||||||
self.sensor = sensor
|
|
||||||
self.heater = heater
|
|
||||||
self.temp_ctrl = temp_ctrl
|
|
||||||
self.path = path
|
|
||||||
|
|
||||||
async def recv(self, data):
|
|
||||||
pass
|
|
||||||
|
|
||||||
async def send(self, data):
|
|
||||||
await self.msg_handler.send(data)
|
|
||||||
|
|
||||||
async def on_process(self):
|
|
||||||
print("{}: Started with interval {} s".format(self.msg_handler.get_key(), self.interval))
|
|
||||||
|
|
||||||
timestamp = 0
|
|
||||||
_timestamp = np.empty(0)
|
|
||||||
_sensor_temp = np.empty(0)
|
|
||||||
_heater_power = np.empty(0)
|
|
||||||
_tc_temp_ist = np.empty(0)
|
|
||||||
_tc_dtemp_ist = np.empty(0)
|
|
||||||
_tc_temp_soll = np.empty(0)
|
|
||||||
_tc_dtemp_soll = np.empty(0)
|
|
||||||
_tc_dtemp_commanded = np.empty(0)
|
|
||||||
|
|
||||||
name = 'brewpi'
|
|
||||||
filename = os.path.join(self.path, '') + name + ".mat"
|
|
||||||
filename_full = os.path.join(self.path, '') + name + "." + time.strftime("%Y%m%d%H%M%S", time.localtime()) + ".mat"
|
|
||||||
|
|
||||||
while True:
|
|
||||||
_timestamp = np.append(_timestamp, timestamp)
|
|
||||||
_sensor_temp = np.append(_sensor_temp, self.sensor.temperature())
|
|
||||||
_heater_power = np.append(_heater_power, self.heater.get_power())
|
|
||||||
_tc_temp_ist = np.append(_tc_temp_ist, self.temp_ctrl.theta_ist)
|
|
||||||
_tc_dtemp_ist = np.append(_tc_dtemp_ist, max(-1, self.temp_ctrl.heatrate_ist))
|
|
||||||
_tc_temp_soll = np.append(_tc_temp_soll, self.temp_ctrl.theta_soll_set)
|
|
||||||
_tc_dtemp_soll = np.append(_tc_dtemp_soll, self.temp_ctrl.heatrate_soll_set)
|
|
||||||
_tc_dtemp_commanded = np.append(_tc_dtemp_commanded, self.temp_ctrl.heatrate_soll)
|
|
||||||
|
|
||||||
data = {'time': _timestamp, 'sensor_temp': _sensor_temp, 'heater_power': _heater_power, 'tc_temp_ist': _tc_temp_ist, 'tc_dtemp_ist': _tc_dtemp_ist, 'tc_temp_soll': _tc_temp_soll, 'tc_dtemp_soll': _tc_dtemp_soll, 'tc_dtemp_commanded': _tc_dtemp_commanded}
|
|
||||||
|
|
||||||
scipy.io.savemat(filename, data)
|
|
||||||
scipy.io.savemat(filename_full, data)
|
|
||||||
timestamp += 1
|
|
||||||
await asyncio.sleep(self.interval)
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user