Commit 5a059961 authored by Francesco Santini's avatar Francesco Santini

Indentation fixes, limit calculations

parent 360b4f60
...@@ -68,7 +68,7 @@ class GCodeAnalyzer(): ...@@ -68,7 +68,7 @@ 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.search(pattern, gcode) m=re.search(pattern, gcode)
if m == None: if m == None:
return None return None
...@@ -76,7 +76,8 @@ class GCodeAnalyzer(): ...@@ -76,7 +76,8 @@ class GCodeAnalyzer():
return m.group(1) return m.group(1)
def Analyze(self, gcode): def Analyze(self, gcode):
gcode = gcode[:gcode.find(";")] # remove comments gcode = gcode[:gcode.find(";")].lstrip() # remove comments
if gcode.startswith("@"): return # code is a host command
code_g = self.findCode(gcode, "G") code_g = self.findCode(gcode, "G")
code_m = self.findCode(gcode, "M") code_m = self.findCode(gcode, "M")
# we have a g_code # we have a g_code
......
...@@ -31,7 +31,7 @@ class Line(object): ...@@ -31,7 +31,7 @@ class Line(object):
self.relative = False self.relative = False
#ignore host commands #ignore host commands
if "@" in self.raw: if self.raw.startswith("@"):
self.raw = "" self.raw = ""
if ";" in self.raw: if ";" in self.raw:
......
...@@ -229,16 +229,16 @@ class printcore(): ...@@ -229,16 +229,16 @@ class printcore():
if filename == None: return if filename == None: return
f = None f = None
try: try:
f = open(filename) f = open(filename)
except: except:
pass pass
if f != None: if f != None:
for i in f: for i in f:
l = i.replace("\n", "") l = i.replace("\n", "")
l = l[:l.find(";")] #remove comment l = l[:l.find(";")] #remove comment
self.send_now(l) self.send_now(l)
f.close() f.close()
def pause(self): def pause(self):
"""Pauses the print, saving the current position. """Pauses the print, saving the current position.
...@@ -249,9 +249,10 @@ class printcore(): ...@@ -249,9 +249,10 @@ class printcore():
# try joining the print thread: enclose it in try/except because we might be calling it from the thread itself # try joining the print thread: enclose it in try/except because we might be calling it from the thread itself
try: try:
self.print_thread.join() self.print_thread.join()
except: pass except:
pass
self.print_thread = None self.print_thread = None
# saves the status # saves the status
...@@ -349,11 +350,12 @@ class printcore(): ...@@ -349,11 +350,12 @@ class printcore():
#now only "pause" is implemented as host command #now only "pause" is implemented as host command
def processHostCommand(self, command): def processHostCommand(self, command):
command = command.lstrip()
if command == "@pause": if command == "@pause":
if self.pronterface != None: if self.pronterface != None:
self.pronterface.pause(None) self.pronterface.pause(None)
else: else:
self.pause() self.pause()
def _sendnext(self): def _sendnext(self):
if not self.printer: if not self.printer:
...@@ -376,12 +378,12 @@ class printcore(): ...@@ -376,12 +378,12 @@ class printcore():
if self.printing and self.queueindex < len(self.mainqueue): if self.printing and self.queueindex < len(self.mainqueue):
tline = self.mainqueue[self.queueindex] tline = self.mainqueue[self.queueindex]
#check for host command #check for host command
if tline.startswith("@"): if tline.lstrip().startswith("@"):
#it is a host command: pop it from the list #it is a host command: pop it from the list
self.mainqueue.pop(self.queueindex) self.mainqueue.pop(self.queueindex)
self.processHostCommand(tline) self.processHostCommand(tline)
return return
tline = tline.split(";")[0] tline = tline.split(";")[0]
if len(tline) > 0: if len(tline) > 0:
self._send(tline, self.lineno, True) self._send(tline, self.lineno, True)
......
...@@ -134,14 +134,17 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -134,14 +134,17 @@ class PronterWindow(MainWindow, pronsole.pronsole):
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 #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] if self.build_dimensions_list[0] >= self.build_dimensions_list[6] else self.build_dimensions_list[6] # maximum x is maximum x if maximum X > home X, else it is home X
self.p.analyzer.maxY = self.build_dimensions_list[1] if self.build_dimensions_list[1] >= self.build_dimensions_list[7] else self.build_dimensions_list[7] # minimum = offset
self.p.analyzer.maxZ = self.build_dimensions_list[2] if self.build_dimensions_list[2] >= self.build_dimensions_list[8] else self.build_dimensions_list[8]
self.p.analyzer.minX = self.build_dimensions_list[3] self.p.analyzer.minX = self.build_dimensions_list[3]
self.p.analyzer.minY = self.build_dimensions_list[4] self.p.analyzer.minY = self.build_dimensions_list[4]
self.p.analyzer.minZ = self.build_dimensions_list[5] self.p.analyzer.minZ = self.build_dimensions_list[5]
#max = offset + bedsize
self.p.analyzer.maxX = self.build_dimensions_list[3] + self.build_dimensions_list[0]
self.p.analyzer.maxY = self.build_dimensions_list[4] + self.build_dimensions_list[1]
self.p.analyzer.maxZ = self.build_dimensions_list[5] + self.build_dimensions_list[2]
self.p.analyzer.homeX = self.build_dimensions_list[6] self.p.analyzer.homeX = self.build_dimensions_list[6]
self.p.analyzer.homeY = self.build_dimensions_list[7] self.p.analyzer.homeY = self.build_dimensions_list[7]
self.p.analyzer.homeZ = self.build_dimensions_list[8] self.p.analyzer.homeZ = self.build_dimensions_list[8]
......
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