Fix for initial connection

This commit is contained in:
ChrisTerBeke 2019-07-29 21:27:28 +02:00
parent 8360b5b448
commit 4b71b45aa3
2 changed files with 13 additions and 16 deletions

View File

@ -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:

View File

@ -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]]: