GUI: widen ambient-temp spinbox range and persist it client-side
doubleSpinBox_ambient now allows -999..999 in whole degrees (was 0..50 with 1 decimal), and main_window.py is regenerated to match. The ambient temperature is also now a properly client-owned setting: it's written to the user config on shutdown (not on every spinbox tick), restored into the spinbox immediately on GUI start, resent to the server on every (re)connect using the spinbox's live value, and no longer reset to the spinbox minimum on disconnect.
This commit is contained in:
+4
-4
@@ -3727,16 +3727,16 @@
|
||||
<string>Set the simulated/assumed ambient temperature</string>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
<double>-999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
<double>999.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.500000000000000</double>
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btn_pot_reset">
|
||||
|
||||
+23
-9
@@ -365,6 +365,15 @@ 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.checkbox_tc_enable.stateChanged.connect(self.on_checkbox_tc_enable_changed)
|
||||
# Show the last value we had before the GUI last closed (see
|
||||
# closeEvent()) right away, rather than the spinbox's bare design-time
|
||||
# default - blockSignals so this doesn't queue a spurious 'AmbientTemp'
|
||||
# send before the user has touched anything.
|
||||
remembered_ambient = self.user_config.get('ambient_temperature')
|
||||
if remembered_ambient is not None:
|
||||
self.doubleSpinBox_ambient.blockSignals(True)
|
||||
self.doubleSpinBox_ambient.setValue(remembered_ambient)
|
||||
self.doubleSpinBox_ambient.blockSignals(False)
|
||||
self.doubleSpinBox_ambient.valueChanged.connect(self.on_ambient_entry_changed)
|
||||
self.btn_pot_reset.clicked.connect(self.on_action_pot_reset)
|
||||
# Only meaningful (and only shown) once the server confirms its Pot
|
||||
@@ -424,11 +433,12 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
# on_sud_changed() routes the reply to update_sud_forecast() instead
|
||||
# of a save dialog.
|
||||
self.msg_sud.send({'Save': True})
|
||||
# Re-apply the last ambient temperature we set, in case the server
|
||||
# restarted since (and so fell back to its own config.json default).
|
||||
remembered_ambient = self.user_config.get('ambient_temperature')
|
||||
if remembered_ambient is not None:
|
||||
self.msg_system.send({'AmbientTemp': remembered_ambient})
|
||||
# Re-apply our own ambient temperature, in case the server restarted
|
||||
# since (and so fell back to its own config.json default) - the
|
||||
# spinbox's current value, not the on-disk user config (which is
|
||||
# only refreshed on shutdown - see closeEvent()), so this also picks
|
||||
# up a change made earlier in the same session, before a reconnect.
|
||||
self.msg_system.send({'AmbientTemp': self.doubleSpinBox_ambient.value()})
|
||||
|
||||
def _elapsed_min(self):
|
||||
"""Simulated-schedule minutes elapsed since the run started, or
|
||||
@@ -493,10 +503,11 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.checkbox_tc_enable.blockSignals(False)
|
||||
self.Slider_temp_soll.setEnabled(False)
|
||||
self.doubleSpinBox_heatrate_soll.setEnabled(False)
|
||||
# ambient_temp (the server's last echoed reading, shown in the
|
||||
# status bar) is no longer trustworthy, but the spinbox itself is
|
||||
# a client-owned setting (see closeEvent()/connect()) - leave it
|
||||
# showing whatever the user last set rather than blanking it.
|
||||
self.ambient_temp = None
|
||||
self.doubleSpinBox_ambient.blockSignals(True)
|
||||
self.doubleSpinBox_ambient.setValue(self.doubleSpinBox_ambient.minimum())
|
||||
self.doubleSpinBox_ambient.blockSignals(False)
|
||||
self.btn_pot_reset.setVisible(False)
|
||||
self.warp_factor = 1.0
|
||||
self.sud_elapsed_seconds = None
|
||||
@@ -549,7 +560,9 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.msg_pot.send({'Reset': True})
|
||||
|
||||
def on_ambient_entry_changed(self, value):
|
||||
self.user_config.set('ambient_temperature', value)
|
||||
# Persisted on shutdown instead (see closeEvent()), not on every
|
||||
# spinbox tick - this fires on every keystroke/arrow click while
|
||||
# editing.
|
||||
self.msg_system.send({'AmbientTemp': value})
|
||||
|
||||
def update_status_env_label(self):
|
||||
@@ -945,6 +958,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
|
||||
def closeEvent(self, event):
|
||||
print("Exitting gracefully!")
|
||||
self.user_config.set('ambient_temperature', self.doubleSpinBox_ambient.value())
|
||||
self.ws_client.disconnect()
|
||||
|
||||
|
||||
|
||||
@@ -1239,10 +1239,10 @@ class Ui_MainWindow(object):
|
||||
self.label_ambient.setObjectName("label_ambient")
|
||||
self.doubleSpinBox_ambient = QtWidgets.QDoubleSpinBox(self.centralwidget)
|
||||
self.doubleSpinBox_ambient.setGeometry(QtCore.QRect(620, 500, 70, 31))
|
||||
self.doubleSpinBox_ambient.setDecimals(1)
|
||||
self.doubleSpinBox_ambient.setMinimum(0.0)
|
||||
self.doubleSpinBox_ambient.setMaximum(50.0)
|
||||
self.doubleSpinBox_ambient.setSingleStep(0.5)
|
||||
self.doubleSpinBox_ambient.setDecimals(0)
|
||||
self.doubleSpinBox_ambient.setMinimum(-999.0)
|
||||
self.doubleSpinBox_ambient.setMaximum(999.0)
|
||||
self.doubleSpinBox_ambient.setSingleStep(1.0)
|
||||
self.doubleSpinBox_ambient.setObjectName("doubleSpinBox_ambient")
|
||||
self.btn_pot_reset = QtWidgets.QPushButton(self.centralwidget)
|
||||
self.btn_pot_reset.setGeometry(QtCore.QRect(700, 500, 220, 31))
|
||||
|
||||
Reference in New Issue
Block a user