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

This commit is contained in:
ChrisTerBeke 2019-08-12 23:22:16 +02:00
parent 2ed3af5989
commit 445fb59c12
No known key found for this signature in database
GPG key ID: A49F1AB9D7E0C263

View file

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