diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index 6de665b67f..56ac318f20 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -27,7 +27,7 @@ i18n_catalog = i18nCatalog("cura") @signalemitter class PrinterOutputDevice(QObject, OutputDevice): printersChanged = pyqtSignal() - connectionStateChanged = pyqtSignal() + connectionStateChanged = pyqtSignal(str) def __init__(self, device_id, parent = None): super().__init__(device_id = device_id, parent = parent) @@ -54,8 +54,10 @@ class PrinterOutputDevice(QObject, OutputDevice): def isConnected(self): return self._connection_state != ConnectionState.closed and self._connection_state != ConnectionState.error - def setConnectionState(self, new_state): - self._connection_state = new_state + def setConnectionState(self, connection_state): + if self._connection_state != connection_state: + self._connection_state = connection_state + self.connectionStateChanged.emit(self._id) def _update(self): pass diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 0daf54c018..780a2a05ad 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -133,17 +133,17 @@ class MachineManager(QObject): outputDevicesChanged = pyqtSignal() def _onOutputDevicesChanged(self) -> None: - for printer_output_device in self._printer_output_devices: + '''for printer_output_device in self._printer_output_devices: printer_output_device.hotendIdChanged.disconnect(self._onHotendIdChanged) - printer_output_device.materialIdChanged.disconnect(self._onMaterialIdChanged) + printer_output_device.materialIdChanged.disconnect(self._onMaterialIdChanged)''' self._printer_output_devices.clear() for printer_output_device in Application.getInstance().getOutputDeviceManager().getOutputDevices(): if isinstance(printer_output_device, PrinterOutputDevice): self._printer_output_devices.append(printer_output_device) - printer_output_device.hotendIdChanged.connect(self._onHotendIdChanged) - printer_output_device.materialIdChanged.connect(self._onMaterialIdChanged) + #printer_output_device.hotendIdChanged.connect(self._onHotendIdChanged) + #printer_output_device.materialIdChanged.connect(self._onMaterialIdChanged) self.outputDevicesChanged.emit() diff --git a/plugins/UM3NetworkPrinting/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/UM3OutputDevicePlugin.py index 98fab42a44..09bff8e7b8 100644 --- a/plugins/UM3NetworkPrinting/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/UM3OutputDevicePlugin.py @@ -84,7 +84,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): def _onDeviceConnectionStateChanged(self, key): if key not in self._discovered_devices: return - + print("STATE CHANGED", key) if self._discovered_devices[key].isConnected(): self.getOutputDeviceManager().addOutputDevice(self._discovered_devices[key]) else: @@ -95,8 +95,8 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): Logger.log("d", "zeroconf close...") self._zero_conf.close() - def _onRemoveDevice(self, name): - device = self._discovered_devices.pop(name, None) + def _onRemoveDevice(self, device_id): + device = self._discovered_devices.pop(device_id, None) if device: if device.isConnected(): device.disconnect() @@ -108,10 +108,12 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): # Check what kind of device we need to add; Depending on the firmware we either add a "Connect"/"Cluster" # or "Legacy" UM3 device. cluster_size = int(properties.get(b"cluster_size", -1)) - if cluster_size > 0: + # TODO: For debug purposes; force it to be legacy printer. + device = LegacyUM3OutputDevice.LegacyUM3OutputDevice(name, address, properties) + '''if cluster_size > 0: device = ClusterUM3OutputDevice.ClusterUM3OutputDevice(name, address, properties) else: - device = LegacyUM3OutputDevice.LegacyUM3OutputDevice(name, address, properties) + device = LegacyUM3OutputDevice.LegacyUM3OutputDevice(name, address, properties)''' self._discovered_devices[device.getId()] = device self.discoveredDevicesChanged.emit() diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index e69f7cf4fd..901c8f9fdc 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -12,7 +12,9 @@ import Cura 1.0 as Cura Column { id: printMonitor - property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null + property var connectedDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null + + property var activePrinter: connectedDevice != null ? connectedDevice.activePrinter : null Cura.ExtrudersModel {