Skip to content

Commit 979139a

Browse files
committed
qtplasmac: make gcode filter more generic
1 parent 458d668 commit 979139a

3 files changed

Lines changed: 81 additions & 50 deletions

File tree

share/qtvcp/screens/qtplasmac/qtplasmac_handler.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = '1.227.216'
1+
VERSION = '1.227.217'
22

33
'''
44
qtplasmac_handler.py
@@ -4303,29 +4303,29 @@ def material_temp_pin_changed(self, halpin):
43034303
for line in f_in:
43044304
if line.startswith('name'):
43054305
t_name = line.split('=')[1].strip()
4306-
if line.startswith('kerf-width'):
4306+
if line.startswith('kerf_width'):
43074307
k_width = float(line.split('=')[1].strip())
4308-
elif line.startswith('pierce-height'):
4308+
elif line.startswith('pierce_height'):
43094309
p_height = float(line.split('=')[1].strip())
4310-
elif line.startswith('pierce-delay'):
4310+
elif line.startswith('pierce_delay'):
43114311
p_delay = float(line.split('=')[1].strip())
4312-
elif line.startswith('puddle-jump-height'):
4312+
elif line.startswith('puddle_jump_height'):
43134313
pj_height = float(line.split('=')[1].strip())
4314-
elif line.startswith('puddle-jump-delay'):
4314+
elif line.startswith('puddle_jump_delay'):
43154315
pj_delay = float(line.split('=')[1].strip())
4316-
elif line.startswith('cut-height'):
4316+
elif line.startswith('cut_height'):
43174317
c_height = float(line.split('=')[1].strip())
4318-
elif line.startswith('cut-feed-rate'):
4318+
elif line.startswith('cut_speed'):
43194319
c_speed = float(line.split('=')[1].strip())
4320-
elif line.startswith('cut-amps'):
4320+
elif line.startswith('cut_amps'):
43214321
c_amps = float(line.split('=')[1].strip())
4322-
elif line.startswith('cut-volts'):
4322+
elif line.startswith('cut_volts'):
43234323
c_volts = float(line.split('=')[1].strip())
4324-
elif line.startswith('pause-at-end'):
4324+
elif line.startswith('pause_at_end'):
43254325
pause = float(line.split('=')[1].strip())
4326-
elif line.startswith('gas-pressure'):
4326+
elif line.startswith('gas_pressure'):
43274327
g_press = float(line.split('=')[1].strip())
4328-
elif line.startswith('cut-mode'):
4328+
elif line.startswith('cut_mode'):
43294329
c_mode = float(line.split('=')[1].strip())
43304330
self.write_materials(halpin, t_name, k_width, p_height, \
43314331
p_delay, pj_height, pj_delay, c_height, c_speed, \

share/qtvcp/screens/qtplasmac/versions.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ <h2>QtPlasmaC Version History</h2>
3030
</table>
3131
<br>
3232
<!--- ****** ADD NEXT VERSION BELOW THIS LINE ****** --->
33+
<br><b><u>v1.227.217 2022 July 12</u></b>
34+
<ul style="margin:0;">
35+
<li>make gcode filter more generic</li>
36+
</ul>
37+
3338
<br><b><u>v1.227.216 2022 July 08</u></b>
3439
<ul style="margin:0;">
3540
<li>conv_line: fix start point</li>

src/emc/usr_intf/qtplasmac/qtplasmac_gcode.py

Lines changed: 63 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,51 @@
4141
for line in inCode:
4242
print(line.strip())
4343
sys.exit()
44-
filteredBkp = '/tmp/qtplasmac/filtered_bkp.ngc'
45-
errorFile = '/tmp/qtplasmac/gcode_errors.txt'
46-
materialFile = '{}_material.cfg'.format(ini.find('EMC', 'MACHINE'))
47-
tmpMaterialFile = '/tmp/qtplasmac/{}_material.gcode'.format(ini.find('EMC', 'MACHINE'))
44+
# assume gui to be qtplasmac unless a specific gui selected
45+
if 'axis' in ini.find('DISPLAY', 'DISPLAY'):
46+
gui = 'plasmac'
47+
materialFile = '{}.mats'.format(ini.find('EMC', 'MACHINE'))
48+
tmpPath = '/tmp/plasmac'
49+
cutTypePin = 'axisui.cut-type'
50+
matNumPin = 'axisui.material-change-number'
51+
convBlockPin = 'axisui.conv-block-loaded'
52+
matTmpPin = 'axisui.material-temp'
53+
matReloadPin = 'axisui.material-reload'
54+
fgColor = '#ffee00'
55+
bgColor = '#050505'
56+
bgAltColor = '#36362e'
57+
notice = 'The line numbers in the original file may differ from what is shown below.\n\n'
58+
else:
59+
gui = 'qtplasmac'
60+
materialFile = '{}_material.cfg'.format(ini.find('EMC', 'MACHINE'))
61+
tmpPath = '/tmp/qtplasmac'
62+
cutTypePin = 'qtplasmac.cut_type'
63+
matNumPin = 'qtplasmac.material_change_number'
64+
convBlockPin = 'qtplasmac.conv_block_loaded'
65+
matTmpPin = 'qtplasmac.material_temp'
66+
matReloadPin = 'qtplasmac.material_reload'
67+
response = RUN(['halcmd', 'getp', 'qtplasmac.color_fg'], capture_output = True)
68+
fgColor = str(hex(int(response.stdout.decode()))).replace('0x', '#')
69+
response = RUN(['halcmd', 'getp', 'qtplasmac.color_bg'], capture_output = True)
70+
bgColor = str(hex(int(response.stdout.decode()))).replace('0x', '#')
71+
response = RUN(['halcmd', 'getp', 'qtplasmac.color_bgalt'], capture_output = True)
72+
bgAltColor = str(hex(int(response.stdout.decode()))).replace('0x', '#')
73+
response = RUN(['halcmd', 'getp', 'plasmac.max-offset'], capture_output = True)
74+
notice = 'If the G-code editor is used to resolve the following issues, the lines with errors\n'
75+
notice += 'will be highlighted. The line numbers may differ from what is shown below.\n\n'
76+
filteredBkp = '{}/filtered_bkp.ngc'.format(tmpPath)
77+
errorFile = '{}/gcode_errors.txt'.format(tmpPath)
78+
tmpMaterialFile = '{}/{}_material.gcode'.format(tmpPath, ini.find('EMC', 'MACHINE'))
4879
tmpMatNum = 1000000
4980
tmpMatNam = ''
5081
prefsFile = ini.find('EMC', 'MACHINE') + '.prefs'
51-
response = RUN(['halcmd', 'getp', 'qtplasmac.cut_type'], capture_output = True)
82+
response = RUN(['halcmd', 'getp', '{}'.format(cutTypePin)], capture_output = True)
5283
cutType = int(response.stdout.decode())
53-
response = RUN(['halcmd', 'getp', 'qtplasmac.material_change_number'], capture_output = True)
84+
response = RUN(['halcmd', 'getp', '{}'.format(matNumPin)], capture_output = True)
5485
currentMat = int(response.stdout.decode())
55-
response = RUN(['halcmd', 'getp', 'qtplasmac.color_fg'], capture_output = True)
56-
fgColor = str(hex(int(response.stdout.decode()))).replace('0x', '#')
57-
response = RUN(['halcmd', 'getp', 'qtplasmac.color_bg'], capture_output = True)
58-
bgColor = str(hex(int(response.stdout.decode()))).replace('0x', '#')
59-
response = RUN(['halcmd', 'getp', 'qtplasmac.color_bgalt'], capture_output = True)
60-
bgAltColor = str(hex(int(response.stdout.decode()))).replace('0x', '#')
6186
response = RUN(['halcmd', 'getp', 'plasmac.max-offset'], capture_output = True)
6287
zMaxOffset = float(response.stdout.decode())
63-
RUN(['halcmd', 'setp', 'qtplasmac.conv_block_loaded', '0'])
88+
RUN(['halcmd', 'setp', '{}'.format(convBlockPin), '0'])
6489
metric = ['mm', 4]
6590
imperial = ['in', 6]
6691
units, precision = imperial if ini.find('TRAJ', 'LINEAR_UNITS').lower() == 'inch' else metric
@@ -107,8 +132,6 @@
107132
convBlock = False
108133
filtered = False
109134
firstMove = False
110-
notice = 'If the G-code editor is used to resolve the following issues, the lines with errors\n'
111-
notice += 'will be highlighted. The line numbers may differ from what is shown below.\n\n'
112135
codeError = False
113136
errors = 'The following errors will affect the process.\n'
114137
errors += 'Errors must be fixed before reloading this file.\n'
@@ -463,7 +486,7 @@ def do_material_change():
463486
codeError = True
464487
errorMissMat.append(lineNum)
465488
errorLines.append(lineNumOrg)
466-
RUN(['halcmd', 'setp', 'qtplasmac.material_change_number', '{}'.format(material[0])])
489+
RUN(['halcmd', 'setp', '{}'.format(matNumPin), '{}'.format(material[0])])
467490
if not firstMaterial:
468491
firstMaterial = material[0]
469492
gcodeList.append(line)
@@ -559,29 +582,32 @@ def write_temporary_material(data):
559582
global lineNum, lineNumOrg, errorLines, errorTempMat, warnMatLoad, material, codeError
560583
try:
561584
with open(tmpMaterialFile, 'w') as fWrite:
562-
fWrite.write('#plasmac temporary material file\n')
563-
fWrite.write('\nnumber={}\n'.format(tmpMatNum))
585+
if gui == 'plasmac':
586+
fWrite.write('[MATERIAL_NUMBER_{}]\n'.format(tmpMatNum))
587+
else:
588+
fWrite.write('#plasmac temporary material file\n')
589+
fWrite.write('\nnumber={}\n'.format(tmpMatNum))
564590
fWrite.write('name={}\n'.format(tmpMatNam))
565-
fWrite.write('kerf-width={}\n'.format(data[3]))
566-
fWrite.write('thc-enable={}\n'.format(data[4]))
567-
fWrite.write('pierce-height={}\n'.format(data[5]))
568-
fWrite.write('pierce-delay={}\n'.format(data[6]))
569-
fWrite.write('puddle-jump-height={}\n'.format(data[7]))
570-
fWrite.write('puddle-jump-delay={}\n'.format(data[8]))
571-
fWrite.write('cut-height={}\n'.format(data[9]))
572-
fWrite.write('cut-feed-rate={}\n'.format(data[10]))
573-
fWrite.write('cut-amps={}\n'.format(data[11]))
574-
fWrite.write('cut-volts={}\n'.format(data[12]))
575-
fWrite.write('pause-at-end={}\n'.format(data[13]))
576-
fWrite.write('gas-pressure={}\n'.format(data[14]))
577-
fWrite.write('cut-mode={}\n'.format(data[15]))
591+
fWrite.write('kerf_width={}\n'.format(data[3]))
592+
fWrite.write('thc_enable={}\n'.format(data[4]))
593+
fWrite.write('pierce_height={}\n'.format(data[5]))
594+
fWrite.write('pierce_delay={}\n'.format(data[6]))
595+
fWrite.write('puddle_jump_height={}\n'.format(data[7]))
596+
fWrite.write('puddle_jump_delay={}\n'.format(data[8]))
597+
fWrite.write('cut_height={}\n'.format(data[9]))
598+
fWrite.write('cut_speed={}\n'.format(data[10]))
599+
fWrite.write('cut_amps={}\n'.format(data[11]))
600+
fWrite.write('cut_volts={}\n'.format(data[12]))
601+
fWrite.write('pause_at_end={}\n'.format(data[13]))
602+
fWrite.write('gas_pressure={}\n'.format(data[14]))
603+
fWrite.write('cut_mode={}\n'.format(data[15]))
578604
fWrite.write('\n')
579605
except:
580606
codeError = True
581607
errorTempMat.append(lineNum)
582608
errorLines.append(lineNumOrg)
583609
materialDict[tmpMatNum] = [data[10], data[3]]
584-
RUN(['halcmd', 'setp', 'qtplasmac.material_temp', '{}'.format(tmpMatNum)])
610+
RUN(['halcmd', 'setp', '{}'.format(matTmpPin), '{}'.format(tmpMatNum)])
585611
material[0] = tmpMatNum
586612
matDelay = time.time()
587613
while 1:
@@ -590,7 +616,7 @@ def write_temporary_material(data):
590616
warnMatLoad.append(lineNum)
591617
errorLines.append(lineNumOrg)
592618
break
593-
response = RUN(['halcmd', 'getp', 'qtplasmac.material_temp'], capture_output = True)
619+
response = RUN(['halcmd', 'getp', '{}'.format(matTmpPin)], capture_output = True)
594620
if not int(response.stdout.decode()):
595621
break
596622

@@ -626,7 +652,7 @@ def rewrite_material_file(newMaterial):
626652
add_edit_material(newMaterial, outFile)
627653
inFile.close()
628654
outFile.close()
629-
RUN(['halcmd', 'setp', 'qtplasmac.material_reload', '1'])
655+
RUN(['halcmd', 'setp', '{}'.format(matReloadPin), '1'])
630656
get_materials()
631657
matDelay = time.time()
632658
while 1:
@@ -635,7 +661,7 @@ def rewrite_material_file(newMaterial):
635661
warnMatLoad.append(lineNum)
636662
errorLines.append(lineNumOrg)
637663
break
638-
response = RUN(['halcmd', 'getp', 'qtplasmac.material_reload'], capture_output = True)
664+
response = RUN(['halcmd', 'getp', '{}'.format(matReloadPin)], capture_output = True)
639665
if not int(response.stdout.decode()):
640666
break
641667

@@ -799,7 +825,7 @@ def message_set(msgType, msg):
799825
# check if original is a conversational block
800826
if line.startswith(';conversational block'):
801827
convBlock = True
802-
RUN(['halcmd', 'setp', 'qtplasmac.conv_block_loaded', '1'])
828+
RUN(['halcmd', 'setp', '{}'.format(convBlockPin), '1'])
803829
# remove whitespace and trailing periods
804830
line = line.strip().rstrip('.')
805831
# remove line numbers
@@ -1119,7 +1145,7 @@ def message_set(msgType, msg):
11191145
gcodeList.append('#<holes>=0 (disable hole sensing)')
11201146
holeEnable = False
11211147
if firstMaterial:
1122-
RUN(['halcmd', 'setp', 'qtplasmac.material_change_number', '{}'.format(firstMaterial)])
1148+
RUN(['halcmd', 'setp', '{}'.format(matNumPin), '{}'.format(firstMaterial)])
11231149
gcodeList.append(line)
11241150
continue
11251151
# check feed rate

0 commit comments

Comments
 (0)