Commit f6fbb75d authored by Guillaume Seguin's avatar Guillaume Seguin

Pass parsed gcoder line to sendcb

parent 36688d2f
...@@ -563,14 +563,16 @@ class printcore(): ...@@ -563,14 +563,16 @@ class printcore():
if self.printer: if self.printer:
self.sent.append(command) self.sent.append(command)
# run the command through the analyzer # run the command through the analyzer
try: self.analyzer.append(command, store = False) gline = None
try:
gline = self.analyzer.append(command, store = False)
except: except:
logging.warning(_("Could not analyze command %s:") % command + logging.warning(_("Could not analyze command %s:") % command +
"\n" + traceback.format_exc()) "\n" + traceback.format_exc())
if self.loud: if self.loud:
logging.info("SENT: %s" % command) logging.info("SENT: %s" % command)
if self.sendcb: if self.sendcb:
try: self.sendcb(command) try: self.sendcb(command, gline)
except: pass except: pass
try: try:
self.printer.write(str(command + "\n")) self.printer.write(str(command + "\n"))
......
...@@ -277,11 +277,10 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -277,11 +277,10 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if self.filename: if self.filename:
self.printbtn.Enable() self.printbtn.Enable()
def sentcb(self, line): def sentcb(self, line, gline):
gline = gcoder.Line(line) if not gline:
split_raw = gcoder.split(gline) pass
gcoder.parse_coordinates(gline, split_raw, imperial = False) elif gline.is_move:
if gline.is_move:
if gline.z is not None: if gline.z is not None:
layer = gline.z layer = gline.z
if layer != self.curlayer: if layer != self.curlayer:
...@@ -289,14 +288,12 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -289,14 +288,12 @@ class PronterWindow(MainWindow, pronsole.pronsole):
wx.CallAfter(self.gviz.clearhilights) wx.CallAfter(self.gviz.clearhilights)
wx.CallAfter(self.gviz.setlayer, layer) wx.CallAfter(self.gviz.setlayer, layer)
elif gline.command in ["M104", "M109"]: elif gline.command in ["M104", "M109"]:
gcoder.parse_coordinates(gline, split_raw, imperial = False, force = True)
gline_s = gcoder.S(gline) gline_s = gcoder.S(gline)
if gline_s is not None: if gline_s is not None:
temp = gline_s temp = gline_s
if self.display_gauges: wx.CallAfter(self.hottgauge.SetTarget, temp) if self.display_gauges: wx.CallAfter(self.hottgauge.SetTarget, temp)
if self.display_graph: wx.CallAfter(self.graph.SetExtruder0TargetTemperature, temp) if self.display_graph: wx.CallAfter(self.graph.SetExtruder0TargetTemperature, temp)
elif gline.command in ["M140", "M190"]: elif gline.command in ["M140", "M190"]:
gline.parse_coordinates(gline, split_raw, imperial = False, force = True)
gline_s = gcoder.S(gline) gline_s = gcoder.S(gline)
if gline_s is not None: if gline_s is not None:
temp = gline_s temp = gline_s
...@@ -305,8 +302,6 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -305,8 +302,6 @@ class PronterWindow(MainWindow, pronsole.pronsole):
elif gline.command.startswith("T"): elif gline.command.startswith("T"):
tool = gline.command[1:] tool = gline.command[1:]
if hasattr(self, "extrudersel"): wx.CallAfter(self.extrudersel.SetValue, tool) if hasattr(self, "extrudersel"): wx.CallAfter(self.extrudersel.SetValue, tool)
else:
return
self.sentlines.put_nowait(line) self.sentlines.put_nowait(line)
def is_excluded_move(self, gline): def is_excluded_move(self, gline):
......
...@@ -285,7 +285,7 @@ class Prontserve(pronsole.pronsole, EventEmitter): ...@@ -285,7 +285,7 @@ class Prontserve(pronsole.pronsole, EventEmitter):
if l!="ok" and not l.startswith("ok T") and not l.startswith("T:"): if l!="ok" and not l.startswith("ok T") and not l.startswith("T:"):
self.async(self._receive_printer_error, l) self.async(self._receive_printer_error, l)
def sendcb(self, l): def sendcb(self, l, gl):
# Monitor the sent commands for new extruder target temperatures # Monitor the sent commands for new extruder target temperatures
if ("M109" in l) or ("M104" in l) or ("M140" in l) or ("M190" in l): if ("M109" in l) or ("M104" in l) or ("M140" in l) or ("M190" in l):
temp = float(re.search('S([0-9]+)', l).group(1)) temp = float(re.search('S([0-9]+)', l).group(1))
......
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