From ae161748ef9294bb065ad6800bedb9851f134c56 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 12 Sep 2016 10:39:58 +0200 Subject: [PATCH 1/5] Material type is now only checked if we actually use that extruder CURA-2313 --- NetworkPrinterOutputDevice.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NetworkPrinterOutputDevice.py b/NetworkPrinterOutputDevice.py index 0624c817d1..ce0aba70af 100644 --- a/NetworkPrinterOutputDevice.py +++ b/NetworkPrinterOutputDevice.py @@ -448,10 +448,10 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): if variant.getName() != self._json_printer_state["heads"][0]["extruders"][index]["hotend"]["id"]: warnings.append(i18n_catalog.i18nc("@label", "Different PrintCore selected for extruder {0}".format(index + 1))) - material = extruder_manager.getExtruderStack(0).findContainer({"type": "material"}) - if material: - if material.getMetaDataEntry("GUID") != self._json_printer_state["heads"][0]["extruders"][index]["active_material"]["GUID"]: - warnings.append(i18n_catalog.i18nc("@label", "Different material selected for extruder {0}").format(index + 1)) + material = extruder_manager.getExtruderStack(0).findContainer({"type": "material"}) + if material: + if material.getMetaDataEntry("GUID") != self._json_printer_state["heads"][0]["extruders"][index]["active_material"]["GUID"]: + warnings.append(i18n_catalog.i18nc("@label", "Different material selected for extruder {0}").format(index + 1)) if warnings: text = i18n_catalog.i18nc("@label", "Are you sure you wish to print with the selected configuration?") From 820d91486f192c4785a7291d574def4e063a53d2 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 12 Sep 2016 10:44:56 +0200 Subject: [PATCH 2/5] Printer setting mismatches are now also logged as warnings CURA-2313 --- NetworkPrinterOutputDevice.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/NetworkPrinterOutputDevice.py b/NetworkPrinterOutputDevice.py index ce0aba70af..850e893d96 100644 --- a/NetworkPrinterOutputDevice.py +++ b/NetworkPrinterOutputDevice.py @@ -438,6 +438,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): # Check if there is enough material. Any failure in these results in a warning. material_length = self._json_printer_state["heads"][0]["extruders"][index]["active_material"]["length_remaining"] if material_length != -1 and print_information.materialLengths[index] > material_length: + Logger.log("w", "Printer reports that there is not enough material left for extruder %s. We need %s and the printer has %s", index + 1, print_information.materialLengths[index], material_length) warnings.append(i18n_catalog.i18nc("@label", "Not enough material for spool {0}.").format(index+1)) # Check if the right cartridges are loaded. Any failure in these results in a warning. @@ -446,11 +447,15 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): variant = extruder_manager.getExtruderStack(0).findContainer({"type": "variant"}) if variant: if variant.getName() != self._json_printer_state["heads"][0]["extruders"][index]["hotend"]["id"]: + Logger.log("w", "Extruder %s has a different Cartridge (%s) as Cura (%s)", index + 1, self._json_printer_state["heads"][0]["extruders"][index]["hotend"]["id"], variant.getName()) warnings.append(i18n_catalog.i18nc("@label", "Different PrintCore selected for extruder {0}".format(index + 1))) material = extruder_manager.getExtruderStack(0).findContainer({"type": "material"}) if material: if material.getMetaDataEntry("GUID") != self._json_printer_state["heads"][0]["extruders"][index]["active_material"]["GUID"]: + Logger.log("w", "Extruder %s has a different material (%s) as Cura (%s)", index + 1, + self._json_printer_state["heads"][0]["extruders"][index]["active_material"]["GUID"], + material.getMetaDataEntry("GUID")) warnings.append(i18n_catalog.i18nc("@label", "Different material selected for extruder {0}").format(index + 1)) if warnings: @@ -469,7 +474,6 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): icon=QMessageBox.Question, callback=self._configurationMismatchMessageCallback ) - return self.startPrint() From feae612d5511a2a402619b05b501f10241372897 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 12 Sep 2016 10:54:57 +0200 Subject: [PATCH 3/5] Look at the correct stack for variant CURA-2313 --- NetworkPrinterOutputDevice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NetworkPrinterOutputDevice.py b/NetworkPrinterOutputDevice.py index 850e893d96..627f0b7df3 100644 --- a/NetworkPrinterOutputDevice.py +++ b/NetworkPrinterOutputDevice.py @@ -444,7 +444,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): # Check if the right cartridges are loaded. Any failure in these results in a warning. extruder_manager = cura.Settings.ExtruderManager.getInstance() if print_information.materialLengths[index] != 0: - variant = extruder_manager.getExtruderStack(0).findContainer({"type": "variant"}) + variant = extruder_manager.getExtruderStack(index).findContainer({"type": "variant"}) if variant: if variant.getName() != self._json_printer_state["heads"][0]["extruders"][index]["hotend"]["id"]: Logger.log("w", "Extruder %s has a different Cartridge (%s) as Cura (%s)", index + 1, self._json_printer_state["heads"][0]["extruders"][index]["hotend"]["id"], variant.getName()) From f914ef5424308764f0e53c05fbb1fb64909a93bd Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 12 Sep 2016 11:59:25 +0200 Subject: [PATCH 4/5] We now save the auth data right away in order to prevent mismatches CURA-2279 --- NetworkPrinterOutputDevice.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NetworkPrinterOutputDevice.py b/NetworkPrinterOutputDevice.py index 627f0b7df3..956d4bc2e9 100644 --- a/NetworkPrinterOutputDevice.py +++ b/NetworkPrinterOutputDevice.py @@ -755,6 +755,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): global_container_stack.setMetaDataEntry("network_authentication_id", self._authentication_id) else: global_container_stack.addMetaDataEntry("network_authentication_id", self._authentication_id) + Application.getInstance().saveStack(global_container_stack) # Force save so we are sure the data is not lost. Logger.log("i", "Authentication succeeded") else: # Got a response that we didn't expect, so something went wrong. Logger.log("w", "While trying to authenticate, we got an unexpected response: %s", reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)) @@ -775,6 +776,13 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): if "/auth/request" in reply_url: # We got a response to requesting authentication. data = json.loads(bytes(reply.readAll()).decode("utf-8")) + + global_container_stack = Application.getInstance().getGlobalContainerStack() + if global_container_stack: # Remove any old data. + global_container_stack.removeMetaDataEntry("network_authentication_key") + global_container_stack.removeMetaDataEntry("network_authentication_id") + Application.getInstance().saveStack(global_container_stack) # Force saving so we don't keep wrong auth data. + self._authentication_key = data["key"] self._authentication_id = data["id"] Logger.log("i", "Got a new authentication ID. Waiting for authorization: %s", self._authentication_id ) From 1d91827664e0857c0a031ba53db14c819eeb94a8 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 12 Sep 2016 13:31:07 +0200 Subject: [PATCH 5/5] NetworkPrinter now uses printerState to store global state CURA-2235 --- NetworkPrinterOutputDevice.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/NetworkPrinterOutputDevice.py b/NetworkPrinterOutputDevice.py index 956d4bc2e9..919df506d4 100644 --- a/NetworkPrinterOutputDevice.py +++ b/NetworkPrinterOutputDevice.py @@ -364,6 +364,8 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): head_y = self._json_printer_state["heads"][0]["position"]["y"] head_z = self._json_printer_state["heads"][0]["position"]["z"] self._updateHeadPosition(head_x, head_y, head_z) + self._updatePrinterState(self._json_printer_state["status"]) + def close(self): self._updateJobState("") @@ -397,9 +399,9 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): self._error_message = Message(i18n_catalog.i18nc("@info:status", "Unable to start a new print job because the printer is busy. Please check the printer.")) self._error_message.show() return - if self._json_printer_state["status"] != "idle": + if self._printer_state != "idle": self._error_message = Message( - i18n_catalog.i18nc("@info:status", "Unable to start a new print job, printer is busy. Current printer status is %s.") % self._json_printer_state["status"]) + i18n_catalog.i18nc("@info:status", "Unable to start a new print job, printer is busy. Current printer status is %s.") % self._printer_state) self._error_message.show() return elif self._authentication_state != AuthState.Authenticated: