diff --git a/SM2OutputDeviceManager.py b/SM2OutputDeviceManager.py index 99dc8a4..a80c483 100644 --- a/SM2OutputDeviceManager.py +++ b/SM2OutputDeviceManager.py @@ -117,7 +117,7 @@ def __init__(self, device_id, address, properties={}): self.connectionStateChanged.connect(self._onConnectionStateChanged) - self._progress = PrintJobUploadProgressMessage() + self._progress = PrintJobUploadProgressMessage(self) self._need_auth = PrintJobNeedAuthMessage(self) def _setInterface(self): @@ -264,7 +264,7 @@ def checkAndStartUpload(self): class PrintJobUploadProgressMessage(Message): - def __init__(self): + def __init__(self, device): super().__init__( title = "Sending Print Job", text = "Uploading print job to printer:", @@ -273,6 +273,12 @@ def __init__(self): dismissable = False, use_inactivity_timer = False ) + self._device = device + self._gTimer = QTimer() + self._gTimer.setInterval(3 * 1000) + self._gTimer.timeout.connect(lambda: self._heartbeat()) + self.inactivityTimerStart.connect(self._startTimer) + self.inactivityTimerStop.connect(self._stopTimer) def show(self): self.setProgress(0) @@ -283,6 +289,17 @@ def update(self, percentage: int) -> None: super().show() self.setProgress(percentage) + def _heartbeat(self): + self._device.check_status() + + def _startTimer(self): + if self._gTimer and not self._gTimer.isActive(): + self._gTimer.start() + + def _stopTimer(self): + if self._gTimer and self._gTimer.isActive(): + self._gTimer.stop() + class PrintJobNeedAuthMessage(Message): def __init__(self, device) -> None: diff --git a/plugin.json b/plugin.json index 2466dcd..3c57976 100644 --- a/plugin.json +++ b/plugin.json @@ -1,8 +1,8 @@ { "name": "Snapmaker 2.0 Connection", "author": "https://github.com/macdylan", - "version": "0.1", + "version": "4.0.0", "api": 6, - "supported_sdk_versions": ["6.0.0", "7.0.0"], + "supported_sdk_versions": ["6.0.0", "6.1.0", "6.2.0", "6.3.0", "7.0.0", "7.1.0", "7.2.0", "7.3.0", "7.4.0", "7.5.0"], "description": "Output Device plugin for Snapmaker 2.0" }