From ec63d6931edbebdab5f3d9a5a435f46dee6c13f5 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 5 Oct 2016 14:54:22 +0200 Subject: [PATCH 1/5] Actually perform the filtering based on machine type CURA-2475 --- DiscoverUM3Action.py | 3 +++ NetworkPrinterOutputDevice.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/DiscoverUM3Action.py b/DiscoverUM3Action.py index 3d69a8c118..8213812391 100644 --- a/DiscoverUM3Action.py +++ b/DiscoverUM3Action.py @@ -75,7 +75,10 @@ class DiscoverUM3Action(MachineAction): @pyqtProperty("QVariantList", notify = printersChanged) def foundDevices(self): if self._network_plugin: + global_printer_type = Application.getInstance().getGlobalContainerStack().getBottom().getId() printers = list(self._network_plugin.getPrinters().values()) + # TODO; There are still some testing printers that don't have a correct printer type, so don't filter out unkown ones just yet. + printers = [printer for printer in printers if printer.printerType == global_printer_type or printer.printerType == "unknown"] printers.sort(key = lambda k: k.name) return printers else: diff --git a/NetworkPrinterOutputDevice.py b/NetworkPrinterOutputDevice.py index f57637af1f..3d56a777aa 100644 --- a/NetworkPrinterOutputDevice.py +++ b/NetworkPrinterOutputDevice.py @@ -168,9 +168,9 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): printer_type = self._properties.get(b"machine", b"").decode("utf-8") if printer_type == "9511.0": - self._updatePrinterType("UM3Extended") + self._updatePrinterType("ultimaker3_extended") elif printer_type == "9066.0": - self._updatePrinterType("UM3") + self._updatePrinterType("ultimaker3") else: self._updatePrinterType("unknown") From f71b23c72aadf3b179e81d5fc691da164b8af1e7 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 6 Oct 2016 09:35:31 +0200 Subject: [PATCH 2/5] Added handling for if there is no global stack CURA-2475 --- DiscoverUM3Action.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/DiscoverUM3Action.py b/DiscoverUM3Action.py index 8213812391..7d7484f7af 100644 --- a/DiscoverUM3Action.py +++ b/DiscoverUM3Action.py @@ -75,7 +75,11 @@ class DiscoverUM3Action(MachineAction): @pyqtProperty("QVariantList", notify = printersChanged) def foundDevices(self): if self._network_plugin: - global_printer_type = Application.getInstance().getGlobalContainerStack().getBottom().getId() + if Application.getInstance().getGlobalContainerStack(): + global_printer_type = Application.getInstance().getGlobalContainerStack().getBottom().getId() + else: + global_printer_type = "unknown" + printers = list(self._network_plugin.getPrinters().values()) # TODO; There are still some testing printers that don't have a correct printer type, so don't filter out unkown ones just yet. printers = [printer for printer in printers if printer.printerType == global_printer_type or printer.printerType == "unknown"] From 2688928467d602d808cbe2d5efaddae9bd98a946 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 6 Oct 2016 11:30:56 +0200 Subject: [PATCH 3/5] Revision number is no longer taken into account CURA-2475 --- DiscoverUM3Action.py | 2 +- NetworkPrinterOutputDevice.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DiscoverUM3Action.py b/DiscoverUM3Action.py index 7d7484f7af..c192d36ac1 100644 --- a/DiscoverUM3Action.py +++ b/DiscoverUM3Action.py @@ -79,7 +79,7 @@ class DiscoverUM3Action(MachineAction): global_printer_type = Application.getInstance().getGlobalContainerStack().getBottom().getId() else: global_printer_type = "unknown" - + printers = list(self._network_plugin.getPrinters().values()) # TODO; There are still some testing printers that don't have a correct printer type, so don't filter out unkown ones just yet. printers = [printer for printer in printers if printer.printerType == global_printer_type or printer.printerType == "unknown"] diff --git a/NetworkPrinterOutputDevice.py b/NetworkPrinterOutputDevice.py index 3d56a777aa..2eb126d966 100644 --- a/NetworkPrinterOutputDevice.py +++ b/NetworkPrinterOutputDevice.py @@ -167,9 +167,9 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): self._compressing_print = False printer_type = self._properties.get(b"machine", b"").decode("utf-8") - if printer_type == "9511.0": + if printer_type.startswith("9511"): self._updatePrinterType("ultimaker3_extended") - elif printer_type == "9066.0": + elif printer_type.startswith("9066"): self._updatePrinterType("ultimaker3") else: self._updatePrinterType("unknown") From 93891490647952219ba75e6a698137b753dcd7a8 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 6 Oct 2016 11:36:26 +0200 Subject: [PATCH 4/5] Type name display is now also updated in print discovery CURA-2475 --- DiscoverUM3Action.qml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/DiscoverUM3Action.qml b/DiscoverUM3Action.qml index 79f52460de..06b701605e 100644 --- a/DiscoverUM3Action.qml +++ b/DiscoverUM3Action.qml @@ -228,7 +228,26 @@ Cura.MachineAction { width: parent.width * 0.5 wrapMode: Text.WordWrap - text: true ? catalog.i18nc("@label", "Ultimaker 3") : catalog.i18nc("@label", "Ultimaker 3 Extended") + text: + { + if(base.selectedPrinter) + { + if(base.selectedPrinter.printerType == "ultimaker3") + { + return catalog.i18nc("@label", "Ultimaker 3") + } else if(base.selectedPrinter.printerType == "ultimaker3_extended") + { + return catalog.i18nc("@label", "Ultimaker 3 Extended") + } else + { + return catalog.i18nc("@label", "Unknown") // We have no idea what type it is. Should not happen 'in the field' + } + } + else + { + return "" + } + } } Label { From afd5df283c5f09dc821dfde4bdc9c0549f76e95f Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 6 Oct 2016 14:33:42 +0200 Subject: [PATCH 5/5] Re-filter list of printers when you open the window When you open the window of a printer that already exists, it doesn't re-create the entire window and therefore didn't re-apply the filter on machine type. This triggers the filter to be applied again. Contributes to issue CURA-2475. --- DiscoverUM3Action.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/DiscoverUM3Action.py b/DiscoverUM3Action.py index c192d36ac1..c4ffdb8472 100644 --- a/DiscoverUM3Action.py +++ b/DiscoverUM3Action.py @@ -39,6 +39,11 @@ class DiscoverUM3Action(MachineAction): self._network_plugin.printerListChanged.connect(self._onPrinterDiscoveryChanged) self.printersChanged.emit() + ## Re-filters the list of printers. + @pyqtSlot() + def reset(self): + self.printersChanged.emit() + @pyqtSlot() def restartDiscovery(self): # Ensure that there is a bit of time after a printer has been discovered.