Fix pause support.

master
daid 2012-09-06 17:24:34 +02:00
parent 1f4835b97e
commit 68f1353e60
2 changed files with 20 additions and 10 deletions

View File

@ -297,9 +297,9 @@ class printWindow(wx.Frame):
def UpdateButtonStates(self): def UpdateButtonStates(self):
self.connectButton.Enable(self.machineCom == None or self.machineCom.isClosedOrError()) self.connectButton.Enable(self.machineCom == None or self.machineCom.isClosedOrError())
#self.loadButton.Enable(self.printIdx == None) #self.loadButton.Enable(self.printIdx == None)
self.printButton.Enable(self.machineCom != None and self.machineCom.isOperational() and not self.machineCom.isPrinting()) self.printButton.Enable(self.machineCom != None and self.machineCom.isOperational() and not (self.machineCom.isPrinting() or self.machineCome.isPaused()))
self.pauseButton.Enable(self.machineCom != None and self.machineCom.isPrinting()) self.pauseButton.Enable(self.machineCom != None and (self.machineCom.isPrinting() or self.machineCome.isPaused()))
self.cancelButton.Enable(self.machineCom != None and self.machineCom.isPrinting()) self.cancelButton.Enable(self.machineCom != None and (self.machineCom.isPrinting() or self.machineCome.isPaused()))
self.temperatureSelect.Enable(self.machineCom != None and self.machineCom.isOperational()) self.temperatureSelect.Enable(self.machineCom != None and self.machineCom.isOperational())
self.bedTemperatureSelect.Enable(self.machineCom != None and self.machineCom.isOperational()) self.bedTemperatureSelect.Enable(self.machineCom != None and self.machineCom.isOperational())
self.directControlPanel.Enable(self.machineCom != None and self.machineCom.isOperational()) self.directControlPanel.Enable(self.machineCom != None and self.machineCom.isOperational())
@ -481,8 +481,7 @@ class printWindow(wx.Frame):
return True return True
def mcLog(self, message): def mcLog(self, message):
#print message print message
pass
def mcTempUpdate(self, temp, bedTemp): def mcTempUpdate(self, temp, bedTemp):
self.temperatureGraph.addPoint(temp, self.temperatureSelect.GetValue(), bedTemp, self.bedTemperatureSelect.GetValue()) self.temperatureGraph.addPoint(temp, self.temperatureSelect.GetValue(), bedTemp, self.bedTemperatureSelect.GetValue())

View File

@ -107,9 +107,10 @@ class MachineCom(object):
STATE_CONNECTING = 2 STATE_CONNECTING = 2
STATE_OPERATIONAL = 3 STATE_OPERATIONAL = 3
STATE_PRINTING = 4 STATE_PRINTING = 4
STATE_CLOSED = 5 STATE_PAUSED = 5
STATE_ERROR = 6 STATE_CLOSED = 6
STATE_CLOSED_WITH_ERROR = 7 STATE_ERROR = 7
STATE_CLOSED_WITH_ERROR = 8
def __init__(self, port = None, baudrate = None, callbackObject = None): def __init__(self, port = None, baudrate = None, callbackObject = None):
if port == None: if port == None:
@ -191,6 +192,8 @@ class MachineCom(object):
return "Operational" return "Operational"
if self._state == self.STATE_PRINTING: if self._state == self.STATE_PRINTING:
return "Printing" return "Printing"
if self._state == self.STATE_PAUSED:
return "Paused"
if self._state == self.STATE_CLOSED: if self._state == self.STATE_CLOSED:
return "Closed" return "Closed"
if self._state == self.STATE_ERROR: if self._state == self.STATE_ERROR:
@ -203,7 +206,7 @@ class MachineCom(object):
return self._state == self.STATE_ERROR or self._state == self.STATE_CLOSED_WITH_ERROR or self._state == self.STATE_CLOSED return self._state == self.STATE_ERROR or self._state == self.STATE_CLOSED_WITH_ERROR or self._state == self.STATE_CLOSED
def isOperational(self): def isOperational(self):
return self._state == self.STATE_OPERATIONAL or self._state == self.STATE_PRINTING return self._state == self.STATE_OPERATIONAL or self._state == self.STATE_PRINTING or self._state == self.STATE_PAUSED
def isPrinting(self): def isPrinting(self):
return self._state == self.STATE_PRINTING return self._state == self.STATE_PRINTING
@ -212,7 +215,7 @@ class MachineCom(object):
return self._gcodePos return self._gcodePos
def isPaused(self): def isPaused(self):
return False return self._state == self.STATE_PAUSED
def getTemp(self): def getTemp(self):
return self._temp return self._temp
@ -376,6 +379,14 @@ class MachineCom(object):
def cancelPrint(self): def cancelPrint(self):
if self.isOperational(): if self.isOperational():
self._changeState(self.STATE_OPERATIONAL) self._changeState(self.STATE_OPERATIONAL)
def setPause(self, pause):
if not pause and self.isPaused():
self._changeState(self.STATE_PRINTING)
for i in xrange(0, 6):
self._sendNext()
if pause and self.isPrinting():
self._changeState(self.STATE_PAUSED)
def getExceptionString(): def getExceptionString():
locationInfo = traceback.extract_tb(sys.exc_info()[2])[0] locationInfo = traceback.extract_tb(sys.exc_info()[2])[0]