diff --git a/plugins/UM3NetworkPrinting/src/UltimakerNetworkedPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/src/UltimakerNetworkedPrinterOutputDevice.py index 13aa0d7063..c05945c356 100644 --- a/plugins/UM3NetworkPrinting/src/UltimakerNetworkedPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/UltimakerNetworkedPrinterOutputDevice.py @@ -45,10 +45,6 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice): # States indicating if a print job is queued. QUEUED_PRINT_JOBS_STATES = {"queued", "error"} - # Time in seconds since last network response after which we consider this device offline. - # We set this a bit higher than some of the other intervals to make sure they don't overlap. - NETWORK_RESPONSE_CONSIDER_OFFLINE = 10.0 # seconds - def __init__(self, device_id: str, address: str, properties: Dict[bytes, bytes], connection_type: ConnectionType, parent=None) -> None: @@ -87,6 +83,8 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice): # The job upload progress message modal. self._progress = PrintJobUploadProgressMessage() + self._timeout_time = 30 + @pyqtProperty(str, constant=True) def address(self) -> str: """The IP address of the printer.""" @@ -213,8 +211,8 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice): return Duration(seconds).getDisplayString(DurationFormat.Format.Short) def _update(self) -> None: - self._checkStillConnected() super()._update() + self._checkStillConnected() def _checkStillConnected(self) -> None: """Check if we're still connected by comparing the last timestamps for network response and the current time. @@ -224,7 +222,8 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice): TODO: it would be nice to have this logic in the managers, but connecting those with signals causes crashes. """ time_since_last_response = time() - self._time_of_last_response - if time_since_last_response > self.NETWORK_RESPONSE_CONSIDER_OFFLINE: + if time_since_last_response > self._timeout_time: + Logger.log("d", "It has been %s seconds since the last response for outputdevice %s, so assume a timeout", time_since_last_response, self.key) self.setConnectionState(ConnectionState.Closed) if self.key in CuraApplication.getInstance().getOutputDeviceManager().getOutputDeviceIds(): CuraApplication.getInstance().getOutputDeviceManager().removeOutputDevice(self.key) @@ -241,6 +240,7 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice): return # Indicate this device is now connected again. + Logger.log("d", "Reconnecting output device after timeout.") self.setConnectionState(ConnectionState.Connected) # If the device was already registered we don't need to register it again.