diff --git a/DuetRRFOutputDevice.py b/DuetRRFOutputDevice.py index 5efd2fd..ea9e708 100644 --- a/DuetRRFOutputDevice.py +++ b/DuetRRFOutputDevice.py @@ -79,6 +79,11 @@ def __init__( self._stream = None self._cleanupRequest() + if hasattr(self, '_message'): + self._message.hide() + self._message = None + + def _timestamp(self): return ("time", datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S')) @@ -173,6 +178,9 @@ def onFilenameAccepted(self): self._send('connect', [("password", self._duet_password), self._timestamp()], self.onConnected) def onConnected(self): + if self._stage != OutputStage.writing: + return + Logger.log("d", "Connected") Logger.log("d", "Uploading...") @@ -182,6 +190,9 @@ def onConnected(self): self._send('upload', [("name", "0:/gcodes/" + self._fileName), self._timestamp()], self.onUploadDone, self._postData) def onUploadDone(self): + if self._stage != OutputStage.writing: + return + Logger.log("d", "Upload done") self._stream.close() @@ -212,10 +223,16 @@ def onUploadDone(self): self._cleanupRequest() def onReadyToPrint(self): + if self._stage != OutputStage.writing: + return + Logger.log("d", "Ready to print") self._send('gcode', [("gcode", "M32 /gcodes/" + self._fileName)], self.onPrintStarted) def onPrintStarted(self): + if self._stage != OutputStage.writing: + return + Logger.log("d", "Print started") if self._device_type == DeviceType.simulate: @@ -234,16 +251,25 @@ def onPrintStarted(self): self._cleanupRequest() def onSimulatedPrintFinished(self): + if self._stage != OutputStage.writing: + return + Logger.log("d", "Simulation print finished") self._send('gcode', [("gcode", "M37 S0")], self.onSimulationStopped) def onCheckStatus(self): + if self._stage != OutputStage.writing: + return + Logger.log("d", "Check status") self._send('status', [("type", "3")], self.onStatusReceived) def onStatusReceived(self): + if self._stage != OutputStage.writing: + return + Logger.log("d", "Status received") status_bytes = bytes(self._reply.readAll()) @@ -260,16 +286,25 @@ def onStatusReceived(self): self.onSimulatedPrintFinished() def onSimulationStopped(self): + if self._stage != OutputStage.writing: + return + Logger.log("d", "Simulation stopped") self._send('gcode', [("gcode", "M37")], self.onReporting) def onReporting(self): + if self._stage != OutputStage.writing: + return + Logger.log("d", "Reporting") self._send('reply', [], self.onReported) def onReported(self): + if self._stage != OutputStage.writing: + return + Logger.log("d", "Reported") self._send('disconnect') diff --git a/plugin.json b/plugin.json index 8b54a69..2449f2c 100644 --- a/plugin.json +++ b/plugin.json @@ -2,6 +2,6 @@ "name": "DuetRRF", "author": "Thomas Kriechbaumer", "description": "Provides direct upload of gcode to DuetRRF.", - "version": "0.0.5", + "version": "0.0.6", "api": 4 }