diff --git a/printcore.py b/printcore.py index 166c7dc..789f4a9 100755 --- a/printcore.py +++ b/printcore.py @@ -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: diff --git a/pronterface.py b/pronterface.py index 0982f1d..d64b56c 100755 --- a/pronterface.py +++ b/pronterface.py @@ -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()