Add a GUI text entry to set the ambient temperature live

New lineEdit_ambient next to the host/connect row - type a value and
press Enter to send {"System": {"AmbientTemp": ...}}. The server now
has a recv handler for the System channel (previously send-only):
updates the real Pot's ambient temperature and, where the controller
has an internal model (Smith), its model Pots too (new
set_ambient_temperature() on TempControllerSmith), then echoes the new
value back so the status bar label and entry itself stay in sync.
This commit is contained in:
2026-06-21 11:53:45 +02:00
parent a44060a9bd
commit 40cf4b69cc
5 changed files with 71 additions and 2 deletions
+14
View File
@@ -329,6 +329,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
self.checkbox_heater_activate.stateChanged.connect(self.on_checkbox_changed)
self.checkbox_stirrer_activate.stateChanged.connect(self.on_checkbox_stirrer_activate_changed)
self.lineEdit_ambient.returnPressed.connect(self.on_ambient_entry_changed)
self.send_data = Queue()
self.slider_pwr_initial_update = True
@@ -460,6 +461,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
self.sud_state = None
self.sud_user_message = None
self.ambient_temp = None
self.lineEdit_ambient.clear()
self.warp_factor = 1.0
self.sud_start_time = None
self.sud_paused_total = 0.0
@@ -491,10 +493,22 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
for key in msg:
if "AmbientTemp" in key:
self.ambient_temp = msg['AmbientTemp']
# Only sync the entry's text while the user isn't actively
# editing it, so a server echo doesn't clobber in-progress
# typing.
if not self.lineEdit_ambient.hasFocus():
self.lineEdit_ambient.setText("{:.1f}".format(self.ambient_temp))
elif "WarpFactor" in key:
self.warp_factor = msg['WarpFactor']
self.update_status_env_label()
def on_ambient_entry_changed(self):
try:
value = float(self.lineEdit_ambient.text())
except ValueError:
return
self.msg_system.send({'AmbientTemp': value})
def update_status_env_label(self):
ambient = "{:.1f}°C".format(self.ambient_temp) if self.ambient_temp is not None else "-"
self.status_label_env.setText("Ambient: {} Warp: {:.1f}x".format(ambient, self.warp_factor))