Skip to content

Commit

Permalink
qtplasmac: gcode filter
Browse files Browse the repository at this point in the history
fix feed rate
fix paramater check
attempt better line number reporting
  • Loading branch information
phillc54 committed Aug 5, 2023
1 parent de3b0fa commit 357942c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 22 deletions.
2 changes: 1 addition & 1 deletion share/qtvcp/screens/qtplasmac/qtplasmac_handler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = '1.236.279'
VERSION = '1.236.280'

'''
qtplasmac_handler.py
Expand Down
7 changes: 7 additions & 0 deletions share/qtvcp/screens/qtplasmac/versions.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ <h2>QtPlasmaC Version History</h2>
</table>
<br>
<!--- ****** ADD NEXT VERSION BELOW THIS LINE ****** --->
<br><b><u>v1.236.280 2023 Aug 05</u></b>
<ul style="margin:0;">
<li>gcode filter: fix feed rate check</li>
<li>gcode filter: fix paramater check</li>
<li>gcode filter: attempt better line number reporting</li>
</ul>

<br><b><u>v1.236.279 2023 Aug 03</u></b>
<ul style="margin:0;">
<li>fix multi g/m codes in line in gcode filter</li>
Expand Down
53 changes: 32 additions & 21 deletions src/emc/usr_intf/qtplasmac/qtplasmac_gcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def check_math(self, data, axis):
'''
tmp1 = data.split(axis)[1]
if tmp1.startswith('[') or tmp1.startswith('#'):
self.codeError = True
self.set_code_error()
if self.lineNum not in self.errorMath:
self.errorMath.append(self.lineNum)
self.errorLines.append(self.lineNumOrg)
Expand Down Expand Up @@ -432,14 +432,18 @@ def illegal_character(self, data):
if not '=' in code:
err = 5
else:
# left = parameter, right = value (we don't process right side yet)
left, right = code.split('=')
# named parameter is missing a chevron
if left[0] == '<' and not '>' in left:
err = 6
# numbered parameter is not a number
elif left[0] != '<' and not left.isdigit():
err =7
try:
# left = parameter, right = value (we don't process right side yet)
left, right = code.split('=')
# named parameter is missing a chevron
if left[0] == '<' and not '>' in left:
err = 6
# numbered parameter is not a number
elif left[0] != '<' and not left.isdigit():
err = 7
except:
# parameter has no value
err = 8
if err:
errs= [None]
errs.append('single character line with invalid character')
Expand All @@ -449,10 +453,11 @@ def illegal_character(self, data):
errs.append('parameter is missing equals sign')
errs.append('named parameter is missing a chevron')
errs.append('numbered parameter is not a number')
errs.append('parameter has no value')
self.codeWarn = True
self.warnChar.append(self.lineNum)
self.errorLines.append(self.lineNumOrg)
self.gcodeList.append(f';{errs[err]} in: {data}')
self.gcodeList.append(f';{data} |{errs[err]}')
return err

def remove_line_numbers(self, data):
Expand Down Expand Up @@ -513,7 +518,7 @@ def set_first_move(self):
self.zSetup = True

def set_no_first_move(self):
self.codeError = True
self.set_code_error()
self.errorFirstMove.append(self.lineNum)
self.errorLines.append(self.lineNumOrg)

Expand Down Expand Up @@ -626,11 +631,12 @@ def comment_z_commands(self, data):

def check_f_word(self, data):
begin, inFeed = data.split('F', 1)
inFeed = inFeed.replace(' ','')
# if feed rate from material file
if inFeed.startswith('#<_hal[plasmac.cut-feed-rate]>'):
# change feed rate if g-code file not in same units as machine units
if self.unitMultiplier != 1:
data = f'{begin}F[#<_hal[plasmac.cut-feed-rate]> * {self.unitMultiplier}]\n'
data = f'{begin}F[#<_hal[plasmac.cut-feed-rate]> * {self.unitMultiplier}]'
return data
# if explicit feed rate
rawFeed = ''
Expand Down Expand Up @@ -879,7 +885,7 @@ def do_material_change(self, data):
code = data.replace('M190', '').strip()
# check for missing p or material
if not len(code) or code[0] != 'P' or code == 'P':
self.codeError = True
self.set_code_error()
self.errorNoMat.append(self.lineNum)
self.errorLines.append(self.lineNumOrg)
return
Expand All @@ -889,15 +895,15 @@ def do_material_change(self, data):
except:
num = -2
if num < -1:
self.codeError = True
self.set_code_error()
self.errorBadMat.append(self.lineNum)
self.errorLines.append(self.lineNumOrg)
return
self.currentMaterial[0] = num
self.currentMaterial[1] = True
# check if material exists in dict
if self.currentMaterial[0] not in self.materialDict and self.currentMaterial[0] < 1000000 and self.currentMaterial[0] != -1:
self.codeError = True
self.set_code_error()
self.errorMissMat.append(self.lineNum)
self.errorLines.append(self.lineNumOrg)
return
Expand All @@ -907,7 +913,7 @@ def do_material_change(self, data):

def material_change_wait(self):
if self.offsetG4x:
self.codeError = True
self.set_code_error()
self.errorCompMat.append(self.lineNum)
self.errorLines.append(self.lineNumOrg)

Expand Down Expand Up @@ -982,17 +988,17 @@ def check_material_edit(self, data):
if newMaterial[0] == 0:
self.set_temporary_material(newMaterial)
elif nu in self.materialDict and newMaterial[0] == 1:
self.codeError = True
self.set_code_error()
self.errorNewMat.append(self.lineNum)
self.errorLines.append(self.lineNumOrg)
else:
self.rewrite_material_file(data, newMaterial)
else:
self.codeError = True
self.set_code_error()
self.errorEditMat.append(self.lineNum)
self.errorLines.append(self.lineNumOrg)
except:
self.codeError = True
self.set_code_error()
self.errorLines.append(self.lineNumOrg)

def set_temporary_material(self, data):
Expand Down Expand Up @@ -1075,7 +1081,7 @@ def write_one_material(self, mat, file, err):
file.write(f'CUT_MODE = {mat[15]}\n')
file.write('\n')
except:
self.codeError = True
self.set_code_error()
err.append(self.lineNum)
self.errorLines.append(self.lineNumOrg)

Expand Down Expand Up @@ -1113,7 +1119,7 @@ def get_materials(self):
elif data.startswith('KERF_WIDTH'):
kWidth = float(data.split('=')[1].strip())
except:
self.codeError = True
self.set_code_error()
self.errorReadMat.append(self.lineNum)
self.errorLines.append(self.lineNumOrg)

Expand All @@ -1122,6 +1128,11 @@ def get_materials(self):
# ERROR AND WARNING MESSAGING
##############################################################################

def set_code_error(self):
if not self.codeError:
self.lineNum -= 1
self.codeError = True

def write_errors(self):
errorText = ''
warnText = ''
Expand Down

0 comments on commit 357942c

Please sign in to comment.