diff --git a/octoprint_DisplayLayerProgress/__init__.py b/octoprint_DisplayLayerProgress/__init__.py index 8ef0d24..c37f204 100644 --- a/octoprint_DisplayLayerProgress/__init__.py +++ b/octoprint_DisplayLayerProgress/__init__.py @@ -29,8 +29,8 @@ LAYER_EXPRESSION_CURA = ";LAYER:([0-9]+).*" LAYER_EXPRESSION_S3D = "; layer ([0-9]+),.*" LAYER_COUNT_EXPRESSION = LAYER_MESSAGE_PREFIX + "([0-9]*)" -# Match G1 Z149.370 F1000 or G0 F9000 X161.554 Y118.520 Z14.950 -Z_HEIGHT_EXPRESSION = "(.*)( Z)([+]*[0-9]+.[0-9]*)(.*)" +# Match G1 Z149.370 F1000 or G0 F9000 X161.554 Y118.520 Z14.950 ##no comments +Z_HEIGHT_EXPRESSION = "^[^;](.*)( Z)([+]*[0-9]+[.]*[0-9]*)(.*)" zHeightPattern = re.compile(Z_HEIGHT_EXPRESSION) # Match G0 or G1 positive extrusion e.g. G1 X58.030 Y72.281 E0.1839 F2250 EXTRUSION_EXPRESSION = "G[0|1] .*E[+]*([0-9]+[.]*[0-9]*).*" @@ -155,23 +155,31 @@ def on_event(self, event, payload): totalHeight = 0.0 currentHeight = 0.0 lineNumber = 0 + self._activateBusyIndicator() with open(selectedFile, "r") as f: for line in f: - lineNumber += 1 - matched = pattern.match(line) - if matched: - layerOffset = self._settings.get_int([SETTINGS_KEY_LAYER_OFFSET]) - self._layerTotalCount = str(int(matched.group(1)) + layerOffset) - - matched = zHeightPattern.match(line) - if matched: - currentHeight = float(matched.group(3)) - if currentHeight > totalHeight: - totalHeight = currentHeight - - matched = extrusionPattern.match(line) - if matched: - self._totalHeightWithExtrusion = currentHeight + try: + lineNumber += 1 + matched = pattern.match(line) + if matched: + layerOffset = self._settings.get_int([SETTINGS_KEY_LAYER_OFFSET]) + self._layerTotalCount = str(int(matched.group(1)) + layerOffset) + + matched = zHeightPattern.match(line) + if matched: + currentHeight = float(matched.group(3)) + if currentHeight > totalHeight: + totalHeight = currentHeight + + matched = extrusionPattern.match(line) + if matched: + self._totalHeightWithExtrusion = currentHeight + except (ValueError, RuntimeError): + print("BOOOOOOMMMM") + print("#"+lineNumber + " "+line) + + + if self._settings.get([SETTINGS_KEY_TOTAL_HEIGHT_METHODE]) == HEIGHT_METHODE_Z_MAX: self._totalHeight = "%.2f" % totalHeight else: @@ -209,6 +217,10 @@ def _resetProgressValues(self): self._totalHeight = 0.0 self._totalHeightWithExtrusion = 0.0 + def _activateBusyIndicator(self): + self._plugin_manager.send_plugin_message(self._identifier, dict(busy=True)) + + def _updateDisplay(self, updateReason): currentValueDict = { PROGRESS_KEYWORD_EXPRESSION: self._progress, diff --git a/octoprint_DisplayLayerProgress/static/js/DisplayLayerProgress.js b/octoprint_DisplayLayerProgress/static/js/DisplayLayerProgress.js index 65de7e6..2e74b7b 100644 --- a/octoprint_DisplayLayerProgress/static/js/DisplayLayerProgress.js +++ b/octoprint_DisplayLayerProgress/static/js/DisplayLayerProgress.js @@ -33,15 +33,18 @@ $(function () { var element = $("#state").find(".accordion-inner .progress"); if (element.length) { + + var busyIndicator = ""; + var label = gettext("Current Height"); var tooltip = gettext("Might be inaccurate!"); element.before("" + label + "" + ": " - + "- / -
"); + + "- / -"+busyIndicator+"
"); label = gettext("Layer"); tooltip = gettext("Shows the layer information"); element.before("" + label + "" + ": " - + "- / -
"); + + "- / -"+busyIndicator+"
"); // call backend for update navbar and printer-display OctoPrint.get("api/plugin/"+PLUGIN_ID); @@ -56,6 +59,12 @@ $(function () { return; } + if (data.busy){ + $(".busyIndicator").show(); + } else { + $(".busyIndicator").hide(); + } + // NavBar if (data.navBarMessage){ self.navBarMessage(data.navBarMessage); diff --git a/setup.py b/setup.py index d826b7f..7e15898 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "DisplayLayerProgress" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "1.5.0" +plugin_version = "1.5.1" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module