PIDAutotuner: Don't use separate sig for interval

This commit is contained in:
atse 2024-08-30 11:51:25 +08:00
parent 2e0ecd9758
commit ba6b24fe95
2 changed files with 4 additions and 13 deletions

View File

@ -11,7 +11,6 @@ class PIDAutoTuner(QObject):
self._thermostat = thermostat self._thermostat = thermostat
self._thermostat.report_update.connect(self.tick) self._thermostat.report_update.connect(self.tick)
self._thermostat.interval_update.connect(self.update_sampling_interval)
self.autotuners = [PIDAutotune(25) for _ in range(num_of_channel)] self.autotuners = [PIDAutotune(25) for _ in range(num_of_channel)]
self.target_temp = [20.0 for _ in range(num_of_channel)] self.target_temp = [20.0 for _ in range(num_of_channel)]
@ -20,10 +19,6 @@ class PIDAutoTuner(QObject):
self.lookback = [3.0 for _ in range(num_of_channel)] self.lookback = [3.0 for _ in range(num_of_channel)]
self.sampling_interval = [1 / 16.67 for _ in range(num_of_channel)] self.sampling_interval = [1 / 16.67 for _ in range(num_of_channel)]
@pyqtSlot(list)
def update_sampling_interval(self, interval):
self.sampling_interval = interval
def set_params(self, params_name, ch, val): def set_params(self, params_name, ch, val):
getattr(self, params_name)[ch] = val getattr(self, params_name)[ch] = val
@ -50,11 +45,14 @@ class PIDAutoTuner(QObject):
@asyncSlot(list) @asyncSlot(list)
async def tick(self, report): async def tick(self, report):
for channel_report in report: for channel_report in report:
ch = channel_report["channel"]
self.sampling_interval[ch] = channel_report["interval"]
# TODO: Skip when PID Autotune or emit error message if NTC is not connected # TODO: Skip when PID Autotune or emit error message if NTC is not connected
if channel_report["temperature"] is None: if channel_report["temperature"] is None:
continue continue
ch = channel_report["channel"]
match self.autotuners[ch].state(): match self.autotuners[ch].state():
case ( case (
PIDAutotuneState.STATE_READY PIDAutotuneState.STATE_READY

View File

@ -20,7 +20,6 @@ class Thermostat(QObject, metaclass=PropertyMeta):
pid = Property(list) pid = Property(list)
pwm = Property(list) pwm = Property(list)
postfilter = Property(list) postfilter = Property(list)
interval = Property(list)
report = Property(list) report = Property(list)
connection_error = pyqtSignal() connection_error = pyqtSignal()
@ -78,9 +77,6 @@ class Thermostat(QObject, metaclass=PropertyMeta):
self.pwm = await pwm_task self.pwm = await pwm_task
if self._poll_for_report: if self._poll_for_report:
self.report = await report_task self.report = await report_task
self.interval = [
self.report[i]["interval"] for i in range(len(self.report))
]
self.pid = await pid_task self.pid = await pid_task
self.thermistor = await thermistor_task self.thermistor = await thermistor_task
self.postfilter = await postfilter_task self.postfilter = await postfilter_task
@ -110,9 +106,6 @@ class Thermostat(QObject, metaclass=PropertyMeta):
async def report_mode(self): async def report_mode(self):
async for report in self._client.report_mode(): async for report in self._client.report_mode():
self.report_update.emit(report) self.report_update.emit(report)
self.interval = [
self.report[i]["interval"] for i in range(len(self.report))
]
@asyncSlot() @asyncSlot()
async def end_session(self): async def end_session(self):