From 4b71b45aa3a01c6ba9c660b1029cae0fe5f5071b Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Mon, 29 Jul 2019 21:27:28 +0200 Subject: [PATCH] Fix for initial connection --- .../src/Cloud/CloudOutputDeviceManager.py | 13 +++++-------- .../src/Network/NetworkOutputDeviceManager.py | 16 ++++++++-------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py index e6ed31219c..b6964c7a9c 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py @@ -126,15 +126,12 @@ class CloudOutputDeviceManager: Logger.log("e", "Could not find discovered device with key [%s]", key) return - group_name = device.clusterData.friendly_name - machine_type_id = device.printerType - - Logger.log("i", "Creating machine from cloud device with key = [%s], group name = [%s], printer type = [%s]", - key, group_name, machine_type_id) - # The newly added machine is automatically activated. - CuraApplication.getInstance().getMachineManager().addMachine(machine_type_id, group_name) - self._connectToActiveMachine() + CuraApplication.getInstance().getMachineManager().addMachine(device.printerType, + device.clusterData.friendly_name) + active_machine = CuraApplication.getInstance().getGlobalContainerStack() + if active_machine: + self._connectToOutputDevice(device, active_machine) ## Callback for when the active machine was changed by the user or a new remote cluster was found. def _connectToActiveMachine(self) -> None: diff --git a/plugins/UM3NetworkPrinting/src/Network/NetworkOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Network/NetworkOutputDeviceManager.py index fb660610e3..5b97bc90f2 100644 --- a/plugins/UM3NetworkPrinting/src/Network/NetworkOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Network/NetworkOutputDeviceManager.py @@ -231,16 +231,16 @@ class NetworkOutputDeviceManager: ## Create a machine instance based on the discovered network printer. def _createMachineFromDiscoveredPrinter(self, key: str) -> None: - discovered_device = self._discovered_devices.get(key) - if discovered_device is None: + device = self._discovered_devices.get(key) + if device is None: Logger.log("e", "Could not find discovered device with key [%s]", key) return - group_name = discovered_device.getProperty("name") - machine_type_id = discovered_device.getProperty("printer_type") - Logger.log("i", "Creating machine from network device with key = [%s], group name = [%s], printer type = [%s]", - key, group_name, machine_type_id) - CuraApplication.getInstance().getMachineManager().addMachine(machine_type_id, group_name) - self._connectToActiveMachine() + + # The newly added machine is automatically activated. + CuraApplication.getInstance().getMachineManager().addMachine(device.printerType, device.name) + active_machine = CuraApplication.getInstance().getGlobalContainerStack() + if active_machine: + self._connectToOutputDevice(device, active_machine) ## Load the user-configured manual devices from Cura preferences. def _getStoredManualInstances(self) -> Dict[str, Optional[Callable]]: