From b55b9f6730e2359eea0035d11408bb3a9fd746b8 Mon Sep 17 00:00:00 2001 From: Youness Alaoui Date: Fri, 22 May 2015 13:06:21 -0400 Subject: [PATCH] Add Pause support to serial communication which adds a pause button to UI --- Cura/serialCommunication.py | 4 ++++ Cura/util/printerConnection/serialConnection.py | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Cura/serialCommunication.py b/Cura/serialCommunication.py index efc6e72d..4add5f23 100644 --- a/Cura/serialCommunication.py +++ b/Cura/serialCommunication.py @@ -68,6 +68,10 @@ class serialComm(object): self._comm.sendCommand(line[1]) elif line[0] == 'START': self._comm.printGCode(self._gcodeList) + elif line[0] == 'PAUSE': + self._comm.setPause(True) + elif line[0] == 'RESUME': + self._comm.setPause(False) else: sys.stderr.write(str(line)) diff --git a/Cura/util/printerConnection/serialConnection.py b/Cura/util/printerConnection/serialConnection.py index 2495f77a..6f5d1a8d 100644 --- a/Cura/util/printerConnection/serialConnection.py +++ b/Cura/util/printerConnection/serialConnection.py @@ -97,13 +97,26 @@ class serialConnection(printerConnectionBase.printerConnectionBase): #Abort the previously loaded print file def cancelPrint(self): - if not self.isPrinting()or self._process is None: + if not self.isPrinting() or self._process is None: return self._process.stdin.write('STOP\n') self._printProgress = 0 def isPrinting(self): - return self._commState == machineCom.MachineCom.STATE_PRINTING + return self._commState == machineCom.MachineCom.STATE_PRINTING or self.isPaused() + + #Returns true if we have the ability to pause the file printing. + def hasPause(self): + return True + + def isPaused(self): + return self._commState == machineCom.MachineCom.STATE_PAUSED + + #Pause or unpause the printing depending on the value, if supported. + def pause(self, value): + if not self.isPrinting() or self._process is None: + return + self._process.stdin.write('PAUSE\n' if value else "RESUME\n") #Amount of progression of the current print file. 0.0 to 1.0 def getPrintProgress(self): -- 2.30.2