diff --git a/octoprint_SlicerEstimator/__init__.py b/octoprint_SlicerEstimator/__init__.py index ed4c0da..cc8dfb9 100644 --- a/octoprint_SlicerEstimator/__init__.py +++ b/octoprint_SlicerEstimator/__init__.py @@ -178,9 +178,9 @@ def on_event(self, event, payload): if slicer_additional["slicer"] == SLICER_SIMPLIFY3D: # Simplify3D has no embedded time left self._estimator.use_progress = True + self._estimator.time_total = slicer_additional["printtime"] else: self._estimator.use_progress = False - self._estimator.time_total = slicer_additional["printtime"] self._slicer_filament_change = self._file_manager._storage_managers["local"].get_additional_metadata(path,"slicer_filament_change") self._send_metadata_print_event(origin, path) self._send_filament_change_event(origin, path) @@ -189,7 +189,9 @@ def on_event(self, event, payload): # Init of Class variables for new estimation self._slicer_estimation = None self._sliver_estimation_str = None - self._estimator.estimated_time = -1 + self._estimator.time_left = -1.0 + self._estimator.time_total = -1.0 + self._estimator.use_progress = False self._slicer_filament_change = None self._logger.debug("Event received: {}".format(event)) @@ -345,11 +347,11 @@ def get_metadata_file(self, plugin_identifier, target, origin, path): return_list = [] meta_selected = filter(lambda elem: elem["targets"][plugin_identifier][target] == True, self._metadata_list) additional_metadata = self._file_manager._storage_managers[origin].get_additional_metadata(path, "slicer") - for meta_item in meta_selected: - additional_metadata = self._file_manager._storage_managers[origin].get_additional_metadata(path, "slicer") - if meta_item["id"] in additional_metadata: - return_item = [meta_item["id"], meta_item["description"], additional_metadata[meta_item["id"]]] - return_list.append(return_item) + if additional_metadata: + for meta_item in meta_selected: + if meta_item["id"] in additional_metadata: + return_item = [meta_item["id"], meta_item["description"], additional_metadata[meta_item["id"]]] + return_list.append(return_item) return return_list else: self._logger.error("Target {} of plugin {} not registered.".format(target, plugin_identifier)) diff --git a/octoprint_SlicerEstimator/estimator.py b/octoprint_SlicerEstimator/estimator.py index c98174c..1edadcc 100644 --- a/octoprint_SlicerEstimator/estimator.py +++ b/octoprint_SlicerEstimator/estimator.py @@ -17,17 +17,17 @@ def __init__(self, job_type): def estimate(self, progress, printTime, cleanedPrintTime, statisticalTotalPrintTime, statisticalTotalPrintTimeType): std_estimator = PrintTimeEstimator.estimate(self, progress, printTime, cleanedPrintTime, statisticalTotalPrintTime, statisticalTotalPrintTimeType) + logger.debug("SlicerEstimator: Time Left {}, Use Progress {}, Progress {}, Cleaned Print Time {}, Stat. Total Print Time {}, Stat. Total Print Time Type {}".format(self.time_left, self.use_progress, progress, cleanedPrintTime, statisticalTotalPrintTime, statisticalTotalPrintTimeType)) if self._job_type != "local" or ( self.time_left == -1.0 and not self.use_progress ) or cleanedPrintTime is None or progress is None: - # using standard estimator - self.time_left = std_estimator[0] + # using standard estimator return std_estimator elif std_estimator[1] == "average" and self.average_prio: # average more important than estimation self.time_left = std_estimator[0] return std_estimator elif self.use_progress: - # progress based estimation - as GCODe position based not very accurate + # progress based estimation - as GCODE position based not very accurate self.time_left = self.time_total - (progress * 0.01 * self.time_total) logger.debug("SlicerEstimator: Estimation Reported {}".format(self.time_left)) return self.time_left, "slicerestimator"