verify_heater: If the heating_gain check fails, just use max_error check
Don't immediately raise an error if the heating_gain check fails. Instead, just transition to the normal max_error check. This should make the code less likely to raise an error should the heater have a slow approach to the target temperature. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
f2ca7d5c66
commit
8f37700d23
|
@ -27,9 +27,9 @@ class HeaterCheck:
|
||||||
default_gain_time = 60.
|
default_gain_time = 60.
|
||||||
self.check_gain_time = config.getfloat(
|
self.check_gain_time = config.getfloat(
|
||||||
'check_gain_time', default_gain_time, minval=1.)
|
'check_gain_time', default_gain_time, minval=1.)
|
||||||
self.met_target = self.starting_approach = False
|
self.approaching_target = self.starting_approach = False
|
||||||
self.last_target = self.goal_temp = self.error = 0.
|
self.last_target = self.goal_temp = self.error = 0.
|
||||||
self.fault_systime = self.printer.get_reactor().NEVER
|
self.goal_systime = self.printer.get_reactor().NEVER
|
||||||
self.check_timer = None
|
self.check_timer = None
|
||||||
def handle_connect(self):
|
def handle_connect(self):
|
||||||
if self.printer.get_start_args().get('debugoutput') is not None:
|
if self.printer.get_start_args().get('debugoutput') is not None:
|
||||||
|
@ -48,33 +48,37 @@ class HeaterCheck:
|
||||||
temp, target = self.heater.get_temp(eventtime)
|
temp, target = self.heater.get_temp(eventtime)
|
||||||
if temp >= target - self.hysteresis:
|
if temp >= target - self.hysteresis:
|
||||||
# Temperature near target - reset checks
|
# Temperature near target - reset checks
|
||||||
if not self.met_target and target:
|
if self.approaching_target and target:
|
||||||
logging.info("Heater %s within range of %.3f",
|
logging.info("Heater %s within range of %.3f",
|
||||||
self.heater_name, target)
|
self.heater_name, target)
|
||||||
self.met_target = True
|
self.approaching_target = self.starting_approach = False
|
||||||
if temp <= target + self.hysteresis:
|
if temp <= target + self.hysteresis:
|
||||||
self.error = 0.
|
self.error = 0.
|
||||||
elif self.met_target:
|
self.last_target = target
|
||||||
self.error += (target - self.hysteresis) - temp
|
return eventtime + 1.
|
||||||
|
self.error += (target - self.hysteresis) - temp
|
||||||
|
if not self.approaching_target:
|
||||||
if target != self.last_target:
|
if target != self.last_target:
|
||||||
# Target changed - reset checks
|
# Target changed - reset checks
|
||||||
logging.info("Heater %s approaching new target of %.3f",
|
logging.info("Heater %s approaching new target of %.3f",
|
||||||
self.heater_name, target)
|
self.heater_name, target)
|
||||||
self.met_target = False
|
self.approaching_target = self.starting_approach = True
|
||||||
self.starting_approach = True
|
|
||||||
self.goal_temp = temp + self.heating_gain
|
self.goal_temp = temp + self.heating_gain
|
||||||
self.fault_systime = eventtime + self.check_gain_time
|
self.goal_systime = eventtime + self.check_gain_time
|
||||||
elif self.error >= self.max_error:
|
elif self.error >= self.max_error:
|
||||||
# Failure due to inability to maintain target temperature
|
# Failure due to inability to maintain target temperature
|
||||||
return self.heater_fault()
|
return self.heater_fault()
|
||||||
elif temp >= self.goal_temp:
|
elif temp >= self.goal_temp:
|
||||||
# Temperature approaching target - reset checks
|
# Temperature approaching target - reset checks
|
||||||
self.starting_approach = False
|
self.starting_approach = False
|
||||||
|
self.error = 0.
|
||||||
self.goal_temp = temp + self.heating_gain
|
self.goal_temp = temp + self.heating_gain
|
||||||
self.fault_systime = eventtime + self.check_gain_time
|
self.goal_systime = eventtime + self.check_gain_time
|
||||||
elif eventtime >= self.fault_systime:
|
elif eventtime >= self.goal_systime:
|
||||||
# Failure due to inability to approach target temperature
|
# Temperature is no longer approaching target
|
||||||
return self.heater_fault()
|
self.approaching_target = False
|
||||||
|
logging.info("Heater %s no longer approaching target %.3f",
|
||||||
|
self.heater_name, target)
|
||||||
elif self.starting_approach:
|
elif self.starting_approach:
|
||||||
self.goal_temp = min(self.goal_temp, temp + self.heating_gain)
|
self.goal_temp = min(self.goal_temp, temp + self.heating_gain)
|
||||||
self.last_target = target
|
self.last_target = target
|
||||||
|
|
Loading…
Reference in New Issue