Skip to content

Commit

Permalink
WIP #575: implement untested !! and // support in pronterface & pronsole
Browse files Browse the repository at this point in the history
  • Loading branch information
iXce committed Nov 3, 2014
1 parent 1340bd2 commit 07af3e4
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 19 deletions.
52 changes: 39 additions & 13 deletions printrun/pronsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ def do_pause(self, l):
def help_pause(self):
self.log(_("Pauses a running print"))

def pause(self, event):
def pause(self, event = None):
return self.do_pause(None)

def do_resume(self, l):
Expand Down Expand Up @@ -1217,20 +1217,46 @@ def recvcb_report(self, l):
self.m105_waitcycles = 0
return isreport

def recvcb(self, l):
report_type = self.recvcb_report(l)
if report_type & REPORT_TEMP:
self.status.update_tempreading(l)
tstring = l.rstrip()
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))
def recvcb_actions(self, l):
if l.startswith("!!"):
self.do_pause(None)
msg = l.split(" ", 1)[1]
if self.silent is False: self.logError(msg.ljust(15))
sys.stdout.write(self.promptf())
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):
layerz = self.fgcode.all_layers[newlayer].z
Expand Down
41 changes: 35 additions & 6 deletions printrun/pronterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ def endupload(self):
self.p.clear = True
self.uploading = False

def pause(self, event):
def pause(self, event = None):
if not self.paused:
self.log(_("Print paused at: %s") % format_time(time.time()))
if self.sdprinting:
Expand Down Expand Up @@ -1671,17 +1671,46 @@ def update_pos(self):
if y is not None: self.current_pos[1] = y
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):
l = l.rstrip()
if l.startswith("!!"):
return
report_type = self.recvcb_report(l)
isreport = report_type != REPORT_NONE
if report_type == REPORT_POS:
if report_type & REPORT_POS:
self.update_pos()
elif report_type == REPORT_TEMP:
elif report_type & REPORT_TEMP:
wx.CallAfter(self.tempdisp.SetLabel, self.tempreadings.strip().replace("ok ", ""))
self.update_tempdisplay()
tstring = l.rstrip()
if not self.p.loud and (tstring not in ["ok", "wait"] and not isreport):
wx.CallAfter(self.addtexttolog, tstring + "\n")
if not self.p.loud and (l not in ["ok", "wait"] and not isreport):
wx.CallAfter(self.addtexttolog, l + "\n")
for listener in self.recvlisteners:
listener(l)

Expand Down

0 comments on commit 07af3e4

Please sign in to comment.