diff --git a/client/brewpi_gui.py b/client/brewpi_gui.py index 3d37a9a..188ebea 100755 --- a/client/brewpi_gui.py +++ b/client/brewpi_gui.py @@ -24,6 +24,16 @@ SUD_RUNNING_STATES = {"SudState.RAMPING", "SudState.HOLDING", "SudState.WAIT_USE SUD_WAIT_USER_STATE = "SudState.WAIT_USER" SUD_PAUSED_STATE = "SudState.PAUSED" +# Below this (simulated seconds), an 'Elapsed' push is treated as "this run +# just started" rather than "reconnecting mid-brew" - see on_sud_changed()'s +# Elapsed handling. Generous relative to typical dt (0.1-1s/tick): a fresh +# start's first push always lands well under it, while reconnecting to an +# established run (anything past its first handful of ticks) always lands +# well over it - and seeding the history a few seconds "late" within a +# genuinely fresh run is harmless anyway, since the temperature there is +# still essentially the t=0 anchor. +FRESH_RUN_ELAPSED_THRESHOLD_S = 5.0 + def _style_axis(ax): ax.set_facecolor('white') @@ -827,6 +837,19 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow): # a run starting. if self.sud_elapsed_seconds is not None: self.sud_elapsed_seconds = msg['Elapsed'] + # Seed the actual-trace history with this run's real + # t=0 point - without it, the first sample only lands + # at on_plot_timer()'s next 1-second tick, which under + # a real sim_warp_factor can already be a noticeable + # way into the run, leaving a small visible gap between + # the forecast's exact t=0 anchor and where the actual + # trace first appears. Gated on elapsed still being + # small so reconnecting mid-brew (large elapsed) - where + # this temperature reading has nothing to do with that + # run's actual t=0 - doesn't get a bogus point plotted + # at x=0. + if not self.forecast_history and self.plot_temp_ist and msg['Elapsed'] < FRESH_RUN_ELAPSED_THRESHOLD_S: + self.forecast_history.append((msg['Elapsed'] / 60.0, self.plot_temp_ist)) elif "Forecast" in key: self.on_sud_forecast_received(msg['Forecast']) elif "Error" in key: