Add indicator of origin of print time left estimate to UI

This commit is contained in:
Gina Häußge 2016-07-27 18:38:17 +02:00
parent 0a81e8b161
commit f2ecb96c83
3 changed files with 56 additions and 6 deletions

View file

@ -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": {

View file

@ -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;

View file

@ -6,7 +6,7 @@
<!-- /ko -->
{{ _('Approx. Total Print Time') }}: <strong data-bind="text: estimatedPrintTimeString"></strong><br>
{{ _('Print Time') }}: <strong data-bind="text: printTimeString"></strong><br>
{{ _('Print Time Left') }}: <strong data-bind="text: printTimeLeftString"></strong><br>
{{ _('Print Time Left') }}: <strong data-bind="text: printTimeLeftString"></strong> <span id="state_printtimeleft_popover" style="display: none" data-bind="visible: printTimeLeftOrigin, attr: {title: printTimeLeftOriginString}"><i class="icon-info-sign" data-bind="css: printTimeLeftOriginClass"></i></span><br>
{{ _('Printed') }}: <strong data-bind="text: byteString"></strong><br>
<div class="progress progress-text-centered">