From 11bdc176a0be87bd70dfbc93e9d8bc7b0305a63e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 15 Aug 2016 12:08:25 +0200 Subject: [PATCH] Fix minute comparison for dumb estimate fallback Probably solves the core reason that caused #1428 to be reported in the first place, totally inaccurate early linear approximations (when nothing better is available) making it to the user. It should now display "Calcuting..." until the approximation stabilizes OR the configured max percentage or max time without an estimate are reached. --- src/octoprint/printer/standard.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 229adcd2..83b81a9f 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -761,15 +761,16 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): printTimeLeft = dumbTotalPrintTime - cleanedPrintTime printTimeLeftOrigin = "linear" - elif progress > self._timeEstimationForceDumbFromPercent or \ - cleanedPrintTime * 60 >= self._timeEstimationForceDumbAfterMin: - # more than x% or y min printed and still no real estimate, ok, we'll use the dumb variant :/ - printTimeLeft = dumbTotalPrintTime - cleanedPrintTime + else: printTimeLeftOrigin = "linear" + if progress > self._timeEstimationForceDumbFromPercent or \ + cleanedPrintTime >= self._timeEstimationForceDumbAfterMin * 60: + # more than x% or y min printed and still no real estimate, ok, we'll use the dumb variant :/ + printTimeLeft = dumbTotalPrintTime - cleanedPrintTime - if printTimeLeft < 0: + if printTimeLeft is not None and printTimeLeft < 0: # shouldn't actually happen, but let's make sure - return None, None + printTimeLeft = None return printTimeLeft, printTimeLeftOrigin