forked from M-Labs/thermostat
PIDAutotuner: Don't use separate sig for interval
This commit is contained in:
parent
07687b4f74
commit
8eee78746e
|
@ -11,7 +11,6 @@ class PIDAutoTuner(QObject):
|
|||
|
||||
self._thermostat = thermostat
|
||||
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.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.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):
|
||||
getattr(self, params_name)[ch] = val
|
||||
|
||||
|
@ -50,11 +45,14 @@ class PIDAutoTuner(QObject):
|
|||
@asyncSlot(list)
|
||||
async def tick(self, 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
|
||||
if channel_report["temperature"] is None:
|
||||
continue
|
||||
|
||||
ch = channel_report["channel"]
|
||||
match self.autotuners[ch].state():
|
||||
case (
|
||||
PIDAutotuneState.STATE_READY
|
||||
|
|
|
@ -20,7 +20,6 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
|||
pid = Property(list)
|
||||
pwm = Property(list)
|
||||
postfilter = Property(list)
|
||||
interval = Property(list)
|
||||
report = Property(list)
|
||||
|
||||
connection_error = pyqtSignal()
|
||||
|
@ -78,9 +77,6 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
|||
self.pwm = await pwm_task
|
||||
if self._poll_for_report:
|
||||
self.report = await report_task
|
||||
self.interval = [
|
||||
self.report[i]["interval"] for i in range(len(self.report))
|
||||
]
|
||||
self.pid = await pid_task
|
||||
self.thermistor = await thermistor_task
|
||||
self.postfilter = await postfilter_task
|
||||
|
@ -110,9 +106,6 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
|||
async def report_mode(self):
|
||||
async for report in self._client.report_mode():
|
||||
self.report_update.emit(report)
|
||||
self.interval = [
|
||||
self.report[i]["interval"] for i in range(len(self.report))
|
||||
]
|
||||
|
||||
@asyncSlot()
|
||||
async def end_session(self):
|
||||
|
|
Loading…
Reference in New Issue