forked from M-Labs/thermostat
Fix Autotuner state for forceful disconnect
This commit is contained in:
parent
f61c09596e
commit
d4f46b994b
@ -35,6 +35,7 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
||||
self._report_mode_task = None
|
||||
self._poll_for_report = True
|
||||
self._update_params_task = None
|
||||
self.connection_errored = False
|
||||
super().__init__(parent)
|
||||
|
||||
async def run(self):
|
||||
@ -51,6 +52,10 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
||||
self._update_params_task = asyncio.create_task(self.update_params())
|
||||
await asyncio.sleep(self._update_s)
|
||||
|
||||
@pyqtSlot()
|
||||
def timed_out(self):
|
||||
self.connection_errored = True
|
||||
|
||||
async def get_hw_rev(self):
|
||||
self.hw_rev = await self._client.hw_rev()
|
||||
return self.hw_rev
|
||||
@ -101,6 +106,7 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
||||
|
||||
async def end_session(self):
|
||||
await self._client.end_session()
|
||||
self.connection_errored = False
|
||||
|
||||
async def set_ipv4(self, 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.client.connection_error.connect(self.thermostat.timed_out)
|
||||
self.client.connection_error.connect(self.bail)
|
||||
|
||||
self.autotuners = PIDAutoTuner(self, self.client, 2)
|
||||
|
||||
def get_ctrl_panel_config(args):
|
||||
@ -190,9 +193,12 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
self.thermostat_ctrl_menu.fan_pwm_warning.setToolTip("")
|
||||
self.clear_graphs()
|
||||
self.report_box.setChecked(False)
|
||||
if not Thermostat.connecting or Thermostat.connected:
|
||||
for ch in range(self.NUM_CHANNELS):
|
||||
if self.autotuners.get_state(ch) != PIDAutotuneState.STATE_OFF:
|
||||
for ch in range(self.NUM_CHANNELS):
|
||||
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.thermostat.set_report_mode(False)
|
||||
self.thermostat.stop_watching()
|
||||
|
Loading…
Reference in New Issue
Block a user