chiark / gitweb /
Add Pause support to serial communication which adds a pause button to UI
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Fri, 22 May 2015 17:06:21 +0000 (13:06 -0400)
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Fri, 22 May 2015 17:06:21 +0000 (13:06 -0400)
Cura/serialCommunication.py
Cura/util/printerConnection/serialConnection.py

index efc6e72d38f0836722117a5cca9effd2348faa53..4add5f2314d8c1efd58ac48055ecc5fae0d08a05 100644 (file)
@@ -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))
 
index 2495f77a3c087040a2fc767c6c9b492ced7ce230..6f5d1a8df0bf67c262edf04a502be87a473efedf 100644 (file)
@@ -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):