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

@ -229,16 +229,16 @@ class printcore():
if filename == None: return
f = None
try:
f = open(filename)
f = open(filename)
except:
pass
if f != None:
for i in f:
l = i.replace("\n", "")
l = l[:l.find(";")] #remove comment
self.send_now(l)
f.close()
pass
if f != None:
for i in f:
l = i.replace("\n", "")
l = l[:l.find(";")] #remove comment
self.send_now(l)
f.close()
def pause(self):
"""Pauses the print, saving the current position.
@ -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:
self.print_thread.join()
except: pass
self.print_thread.join()
except:
pass
self.print_thread = None
# saves the status
@ -349,11 +350,12 @@ 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)
else:
self.pause()
if self.pronterface != None:
self.pronterface.pause(None)
else:
self.pause()
def _sendnext(self):
if not self.printer:
@ -376,12 +378,12 @@ class printcore():
if self.printing and self.queueindex < len(self.mainqueue):
tline = self.mainqueue[self.queueindex]
#check for host command
if tline.startswith("@"):
#it is a host command: pop it from the list
self.mainqueue.pop(self.queueindex)
self.processHostCommand(tline)
return
if tline.lstrip().startswith("@"):
#it is a host command: pop it from the list
self.mainqueue.pop(self.queueindex)
self.processHostCommand(tline)
return
tline = tline.split(";")[0]
if len(tline) > 0:
self._send(tline, self.lineno, True)

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]