forked from M-Labs/thermostat
Fix Autotuner state for forceful disconnect
This commit is contained in:
parent
5475bf7951
commit
52ee422a70
@ -35,6 +35,7 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
|||||||
self._report_mode_task = None
|
self._report_mode_task = None
|
||||||
self._poll_for_report = True
|
self._poll_for_report = True
|
||||||
self._update_params_task = None
|
self._update_params_task = None
|
||||||
|
self.connection_errored = False
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
async def run(self):
|
async def run(self):
|
||||||
@ -51,6 +52,10 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
|||||||
self._update_params_task = asyncio.create_task(self.update_params())
|
self._update_params_task = asyncio.create_task(self.update_params())
|
||||||
await asyncio.sleep(self._update_s)
|
await asyncio.sleep(self._update_s)
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
|
def timed_out(self):
|
||||||
|
self.connection_errored = True
|
||||||
|
|
||||||
async def get_hw_rev(self):
|
async def get_hw_rev(self):
|
||||||
self.hw_rev = await self._client.hw_rev()
|
self.hw_rev = await self._client.hw_rev()
|
||||||
return self.hw_rev
|
return self.hw_rev
|
||||||
@ -101,6 +106,7 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
|||||||
|
|
||||||
async def end_session(self):
|
async def end_session(self):
|
||||||
await self._client.end_session()
|
await self._client.end_session()
|
||||||
|
self.connection_errored = False
|
||||||
|
|
||||||
async def set_ipv4(self, ipv4):
|
async def set_ipv4(self, ipv4):
|
||||||
await self._client.set_param("ipv4", ipv4)
|
await self._client.set_param("ipv4", ipv4)
|
||||||
|
@ -78,6 +78,9 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
self, self.client, self.report_refresh_spin.value()
|
self, self.client, self.report_refresh_spin.value()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.client.connection_error.connect(self.thermostat.timed_out)
|
||||||
|
self.client.connection_error.connect(self.bail)
|
||||||
|
|
||||||
self.autotuners = PIDAutoTuner(self, self.client, 2)
|
self.autotuners = PIDAutoTuner(self, self.client, 2)
|
||||||
|
|
||||||
def get_ctrl_panel_config(args):
|
def get_ctrl_panel_config(args):
|
||||||
@ -197,9 +200,12 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
self.thermostat_ctrl_menu.fan_pwm_warning.setToolTip("")
|
self.thermostat_ctrl_menu.fan_pwm_warning.setToolTip("")
|
||||||
self.clear_graphs()
|
self.clear_graphs()
|
||||||
self.report_box.setChecked(False)
|
self.report_box.setChecked(False)
|
||||||
if not Thermostat.connecting or Thermostat.connected:
|
|
||||||
for ch in range(self.NUM_CHANNELS):
|
for ch in range(self.NUM_CHANNELS):
|
||||||
if self.autotuners.get_state(ch) != PIDAutotuneState.STATE_OFF:
|
if self.autotuners.get_state(ch) != PIDAutotuneState.STATE_OFF:
|
||||||
|
if self.thermostat.connection_errored:
|
||||||
|
# Don't send any commands, just reset local state
|
||||||
|
self.autotuners.autotuners[ch].setOff()
|
||||||
|
else:
|
||||||
await self.autotuners.stop_pid_from_running(ch)
|
await self.autotuners.stop_pid_from_running(ch)
|
||||||
await self.thermostat.set_report_mode(False)
|
await self.thermostat.set_report_mode(False)
|
||||||
self.thermostat.stop_watching()
|
self.thermostat.stop_watching()
|
||||||
|
Loading…
Reference in New Issue
Block a user