Indentation fixes, limit calculations

master
Francesco Santini 2013-04-08 13:06:31 +02:00
parent 360b4f60e4
commit 5a059961fa
4 changed files with 35 additions and 29 deletions

View File

@ -68,7 +68,7 @@ class GCodeAnalyzer():
# find a code in a gstring line
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)
if m == None:
return None
@ -76,7 +76,8 @@ class GCodeAnalyzer():
return m.group(1)
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_m = self.findCode(gcode, "M")
# we have a g_code

View File

@ -31,7 +31,7 @@ class Line(object):
self.relative = False
#ignore host commands
if "@" in self.raw:
if self.raw.startswith("@"):
self.raw = ""
if ";" in self.raw:

View File

@ -250,7 +250,8 @@ class printcore():
try:
self.print_thread.join()
except: pass
except:
pass
self.print_thread = None
@ -349,6 +350,7 @@ class printcore():
#now only "pause" is implemented as host command
def processHostCommand(self, command):
command = command.lstrip()
if command == "@pause":
if self.pronterface != None:
self.pronterface.pause(None)
@ -376,7 +378,7 @@ class printcore():
if self.printing and self.queueindex < len(self.mainqueue):
tline = self.mainqueue[self.queueindex]
#check for host command
if tline.startswith("@"):
if tline.lstrip().startswith("@"):
#it is a host command: pop it from the list
self.mainqueue.pop(self.queueindex)
self.processHostCommand(tline)

View File

@ -134,14 +134,17 @@ class PronterWindow(MainWindow, pronsole.pronsole):
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] 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]
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]
# minimum = offset
self.p.analyzer.minX = self.build_dimensions_list[3]
self.p.analyzer.minY = self.build_dimensions_list[4]
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.homeY = self.build_dimensions_list[7]
self.p.analyzer.homeZ = self.build_dimensions_list[8]