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' ))
4879tmpMatNum = 1000000
4980tmpMatNam = ''
5081prefsFile = 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 )
5283cutType = 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 )
5485currentMat = 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' , '#' )
6186response = RUN (['halcmd' , 'getp' , 'plasmac.max-offset' ], capture_output = True )
6287zMaxOffset = float (response .stdout .decode ())
63- RUN (['halcmd' , 'setp' , 'qtplasmac.conv_block_loaded' , '0' ])
88+ RUN (['halcmd' , 'setp' , '{}' . format ( convBlockPin ) , '0' ])
6489metric = ['mm' , 4 ]
6590imperial = ['in' , 6 ]
6691units , precision = imperial if ini .find ('TRAJ' , 'LINEAR_UNITS' ).lower () == 'inch' else metric
107132convBlock = False
108133filtered = False
109134firstMove = 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 '
112135codeError = False
113136errors = 'The following errors will affect the process.\n '
114137errors += '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 ('\n number={}\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 ('\n number={}\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