diff --git a/client/brewpi_gui.py b/client/brewpi_gui.py index c9ef99f..7d8e349 100755 --- a/client/brewpi_gui.py +++ b/client/brewpi_gui.py @@ -659,8 +659,11 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow): self.msg_sud.send({'Confirm': True}) def on_action_sud_new(self): - # Replaces the running Sud's schedule with an empty one, same as - # Load but with a built-in empty document instead of a file dialog. + # Sends an empty schedule via the same Load path Load Sud uses, with + # a built-in empty document instead of a file dialog - the server + # itself refuses this (like any Load) while a run is in progress, + # surfacing an error (see on_sud_changed()'s 'Error' handling) + # rather than the GUI trying to guess that here. self.msg_sud.send({'Load': {'Name': '', 'Description': '', 'pot_mass': 0, 'pot_material': None, 'steps': []}}) def on_action_sud_save(self): @@ -876,6 +879,8 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow): self.server_remaining_forecast = (anchor_min, forecast['T'], forecast['Theta']) elif "Forecast" in key: self.on_sud_forecast_received(msg['Forecast']) + elif "Error" in key: + QtWidgets.QMessageBox.warning(self, "Sud", msg['Error']) self.update_sud_actions() def on_sud_forecast_received(self, forecast): diff --git a/tasks/sud.py b/tasks/sud.py index ec38653..d9a3a43 100644 --- a/tasks/sud.py +++ b/tasks/sud.py @@ -196,6 +196,13 @@ class SudTask(ATask): await self.send({'Name': self.sud.name, 'Description': self.sud.description}) await self.send({'Json': pair[1]}) await self.send_forecast(pair[1]) + else: + # Sud.load() refuses while a run is in progress (state + # not IDLE/DONE) - tell the client why instead of + # silently dropping the request. The client has no + # business pre-emptively guessing this itself from its + # own (replicated, laggy) view of the state. + await self.send({'Error': 'Cannot load a new schedule while a run is in progress - stop it first.'}) async def send(self, data): await self.msg_handler.send(data)