Attempt at adding a recover print function

master
Guillaume Seguin 2012-08-04 23:15:50 +02:00
parent e046dc8016
commit cda29232e6
2 changed files with 21 additions and 2 deletions

View File

@ -185,7 +185,7 @@ class printcore():
def _checksum(self, command):
return reduce(lambda x,y:x^y, map(ord, command))
def startprint(self,data):
def startprint(self, data, startindex = 0):
"""Start a print, data is an array of gcode commands.
returns True on success, False if already printing.
The print queue will be replaced with the contents of the data array, the next line will be set to 0 and the firmware notified.
@ -196,7 +196,7 @@ class printcore():
self.printing = True
self.mainqueue = [] + data
self.lineno = 0
self.queueindex = 0
self.queueindex = startindex
self.resendfrom = -1
self._send("M110", -1, True)
if len(data) == 0:

View File

@ -1697,8 +1697,27 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.status_thread = threading.Thread(target = self.statuschecker)
self.status_thread.start()
def recover(self, event):
self.extra_print_time = 0
if not self.p.online:
wx.CallAfter(self.status.SetStatusText,_("Not connected to printer."))
return
# Reset Z
self.p.send_now("G92 Z" + self.predisconnect_layer)
# Home X and Y
self.p.send_now("G28 X Y")
self.on_startprint()
self.p.startprint(self.predisconnect_mainqueue)
def store_predisconnect_state(self):
self.predisconnect_mainqueue = self.p.mainqueue
self.predisconnect_queueindex = self.p.queueindex
self.predisconnect_layer = self.curlayer
def disconnect(self,event):
print _("Disconnected.")
if self.p.printing or self.p.paused or self.paused:
self.store_predisconnect_state()
self.p.disconnect()
self.statuscheck = False
self.status_thread.join()