diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 727055d3..b71698aa 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -638,11 +638,13 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): cleanedPrintTime = self._comm.getCleanedPrintTime() statisticalTotalPrintTime = None + statisticalTotalPrintTimeType = None if self._selectedFile and "estimatedPrintTime" in self._selectedFile \ and self._selectedFile["estimatedPrintTime"]: statisticalTotalPrintTime = self._selectedFile["estimatedPrintTime"] + statisticalTotalPrintTimeType = self._selectedFile.get("estimatedPrintTimeType", None) - printTimeLeft, printTimeLeftOrigin = self._estimatePrintTimeLeft(progress, printTime, cleanedPrintTime, statisticalTotalPrintTime) + printTimeLeft, printTimeLeftOrigin = self._estimatePrintTimeLeft(progress, printTime, cleanedPrintTime, statisticalTotalPrintTime, statisticalTotalPrintTimeType) if progress is not None: progress_int = int(progress * 100) @@ -656,7 +658,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): printTimeLeft=int(printTimeLeft) if printTimeLeft is not None else None, printTimeLeftOrigin=printTimeLeftOrigin) - def _estimatePrintTimeLeft(self, progress, printTime, cleanedPrintTime, statisticalTotalPrintTime): + def _estimatePrintTimeLeft(self, progress, printTime, cleanedPrintTime, statisticalTotalPrintTime, statisticalTotalPrintTimeType): """ Tries to estimate the print time left for the print job @@ -705,9 +707,11 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): (if detectable). statisticalTotalPrintTime (float or None): Total print time of past prints against same printer profile, or estimated total print time from GCODE analysis. + statisticalTotalPrintTimeType (str or None): Type of statistical print time, either "average" (total time + of former prints) or "analysis" Returns: - (float or None) estimated print time left or None if not proper estimate could be made at all + (2-tuple) estimated print time left or None if not proper estimate could be made at all, origin of estimation """ if progress is None or printTime is None or cleanedPrintTime is None: @@ -722,7 +726,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): if estimatedTotalPrintTime is None: # no estimate yet, we'll use the statistical total totalPrintTime = statisticalTotalPrintTime - printTimeLeftOrigin = "stats" + printTimeLeftOrigin = statisticalTotalPrintTimeType else: if progress < self._timeEstimationStatsWeighingUntil: @@ -730,7 +734,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): sub_progress = progress * (1 / self._timeEstimationStatsWeighingUntil) if sub_progress > 1.0: sub_progress = 1.0 - printTimeLeftOrigin = "mixture" + printTimeLeftOrigin = "mixed-" + statisticalTotalPrintTimeType else: # use only the current estimate sub_progress = 1.0 @@ -855,9 +859,11 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): if averagePrintTime is not None: self._selectedFile["estimatedPrintTime"] = averagePrintTime + self._selectedFile["estimatedPrintTimeType"] = "average" elif estimatedPrintTime is not None: # TODO apply factor which first needs to be tracked! self._selectedFile["estimatedPrintTime"] = estimatedPrintTime + self._selectedFile["estimatedPrintTimeType"] = "analysis" self._stateMonitor.set_job_data({ "file": { diff --git a/src/octoprint/static/js/app/viewmodels/printerstate.js b/src/octoprint/static/js/app/viewmodels/printerstate.js index 06d89b04..8076c7ae 100644 --- a/src/octoprint/static/js/app/viewmodels/printerstate.js +++ b/src/octoprint/static/js/app/viewmodels/printerstate.js @@ -84,6 +84,50 @@ $(function() { return formatFuzzyEstimation(self.printTimeLeft()); } }); + self.printTimeLeftOriginString = ko.pureComputed(function() { + var value = self.printTimeLeftOrigin(); + switch (value) { + case "linear": { + return gettext("Based on a linear approximation (accuracy highly dependent on the model)"); + } + case "analysis": { + return gettext("Based on the estimate from analysis of file (medium accuracy)"); + } + case "mixed-analysis": { + return gettext("Based on a mix of estimate from analysis and calculation (medium accuracy)"); + } + case "average": { + return gettext("Based on the average total of past prints of this model with the same printer profile (usually good accuracy)"); + } + case "mixed-average": { + return gettext("Based on a mix of average total from past prints and calculation (usually good accuracy)"); + } + case "estimate": { + return gettext("Based on the calculated estimate (best accuracy)"); + } + default: { + return ""; + } + } + }); + self.printTimeLeftOriginClass = ko.pureComputed(function() { + var value = self.printTimeLeftOrigin(); + switch (value) { + default: + case "linear": { + return "text-error"; + } + case "analysis": + case "mixed-analysis": { + return "text-warning"; + } + case "average": + case "mixed-average": + case "estimate": { + return "text-success"; + } + } + }); self.progressString = ko.pureComputed(function() { if (!self.progress()) return 0; diff --git a/src/octoprint/templates/sidebar/state.jinja2 b/src/octoprint/templates/sidebar/state.jinja2 index f6168753..d21426cd 100644 --- a/src/octoprint/templates/sidebar/state.jinja2 +++ b/src/octoprint/templates/sidebar/state.jinja2 @@ -6,7 +6,7 @@ {{ _('Approx. Total Print Time') }}:
{{ _('Print Time') }}:
-{{ _('Print Time Left') }}:
+{{ _('Print Time Left') }}:
{{ _('Printed') }}: