Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
send heartbeat to screen while uploading
Browse files Browse the repository at this point in the history
  • Loading branch information
macdylan committed May 5, 2021
1 parent 3e9cc8f commit f6a70f7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
21 changes: 19 additions & 2 deletions SM2OutputDeviceManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:",
Expand All @@ -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)
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit f6a70f7

Please sign in to comment.