From eaa0ed94c02043a0df2aba0e970bc9e2020b2715 Mon Sep 17 00:00:00 2001 From: jneilliii Date: Mon, 28 Oct 2024 13:17:53 -0400 Subject: [PATCH] 0.1.8rc2 fix references to commands after migrating to internal pybambu module --- octoprint_bambu_printer/bambu_print_plugin.py | 4 +++- octoprint_bambu_printer/printer/bambu_virtual_printer.py | 7 ++++--- octoprint_bambu_printer/printer/print_job.py | 3 +++ octoprint_bambu_printer/printer/states/paused_state.py | 4 ++-- octoprint_bambu_printer/printer/states/printing_state.py | 6 +++--- octoprint_bambu_printer/static/js/bambu_printer.js | 6 ++++++ .../templates/bambu_printer_sidebar.jinja2 | 3 +++ setup.py | 2 +- 8 files changed, 25 insertions(+), 10 deletions(-) diff --git a/octoprint_bambu_printer/bambu_print_plugin.py b/octoprint_bambu_printer/bambu_print_plugin.py index aba273f..89e497b 100644 --- a/octoprint_bambu_printer/bambu_print_plugin.py +++ b/octoprint_bambu_printer/bambu_print_plugin.py @@ -1,4 +1,6 @@ from __future__ import absolute_import, annotations + +import json from pathlib import Path import threading from time import perf_counter @@ -101,7 +103,7 @@ def get_settings_defaults(self): "always_use_default_options": False, "ams_data": [], "ams_mapping": [], - "ams_current_tray": None, + "ams_current_tray": 255, } def is_api_adminonly(self): diff --git a/octoprint_bambu_printer/printer/bambu_virtual_printer.py b/octoprint_bambu_printer/printer/bambu_virtual_printer.py index 632ca97..b81a615 100644 --- a/octoprint_bambu_printer/printer/bambu_virtual_printer.py +++ b/octoprint_bambu_printer/printer/bambu_virtual_printer.py @@ -43,7 +43,7 @@ class BambuPrinterTelemetry: lastTempAt: float = time.monotonic() firmwareName: str = "Bambu" extruderCount: int = 1 - ams_current_tray: int = -1 + ams_current_tray: int = 255 # noinspection PyBroadException @@ -210,7 +210,8 @@ def _update_printer_info(self): self._telemetry.bedTemp = temperatures.bed_temp self._telemetry.bedTargetTemp = temperatures.target_bed_temp self._telemetry.chamberTemp = temperatures.chamber_temp - self._telemetry.ams_current_tray = device_data.push_all_data["ams"]["tray_now"] or -1 + if device_data.push_all_data: + self._telemetry.ams_current_tray = device_data.push_all_data["ams"]["tray_now"] or 255 if self._telemetry.ams_current_tray != self._settings.get_int(["ams_current_tray"]): self._settings.set_int(["ams_current_tray"], self._telemetry.ams_current_tray) @@ -356,7 +357,7 @@ def select_project_file(self, file_path: str) -> bool: return True if file_info is None: - self._log.error(f"Cannot select not existing file: {file_path}") + self._log.error(f"Cannot select non-existent file: {file_path}") return False self._selected_project_file = file_info diff --git a/octoprint_bambu_printer/printer/print_job.py b/octoprint_bambu_printer/printer/print_job.py index 6998f46..3eadb0e 100644 --- a/octoprint_bambu_printer/printer/print_job.py +++ b/octoprint_bambu_printer/printer/print_job.py @@ -10,6 +10,9 @@ class PrintJob: file_info: FileInfo progress: int + remaining_time: int + current_layer: int + total_layers: int @property def file_position(self): diff --git a/octoprint_bambu_printer/printer/states/paused_state.py b/octoprint_bambu_printer/printer/states/paused_state.py index 7c79d2e..3602c05 100644 --- a/octoprint_bambu_printer/printer/states/paused_state.py +++ b/octoprint_bambu_printer/printer/states/paused_state.py @@ -37,14 +37,14 @@ def finalize(self): def start_new_print(self): if self._printer.bambu_client.connected: - if self._printer.bambu_client.publish(pybambu.commands.RESUME): + if self._printer.bambu_client.publish(octoprint_bambu_printer.printer.pybambu.commands.RESUME): self._log.info("print resumed") else: self._log.info("print resume failed") def cancel_print(self): if self._printer.bambu_client.connected: - if self._printer.bambu_client.publish(pybambu.commands.STOP): + if self._printer.bambu_client.publish(octoprint_bambu_printer.printer.pybambu.commands.STOP): self._log.info("print cancelled") self._printer.finalize_print_job() else: diff --git a/octoprint_bambu_printer/printer/states/printing_state.py b/octoprint_bambu_printer/printer/states/printing_state.py index 52922c6..a83c627 100644 --- a/octoprint_bambu_printer/printer/states/printing_state.py +++ b/octoprint_bambu_printer/printer/states/printing_state.py @@ -75,19 +75,19 @@ def update_print_job_info(self): return progress = print_job_info.print_percentage - self._printer.current_print_job = PrintJob(project_file_info, progress) + self._printer.current_print_job = PrintJob(project_file_info, progress, print_job_info.remaining_time, print_job_info.current_layer, print_job_info.total_layers) self._printer.select_project_file(project_file_info.path.as_posix()) def pause_print(self): if self._printer.bambu_client.connected: - if self._printer.bambu_client.publish(pybambu.commands.PAUSE): + if self._printer.bambu_client.publish(octoprint_bambu_printer.printer.pybambu.commands.PAUSE): self._log.info("print paused") else: self._log.info("print pause failed") def cancel_print(self): if self._printer.bambu_client.connected: - if self._printer.bambu_client.publish(pybambu.commands.STOP): + if self._printer.bambu_client.publish(octoprint_bambu_printer.printer.pybambu.commands.STOP): self._log.info("print cancelled") self._printer.finalize_print_job() else: diff --git a/octoprint_bambu_printer/static/js/bambu_printer.js b/octoprint_bambu_printer/static/js/bambu_printer.js index f985b5b..aa45183 100644 --- a/octoprint_bambu_printer/static/js/bambu_printer.js +++ b/octoprint_bambu_printer/static/js/bambu_printer.js @@ -18,6 +18,8 @@ $(function () { self.use_ams = true; self.ams_mapping = ko.observableArray([]); + self.job_info = ko.observable(); + self.ams_mapping_computed = function(){ var output_list = []; var index = 0; @@ -92,6 +94,10 @@ $(function () { self.listHelper.updateItems(data.files); self.listHelper.resetPage(); } + + if (data.job_info !== undefined) { + self.job_info(data.job_info); + } }; self.onBeforeBinding = function () { diff --git a/octoprint_bambu_printer/templates/bambu_printer_sidebar.jinja2 b/octoprint_bambu_printer/templates/bambu_printer_sidebar.jinja2 index a2b2b60..c5108ed 100644 --- a/octoprint_bambu_printer/templates/bambu_printer_sidebar.jinja2 +++ b/octoprint_bambu_printer/templates/bambu_printer_sidebar.jinja2 @@ -10,3 +10,6 @@ +
+
{{ _('Layer') }}:
+
diff --git a/setup.py b/setup.py index 037c5bd..29a40aa 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "OctoPrint-BambuPrinter" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "0.1.8rc1" +plugin_version = "0.1.8rc2" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module