mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Fix not registering cloud output device for every machine
This commit is contained in:
parent
3f82cd4916
commit
5403f5241b
2 changed files with 18 additions and 9 deletions
|
@ -88,7 +88,6 @@ class CloudOutputDeviceManager:
|
||||||
# We only add when is_online as we don't want the option in the drop down if the cluster is not online.
|
# We only add when is_online as we don't want the option in the drop down if the cluster is not online.
|
||||||
for added_cluster in added_clusters:
|
for added_cluster in added_clusters:
|
||||||
device = CloudOutputDevice(self._api, added_cluster)
|
device = CloudOutputDevice(self._api, added_cluster)
|
||||||
self._output_device_manager.addOutputDevice(device)
|
|
||||||
self._remote_clusters[added_cluster.cluster_id] = device
|
self._remote_clusters[added_cluster.cluster_id] = device
|
||||||
|
|
||||||
for device, cluster in updates:
|
for device, cluster in updates:
|
||||||
|
@ -103,17 +102,20 @@ class CloudOutputDeviceManager:
|
||||||
Logger.log("d", "no active machine")
|
Logger.log("d", "no active machine")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Remove all output devices that we have registered.
|
||||||
|
for stored_cluster_id in self._remote_clusters:
|
||||||
|
self._output_device_manager.removeOutputDevice(stored_cluster_id)
|
||||||
|
|
||||||
# Check if the stored cluster_id for the active machine is in our list of remote clusters.
|
# Check if the stored cluster_id for the active machine is in our list of remote clusters.
|
||||||
stored_cluster_id = active_machine.getMetaDataEntry(self.META_CLUSTER_ID)
|
stored_cluster_id = active_machine.getMetaDataEntry(self.META_CLUSTER_ID)
|
||||||
if stored_cluster_id in self._remote_clusters:
|
if stored_cluster_id in self._remote_clusters:
|
||||||
device = self._remote_clusters[stored_cluster_id]
|
device = self._remote_clusters[stored_cluster_id]
|
||||||
if not device.isConnected():
|
self._connectToOutputDevice(device)
|
||||||
device.connect()
|
Logger.log("d", "Device connected by metadata cluster ID %s", stored_cluster_id)
|
||||||
Logger.log("d", "Device connected by metadata %s", stored_cluster_id)
|
|
||||||
else:
|
else:
|
||||||
self._connectByNetworkKey(active_machine)
|
self._connectByNetworkKey(active_machine)
|
||||||
|
|
||||||
## Tries to match the
|
## Tries to match the local network key to the cloud cluster host name.
|
||||||
def _connectByNetworkKey(self, active_machine: GlobalStack) -> None:
|
def _connectByNetworkKey(self, active_machine: GlobalStack) -> None:
|
||||||
# Check if the active printer has a local network connection and match this key to the remote cluster.
|
# Check if the active printer has a local network connection and match this key to the remote cluster.
|
||||||
local_network_key = active_machine.getMetaDataEntry("um_network_key")
|
local_network_key = active_machine.getMetaDataEntry("um_network_key")
|
||||||
|
@ -124,9 +126,15 @@ class CloudOutputDeviceManager:
|
||||||
if not device:
|
if not device:
|
||||||
return
|
return
|
||||||
|
|
||||||
active_machine.setMetaDataEntry(self.META_CLUSTER_ID, device.key)
|
|
||||||
device.connect()
|
|
||||||
Logger.log("i", "Found cluster %s with network key %s", device, local_network_key)
|
Logger.log("i", "Found cluster %s with network key %s", device, local_network_key)
|
||||||
|
active_machine.setMetaDataEntry(self.META_CLUSTER_ID, device.key)
|
||||||
|
self._connectToOutputDevice(device)
|
||||||
|
|
||||||
|
## Connects to an output device and makes sure it is registered in the output device manager.
|
||||||
|
def _connectToOutputDevice(self, device: CloudOutputDevice) -> None:
|
||||||
|
if not device.isConnected():
|
||||||
|
device.connect()
|
||||||
|
self._output_device_manager.addOutputDevice(device)
|
||||||
|
|
||||||
## Handles an API error received from the cloud.
|
## Handles an API error received from the cloud.
|
||||||
# \param errors: The errors received
|
# \param errors: The errors received
|
||||||
|
|
|
@ -389,8 +389,9 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
||||||
|
|
||||||
## Called when the connection to the cluster changes.
|
## Called when the connection to the cluster changes.
|
||||||
def connect(self) -> None:
|
def connect(self) -> None:
|
||||||
super().connect()
|
# super().connect()
|
||||||
self.sendMaterialProfiles()
|
# self.sendMaterialProfiles()
|
||||||
|
pass
|
||||||
|
|
||||||
def _onGetPreviewImageFinished(self, reply: QNetworkReply) -> None:
|
def _onGetPreviewImageFinished(self, reply: QNetworkReply) -> None:
|
||||||
reply_url = reply.url().toString()
|
reply_url = reply.url().toString()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue