forked from M-Labs/thermostat
Fix Autotuner state for forceful disconnect
This commit is contained in:
parent
1b64a88c75
commit
7019bbe004
pytec
@ -34,6 +34,7 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
||||
self._watch_task = None
|
||||
self._report_mode_task = None
|
||||
self._poll_for_report = True
|
||||
self.connection_errored = False
|
||||
super().__init__(parent)
|
||||
|
||||
async def run(self):
|
||||
@ -50,6 +51,10 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
||||
self.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
|
||||
@ -100,6 +105,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):
|
||||
@ -197,9 +200,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