forked from M-Labs/thermostat
Turn on_connection_changed to coroutine
Further compresses the connect
This commit is contained in:
parent
82438ee4a5
commit
b4a5e90f2e
@ -93,7 +93,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.port_set_spin.setValue(int(args.PORT))
|
||||
self.connect_btn.click()
|
||||
|
||||
def _on_connection_changed(self, result):
|
||||
async def _on_connection_changed(self, result):
|
||||
self.graph_group.setEnabled(result)
|
||||
self.fan_group.setEnabled(result)
|
||||
self.report_group.setEnabled(result)
|
||||
@ -105,6 +105,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.status_lbl.setText("Disconnected")
|
||||
self.fan_pwm_warning.setPixmap(QtGui.QPixmap())
|
||||
self.fan_pwm_warning.setToolTip("")
|
||||
else:
|
||||
self._status(await self.tec_client.hw_rev())
|
||||
self.fan_update(await self.tec_client.fan())
|
||||
|
||||
def _set_fan_pwm_warning(self):
|
||||
if self.fan_power_slider.value() != 100:
|
||||
@ -174,21 +177,18 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
except asyncio.CancelledError:
|
||||
return
|
||||
|
||||
self._on_connection_changed(True)
|
||||
self._status(await self.tec_client.hw_rev())
|
||||
self.fan_update(await self.tec_client.fan())
|
||||
|
||||
await self._on_connection_changed(True)
|
||||
self.client_watcher.start_watching()
|
||||
else:
|
||||
self.client_watcher.stop_watching()
|
||||
|
||||
await self.tec_client.disconnect()
|
||||
self._on_connection_changed(False)
|
||||
await self._on_connection_changed(False)
|
||||
|
||||
except (OSError, TimeoutError) as e:
|
||||
logging.error(f"Failed communicating to {ip}:{port}: {e}")
|
||||
await self.tec_client.disconnect()
|
||||
self._on_connection_changed(False)
|
||||
await self._on_connection_changed(False)
|
||||
|
||||
|
||||
async def coro_main():
|
||||
|
Loading…
Reference in New Issue
Block a user