Fix step-1-skipped-on-restart race and Progress tab step number mismatch
Re-enabling the temp controller landed unconditionally in HOLD and relied on the next tick to correct it, but SudTask.on_process() reads is_holding() synchronously in the same call chain that pushes a fresh step's setpoint - so a restart could finish a hold-less step instantly instead of actually ramping. Resolve the FSM against the real gap right away instead. Also fix the status bar showing one step number below what the Progress tab's plates show for the same step. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0189FkmyJkY77HqsNomr1DwV
This commit is contained in:
@@ -1181,7 +1181,11 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
|
||||
def update_status_step_label(self):
|
||||
if self.sud_step_descr:
|
||||
text = "Step {}: {}".format(self.sud_step_index, self.sud_step_descr)
|
||||
# +1: sud_step_index is the 0-based index Sud.index uses, but
|
||||
# StepPlate (the Progress tab) labels steps 1-based - match it
|
||||
# here so the status bar doesn't announce a step one number
|
||||
# below what the Progress tab shows for the same step.
|
||||
text = "Step {}: {}".format(self.sud_step_index + 1, self.sud_step_descr)
|
||||
if self.sud_step_type == 'hold':
|
||||
remaining = max(self.sud_hold_remaining, 0.0)
|
||||
text += " ({:.0f}:{:02.0f} remaining)".format(remaining // 60, remaining % 60)
|
||||
|
||||
@@ -160,14 +160,28 @@ class TempControllerBase(APid):
|
||||
elif not self.enabled:
|
||||
state_next = States.IDLE
|
||||
elif self.state == States.IDLE:
|
||||
# Just (re-)enabled - land in HOLD; the very next tick's
|
||||
# threshold check (below) moves it on to HEAT/COOL if the gap
|
||||
# actually warrants it. pid_heat was frozen (see process_pid())
|
||||
# and possibly stale for as long as we were disabled - start it
|
||||
# clean rather than resuming wherever it last left off.
|
||||
state_next = States.HOLD
|
||||
# Just (re-)enabled - resolve straight to HEAT/COOL/HOLD against
|
||||
# the real gap, the same threshold check the HOLD branch below
|
||||
# uses, rather than landing in HOLD and waiting for the next
|
||||
# tick to correct it: is_holding() is read synchronously within
|
||||
# this very same call chain (tasks/sud.py's SudTask.on_step_
|
||||
# changed() pushes the new step's setpoint via set_theta_soll(),
|
||||
# which calls this method directly), so an unconditional HOLD
|
||||
# here gets mistaken for "ramp already reached" and can finish
|
||||
# a freshly (re-)started step instantly - see SudTask.
|
||||
# on_process()'s is_holding() check. pid_heat/pid_cool were
|
||||
# frozen (see process_pid()) and possibly stale for as long as
|
||||
# we were disabled - start whichever one matters clean rather
|
||||
# than resuming wherever it last left off.
|
||||
self.pid_hold.reset()
|
||||
self.pid_heat.reset()
|
||||
self.pid_cool.reset()
|
||||
if diff >= self.thresholds['HoldHeat']:
|
||||
state_next = States.HEAT
|
||||
elif diff <= -self.thresholds['HoldCool']:
|
||||
state_next = States.COOL
|
||||
else:
|
||||
state_next = States.HOLD
|
||||
elif self.state == States.HOLD:
|
||||
if diff >= self.thresholds['HoldHeat']:
|
||||
state_next = States.HEAT
|
||||
|
||||
Reference in New Issue
Block a user