Commit 07af3e4d authored by Guillaume Seguin's avatar Guillaume Seguin

WIP #575: implement untested !! and // support in pronterface & pronsole

parent 1340bd2f
...@@ -1039,7 +1039,7 @@ class pronsole(cmd.Cmd): ...@@ -1039,7 +1039,7 @@ class pronsole(cmd.Cmd):
def help_pause(self): def help_pause(self):
self.log(_("Pauses a running print")) self.log(_("Pauses a running print"))
def pause(self, event): def pause(self, event = None):
return self.do_pause(None) return self.do_pause(None)
def do_resume(self, l): def do_resume(self, l):
...@@ -1217,20 +1217,46 @@ class pronsole(cmd.Cmd): ...@@ -1217,20 +1217,46 @@ class pronsole(cmd.Cmd):
self.m105_waitcycles = 0 self.m105_waitcycles = 0
return isreport return isreport
def recvcb(self, l): def recvcb_actions(self, l):
report_type = self.recvcb_report(l) if l.startswith("!!"):
if report_type & REPORT_TEMP: self.do_pause(None)
self.status.update_tempreading(l) msg = l.split(" ", 1)[1]
tstring = l.rstrip() if self.silent is False: self.logError(msg.ljust(15))
for listener in self.recvlisteners:
listener(l)
if tstring != "ok" and not self.sdlisting \
and not self.monitoring and (report_type == REPORT_NONE or report_type & REPORT_MANUAL):
if tstring[:5] == "echo:":
tstring = tstring[5:].lstrip()
if self.silent is False: self.log("\r" + tstring.ljust(15))
sys.stdout.write(self.promptf()) sys.stdout.write(self.promptf())
sys.stdout.flush() sys.stdout.flush()
return True
elif l.startswith("//"):
command = l.split(" ", 1)[1]
self.log(_("Received command %s") % command)
command = command.split(":")
if len(command) == 2 and command[0] == "action":
command = command[1]
if command == "pause":
self.do_pause(None)
return True
elif command == "resume":
self.do_resume(None)
return True
elif command == "disconnect":
self.do_disconnect(None)
return True
return False
def recvcb(self, l):
l = l.rstrip()
if not self.recvcb_actions(l):
report_type = self.recvcb_report(l)
if report_type & REPORT_TEMP:
self.status.update_tempreading(l)
for listener in self.recvlisteners:
listener(l)
if l != "ok" and not self.sdlisting \
and not self.monitoring and (report_type == REPORT_NONE or report_type & REPORT_MANUAL):
if l[:5] == "echo:":
l = l[5:].lstrip()
if self.silent is False: self.log("\r" + l.ljust(15))
sys.stdout.write(self.promptf())
sys.stdout.flush()
def layer_change_cb(self, newlayer): def layer_change_cb(self, newlayer):
layerz = self.fgcode.all_layers[newlayer].z layerz = self.fgcode.all_layers[newlayer].z
......
...@@ -1171,7 +1171,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>.""" ...@@ -1171,7 +1171,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self.p.clear = True self.p.clear = True
self.uploading = False self.uploading = False
def pause(self, event): def pause(self, event = None):
if not self.paused: if not self.paused:
self.log(_("Print paused at: %s") % format_time(time.time())) self.log(_("Print paused at: %s") % format_time(time.time()))
if self.sdprinting: if self.sdprinting:
...@@ -1671,17 +1671,46 @@ Printrun. If not, see <http://www.gnu.org/licenses/>.""" ...@@ -1671,17 +1671,46 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
if y is not None: self.current_pos[1] = y if y is not None: self.current_pos[1] = y
if z is not None: self.current_pos[2] = z if z is not None: self.current_pos[2] = z
def recvcb_actions(self, l):
if l.startswith("!!"):
if not self.paused:
self.pause()
msg = l.split(" ", 1)[1]
if not self.p.loud:
wx.CallAfter(self.addtexttolog, msg + "\n")
return True
elif l.startswith("//"):
command = l.split(" ", 1)[1]
self.log(_("Received command %s") % command)
command = command.split(":")
if len(command) == 2 and command[0] == "action":
command = command[1]
if command == "pause":
if not self.paused:
self.pause()
return True
elif command == "resume":
if self.paused:
self.do_resume(None)
return True
elif command == "disconnect":
self.do_disconnect(None)
return True
return False
def recvcb(self, l): def recvcb(self, l):
l = l.rstrip()
if l.startswith("!!"):
return
report_type = self.recvcb_report(l) report_type = self.recvcb_report(l)
isreport = report_type != REPORT_NONE isreport = report_type != REPORT_NONE
if report_type == REPORT_POS: if report_type & REPORT_POS:
self.update_pos() self.update_pos()
elif report_type == REPORT_TEMP: elif report_type & REPORT_TEMP:
wx.CallAfter(self.tempdisp.SetLabel, self.tempreadings.strip().replace("ok ", "")) wx.CallAfter(self.tempdisp.SetLabel, self.tempreadings.strip().replace("ok ", ""))
self.update_tempdisplay() self.update_tempdisplay()
tstring = l.rstrip() if not self.p.loud and (l not in ["ok", "wait"] and not isreport):
if not self.p.loud and (tstring not in ["ok", "wait"] and not isreport): wx.CallAfter(self.addtexttolog, l + "\n")
wx.CallAfter(self.addtexttolog, tstring + "\n")
for listener in self.recvlisteners: for listener in self.recvlisteners:
listener(l) listener(l)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment