From b3ba5772681acd8c72e4651bcd1b72d561874e7b Mon Sep 17 00:00:00 2001 From: atse Date: Mon, 9 Sep 2024 12:45:16 +0800 Subject: [PATCH] Remove report mode from thermostat data model --- pytec/pytec/gui/model/thermostat.py | 37 +++-------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/pytec/pytec/gui/model/thermostat.py b/pytec/pytec/gui/model/thermostat.py index 26f3aca..9566a0b 100644 --- a/pytec/pytec/gui/model/thermostat.py +++ b/pytec/pytec/gui/model/thermostat.py @@ -31,8 +31,6 @@ class Thermostat(QObject, metaclass=PropertyMeta): self._update_s = update_s self._client = AsyncioClient() self._watch_task = None - self._report_mode_task = None - self._poll_for_report = True self._update_params_task = None self.disconnect_cb = disconnect_cb super().__init__(parent) @@ -62,15 +60,8 @@ class Thermostat(QObject, metaclass=PropertyMeta): await asyncio.sleep(self._update_s) async def update_params(self): - if self._poll_for_report: - ( - self.fan, - self.pwm, - self.report, - self.pid, - self.thermistor, - self.postfilter, - ) = await asyncio.gather( + self.fan, self.pwm, self.report, self.pid, self.thermistor, self.postfilter = ( + await asyncio.gather( self._client.get_fan(), self._client.get_pwm(), self._client.report(), @@ -78,16 +69,7 @@ class Thermostat(QObject, metaclass=PropertyMeta): self._client.get_steinhart_hart(), self._client.get_postfilter(), ) - else: - self.fan, self.pwm, self.pid, self.thermistor, self.postfilter = ( - await asyncio.gather( - self._client.get_fan(), - self._client.get_pwm(), - self._client.get_pid(), - self._client.get_steinhart_hart(), - self._client.get_postfilter(), - ) - ) + ) def connected(self): return self._client.connected() @@ -98,26 +80,13 @@ class Thermostat(QObject, metaclass=PropertyMeta): @asyncSlot() async def stop_watching(self): if self._watch_task is not None: - await self.set_report_mode(False) self._watch_task.cancel() self._watch_task = None self._update_params_task.cancel() self._update_params_task = None - async def set_report_mode(self, enabled: bool): - self._poll_for_report = not enabled - if enabled: - self._report_mode_task = asyncio.create_task(self.report_mode()) - else: - self._client.stop_report_mode() - - async def report_mode(self): - async for report in self._client.report_mode(): - self.report_update.emit(report) - @asyncSlot() async def end_session(self): - await self.set_report_mode(False) self.stop_watching() if self.disconnect_cb is not None: