Commit 00f1306f authored by fsantini's avatar fsantini

Bugfixes in the analyzer

Pause code (Ported from RepetierHost, untested)
parent 6cf08006
...@@ -58,6 +58,9 @@ class GCodeAnalyzer(): ...@@ -58,6 +58,9 @@ class GCodeAnalyzer():
self.maxX = 150 self.maxX = 150
self.maxY = 150 self.maxY = 150
self.maxZ = 150 self.maxZ = 150
self.minX = 0
self.minY = 0
self.minZ = 0
self.hasHomeX = False self.hasHomeX = False
self.hasHomeY = False self.hasHomeY = False
self.hasHomeZ = False self.hasHomeZ = False
...@@ -65,8 +68,8 @@ class GCodeAnalyzer(): ...@@ -65,8 +68,8 @@ class GCodeAnalyzer():
# find a code in a gstring line # find a code in a gstring line
def findCode(self, gcode, codeStr): def findCode(self, gcode, codeStr):
pattern = re.compile(codeStr + "s*([\d.]*)",re.I) pattern = re.compile(codeStr + "\\s*([\d.-]*)",re.I)
m=re.match(pattern, gcode) m=re.search(pattern, gcode)
if m == None: if m == None:
return None return None
else: else:
...@@ -85,7 +88,7 @@ class GCodeAnalyzer(): ...@@ -85,7 +88,7 @@ class GCodeAnalyzer():
self.lastY = self.y self.lastY = self.y
self.lastZ = self.z self.lastZ = self.z
self.lastE = self.e self.lastE = self.e
eChanged = false; eChanged = False;
code_f = self.findCode(gcode, "F") code_f = self.findCode(gcode, "F")
if code_f != None: if code_f != None:
self.f=float(code_f) self.f=float(code_f)
...@@ -94,7 +97,7 @@ class GCodeAnalyzer(): ...@@ -94,7 +97,7 @@ class GCodeAnalyzer():
code_y = self.findCode(gcode, "Y") code_y = self.findCode(gcode, "Y")
code_z = self.findCode(gcode, "Z") code_z = self.findCode(gcode, "Z")
code_e = self.findCode(gcode, "E") code_e = self.findCode(gcode, "E")
if self.relative: if self.relative:
if code_x != None: self.x += float(code_x) if code_x != None: self.x += float(code_x)
if code_y != None: self.y += float(code_y) if code_y != None: self.y += float(code_y)
...@@ -120,7 +123,15 @@ class GCodeAnalyzer(): ...@@ -120,7 +123,15 @@ class GCodeAnalyzer():
if self.e != self.eOffset + e: if self.e != self.eOffset + e:
eChanged = True eChanged = True
self.e = self.eOffset + e self.e = self.eOffset + e
#Repetier has a bunch of limit-checking code here and time calculations: we are leaving them for now #limit checking
if self.x < self.minX: self.x = self.minX
if self.y < self.minY: self.y = self.minY
if self.z < self.minZ: self.z = self.minZ
if self.x > self.maxX: self.x = self.maxX
if self.y > self.maxY: self.y = self.maxY
if self.z > self.maxZ: self.z = self.maxZ
#Repetier has a bunch of limit-checking code here and time calculations: we are leaving them for now
elif code_g == 28 or code_g == 161: elif code_g == 28 or code_g == 161:
self.lastX = self.x self.lastX = self.x
self.lastY = self.y self.lastY = self.y
...@@ -193,5 +204,8 @@ class GCodeAnalyzer(): ...@@ -193,5 +204,8 @@ class GCodeAnalyzer():
code_m = int(code_m) code_m = int(code_m)
if code_m == 82: self.eRelative = False if code_m == 82: self.eRelative = False
elif code_m == 83: self.eRelative = True elif code_m == 83: self.eRelative = True
def print_status(self):
attrs = vars(self)
print '\n'.join("%s: %s" % item for item in attrs.items())
\ No newline at end of file
...@@ -70,8 +70,9 @@ class printcore(): ...@@ -70,8 +70,9 @@ class printcore():
self.print_thread = None self.print_thread = None
if port is not None and baud is not None: if port is not None and baud is not None:
self.connect(port, baud) self.connect(port, baud)
self.analyzer = GCodeAnalyzer() self.analyzer = GCodeAnalyzer()
self.xy_feedrate = None
self.z_feedrate = None
def disconnect(self): def disconnect(self):
"""Disconnects from printer and pauses the print """Disconnects from printer and pauses the print
...@@ -229,10 +230,38 @@ class printcore(): ...@@ -229,10 +230,38 @@ class printcore():
self.printing = False self.printing = False
self.print_thread.join() self.print_thread.join()
self.print_thread = None self.print_thread = None
# saves the status
self.pauseX = analyzer.x-analyzer.xOffset;
self.pauseY = analyzer.y-analyzer.yOffset;
self.pauseZ = analyzer.z-analyzer.zOffset;
self.pauseE = analyzer.e-analyzer.eOffset;
self.pauseF = analyzer.f;
self.pauseRelative = analyzer.relative;
def resume(self): def resume(self):
"""Resumes a paused print. """Resumes a paused print.
""" """
if self.paused:
#restores the status
self.send("G90") # go to absolute coordinates
xyFeedString = ""
zFeedString = ""
if self.xy_feedrate != None: xyFeedString = " F" + str(self.xy_feedrate)
if self.z_feedrate != None: zFeedString = " F" + str(self.z_feedrate)
self.send("G1 X" + str(self.pauseX) + " Y" + str(self.pauseY) + xyFeedString)
self.send("G1 Z" + str(self.pauseZ) + zFeedString)
self.send("G92 E" + str(self.pauseE))
if self.pauseRelative: self.send("G91") # go back to relative if needed
#reset old feed rate
self.send("G1 F" + str(self.pauseF))
self.paused = False self.paused = False
self.printing = True self.printing = True
self.print_thread = Thread(target = self._print) self.print_thread = Thread(target = self._print)
......
...@@ -128,6 +128,23 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -128,6 +128,23 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.btndict = {} self.btndict = {}
self.parse_cmdline(sys.argv[1:]) self.parse_cmdline(sys.argv[1:])
self.build_dimensions_list = self.get_build_dimensions(self.settings.build_dimensions) self.build_dimensions_list = self.get_build_dimensions(self.settings.build_dimensions)
#initialize the code analyzer with the correct sizes. There must be a more general way to do so
self.p.analyzer.maxX = self.build_dimensions_list[0];
self.p.analyzer.maxY = self.build_dimensions_list[1];
self.p.analyzer.maxZ = self.build_dimensions_list[2];
self.p.analyzer.homeX = self.build_dimensions_list[3];
self.p.analyzer.homeY = self.build_dimensions_list[4];
self.p.analyzer.homeZ = self.build_dimensions_list[5];
self.p.analyzer.print_status()
#set feedrates in printcore for pause/resume
self.p.xy_feedrate = self.settings.xy_feedrate
self.p.z_feedrate = self.settings.z_feedrate
self.panel.SetBackgroundColour(self.settings.bgcolor) self.panel.SetBackgroundColour(self.settings.bgcolor)
customdict = {} customdict = {}
try: try:
......
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