diff --git a/pytec/pytec/gui/model/thermostat.py b/pytec/pytec/gui/model/thermostat.py index a5c23a9..69ddd40 100644 --- a/pytec/pytec/gui/model/thermostat.py +++ b/pytec/pytec/gui/model/thermostat.py @@ -14,6 +14,7 @@ class ThermostatConnectionState(Enum): class Thermostat(QObject, metaclass=PropertyMeta): + connection_state = Property(ThermostatConnectionState) hw_rev = Property(dict) fan = Property(dict) thermistor = Property(list) @@ -23,7 +24,6 @@ class Thermostat(QObject, metaclass=PropertyMeta): report = Property(list) connection_error = pyqtSignal() - connection_state_changed = pyqtSignal(ThermostatConnectionState) NUM_CHANNELS = 2 @@ -37,11 +37,13 @@ class Thermostat(QObject, metaclass=PropertyMeta): self.disconnect_cb = disconnect_cb super().__init__(parent) + self.connection_state = ThermostatConnectionState.DISCONNECTED + async def start_session(self, host, port): - self.connection_state_changed.emit(ThermostatConnectionState.CONNECTING) + self.connection_state = ThermostatConnectionState.CONNECTING await self._client.connect(host, port) self.hw_rev = await self.get_hw_rev() - self.connection_state_changed.emit(ThermostatConnectionState.CONNECTED) + self.connection_state = ThermostatConnectionState.CONNECTED self.start_watching() async def run(self): @@ -133,7 +135,7 @@ class Thermostat(QObject, metaclass=PropertyMeta): self.disconnect_cb() await self._client.disconnect() - self.connection_state_changed.emit(ThermostatConnectionState.DISCONNECTED) + self.connection_state = ThermostatConnectionState.DISCONNECTED async def set_ipv4(self, ipv4): await self._client.set_param("ipv4", ipv4) diff --git a/pytec/pytec/gui/view/conn_menu.py b/pytec/pytec/gui/view/conn_menu.py index 4a13af5..d815740 100644 --- a/pytec/pytec/gui/view/conn_menu.py +++ b/pytec/pytec/gui/view/conn_menu.py @@ -8,7 +8,7 @@ class ConnMenu(QtWidgets.QMenu): super().__init__() self._thermostat = thermostat self._connect_btn = connect_btn - self._thermostat.connection_state_changed.connect( + self._thermostat.connection_state_update.connect( self.thermostat_state_change_handler ) diff --git a/pytec/pytec/gui/view/live_plot_view.py b/pytec/pytec/gui/view/live_plot_view.py index f651f43..c2656f7 100644 --- a/pytec/pytec/gui/view/live_plot_view.py +++ b/pytec/pytec/gui/view/live_plot_view.py @@ -17,7 +17,7 @@ class LiveDataPlotter(QObject): self._thermostat.report_update.connect(self.update_report) self._thermostat.pid_update.connect(self.update_pid) - self._thermostat.connection_state_changed.connect( + self._thermostat.connection_state_update.connect( self.thermostat_state_change_handler ) diff --git a/pytec/pytec/gui/view/thermostat_ctrl_menu.py b/pytec/pytec/gui/view/thermostat_ctrl_menu.py index 2e2302a..78b88bc 100644 --- a/pytec/pytec/gui/view/thermostat_ctrl_menu.py +++ b/pytec/pytec/gui/view/thermostat_ctrl_menu.py @@ -16,7 +16,7 @@ class ThermostatCtrlMenu(QtWidgets.QMenu): self.hw_rev_data = dict() self._thermostat.hw_rev_update.connect(self.hw_rev) - self._thermostat.connection_state_changed.connect( + self._thermostat.connection_state_update.connect( self.thermostat_state_change_handler ) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 775c1fe..2d2fc6f 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -61,7 +61,7 @@ class MainWindow(QtWidgets.QMainWindow): # Models self.thermostat = Thermostat(self, self.report_refresh_spin.value()) self._connecting_task = None - self.thermostat.connection_state_changed.connect(self._on_connection_changed) + self.thermostat.connection_state_update.connect(self._on_connection_changed) self.autotuners = PIDAutoTuner(self, self.thermostat, 2) self.autotuners.autotune_state_changed.connect(self.pid_autotune_handler)