gui: show the loaded Sud's name in the window caption and forecast title

Window caption becomes "BrewPi - <name>" once a schedule is loaded
(back to plain "BrewPi" when empty/disconnected); the Automatic tab's
forecast title is now "<name> - N min total", replacing the generic
"Estimated course..." text while keeping the time estimate.
This commit is contained in:
2026-06-21 10:47:26 +02:00
parent b51d802b31
commit e855076f55
+6 -5
View File
@@ -148,15 +148,14 @@ class SudForecastPlot(FigureCanvasQTAgg):
theta.append(theta[-1]) theta.append(theta[-1])
return t, theta return t, theta
def show_schedule(self, schedule, start_theta): def show_schedule(self, schedule, start_theta, name):
t, theta = self._estimate_course(schedule, start_theta) t, theta = self._estimate_course(schedule, start_theta)
t_min = [seconds / 60.0 for seconds in t] t_min = [seconds / 60.0 for seconds in t]
self.line.set_data(t_min, theta) self.line.set_data(t_min, theta)
self.ax.relim() self.ax.relim()
self.ax.autoscale_view() self.ax.autoscale_view()
self.ax.set_title("Estimated course (nominal rates, no plant model) " self.ax.set_title("{} - {:.0f} min total".format(name, t_min[-1] if t_min else 0.0), fontsize='small')
"- {:.0f} min total".format(t_min[-1] if t_min else 0.0), fontsize='small')
self.figure.tight_layout() self.figure.tight_layout()
self.draw_idle() self.draw_idle()
@@ -367,6 +366,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
self.set_sud_cooling(False) self.set_sud_cooling(False)
self.update_sud_actions() self.update_sud_actions()
self.update_status_env_label() self.update_status_env_label()
self.setWindowTitle("BrewPi")
def update_sud_actions(self): def update_sud_actions(self):
can_run = self.sud_loaded and not self.sud_empty can_run = self.sud_loaded and not self.sud_empty
@@ -589,6 +589,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
self.update_sud_forecast(msg['Json']) self.update_sud_forecast(msg['Json'])
elif "Name" in key: elif "Name" in key:
self.statusBar().showMessage("Sud schedule updated: {}".format(msg['Name']), 5000) self.statusBar().showMessage("Sud schedule updated: {}".format(msg['Name']), 5000)
self.setWindowTitle("BrewPi - {}".format(msg['Name']) if msg['Name'] else "BrewPi")
elif "State" in key: elif "State" in key:
prev_state = self.sud_state prev_state = self.sud_state
self.sud_state = msg['State'] self.sud_state = msg['State']
@@ -622,7 +623,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
def update_sud_forecast(self, doc): def update_sud_forecast(self, doc):
try: try:
_, _, schedule, _, _ = Sud._parse_data(doc) name, _, schedule, _, _ = Sud._parse_data(doc)
except (KeyError, TypeError): except (KeyError, TypeError):
return return
self.sud_empty = len(schedule) == 0 self.sud_empty = len(schedule) == 0
@@ -633,7 +634,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
# No measured starting temperature is available before a brew has # No measured starting temperature is available before a brew has
# started; fall back to a plausible ambient guess. # started; fall back to a plausible ambient guess.
start_theta = self.plot_temp_ist if self.plot_temp_ist else 20.0 start_theta = self.plot_temp_ist if self.plot_temp_ist else 20.0
self.forecast_plot.show_schedule(schedule, start_theta) self.forecast_plot.show_schedule(schedule, start_theta, name)
def closeEvent(self, event): def closeEvent(self, event):
print("Exitting gracefully!") print("Exitting gracefully!")