From cda29232e6fdb1c727e3b0a7fe42338c005190c9 Mon Sep 17 00:00:00 2001 From: Guillaume Seguin Date: Sat, 4 Aug 2012 23:15:50 +0200 Subject: [PATCH] Attempt at adding a recover print function --- printcore.py | 4 ++-- pronterface.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) 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()