return hwrev when start_session

This commit is contained in:
atse 2024-08-23 16:11:27 +08:00
parent 254e391a09
commit d8c7db3f66
2 changed files with 3 additions and 5 deletions

View File

@ -37,7 +37,9 @@ class Thermostat(QObject, metaclass=PropertyMeta):
async def start_session(self, host, port): async def start_session(self, host, port):
await self._client.connect(host, port) await self._client.connect(host, port)
hw_rev_data = await self.get_hw_rev()
self.start_watching() self.start_watching()
return hw_rev_data
async def run(self): async def run(self):
self._update_params_task = asyncio.create_task(self.update_params()) self._update_params_task = asyncio.create_task(self.update_params())

View File

@ -177,9 +177,6 @@ class MainWindow(QtWidgets.QMainWindow):
self.conn_menu.port_set_spin.setEnabled(False) self.conn_menu.port_set_spin.setEnabled(False)
self.connect_btn.setText("Disconnect") self.connect_btn.setText("Disconnect")
self.hw_rev_data = await self.thermostat.get_hw_rev()
logging.debug(self.hw_rev_data)
self._status(self.hw_rev_data) self._status(self.hw_rev_data)
case ThermostatConnectionState.CONNECTING: case ThermostatConnectionState.CONNECTING:
@ -214,7 +211,6 @@ class MainWindow(QtWidgets.QMainWindow):
await self.autotuners.stop_pid_from_running(ch) await self.autotuners.stop_pid_from_running(ch)
def _status(self, hw_rev_d: dict): def _status(self, hw_rev_d: dict):
logging.debug(hw_rev_d)
self.status_lbl.setText( self.status_lbl.setText(
f"Connected to Thermostat v{hw_rev_d['rev']['major']}.{hw_rev_d['rev']['minor']}" f"Connected to Thermostat v{hw_rev_d['rev']['major']}.{hw_rev_d['rev']['minor']}"
) )
@ -255,7 +251,7 @@ class MainWindow(QtWidgets.QMainWindow):
) )
) )
try: try:
await self._connecting_task self.hw_rev_data = await self._connecting_task
except (OSError, asyncio.CancelledError) as exc: except (OSError, asyncio.CancelledError) as exc:
await self.bail() await self.bail()
if isinstance(exc, asyncio.CancelledError): if isinstance(exc, asyncio.CancelledError):