Browse Source

Fix setting connection state after re-connect, don't re-register output device

ChrisTerBeke 5 years ago
parent
commit
445fb59c12

+ 9 - 1
plugins/UM3NetworkPrinting/src/UltimakerNetworkedPrinterOutputDevice.py

@@ -44,7 +44,8 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice):
     QUEUED_PRINT_JOBS_STATES = {"queued", "error"}
     
     # Time in seconds since last network response after which we consider this device offline.
-    NETWORK_RESPONSE_CONSIDER_OFFLINE = 10.0
+    # We set this a bit higher than some of the other intervals to make sure they don't overlap.
+    NETWORK_RESPONSE_CONSIDER_OFFLINE = 12.0
 
     def __init__(self, device_id: str, address: str, properties: Dict[bytes, bytes], connection_type: ConnectionType,
                  parent=None) -> None:
@@ -216,6 +217,13 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice):
         if not active_machine:
             return
 
+        # Indicate this device is now connected again.
+        self.setConnectionState(ConnectionState.Connected)
+
+        # If the device was already registered we don't need to register it again.
+        if self.key in CuraApplication.getInstance().getOutputDeviceManager().getOutputDeviceIds():
+            return
+
         # Try for local network device.
         stored_device_id = active_machine.getMetaDataEntry(self.META_NETWORK_KEY)
         if self.key == stored_device_id: