def write_temp_default_material(data): with open(tmpMaterialFile, 'w') as fWrite: fWrite.write('#plasmac temporary material file\n') fWrite.write('\nnumber={}\n'.format(tmpMatNum)) fWrite.write('name={}\n'.format(tmpMatNam)) fWrite.write('kerf-width={}\n'.format(data[3])) fWrite.write('thc-enable={}\n'.format(data[4])) fWrite.write('pierce-height={}\n'.format(data[5])) fWrite.write('pierce-delay={}\n'.format(data[6])) fWrite.write('puddle-jump-height={}\n'.format(data[7])) fWrite.write('puddle-jump-delay={}\n'.format(data[8])) fWrite.write('cut-height={}\n'.format(data[9])) fWrite.write('cut-feed-rate={}\n'.format(data[10])) fWrite.write('cut-amps={}\n'.format(data[11])) fWrite.write('cut-volts={}\n'.format(data[12])) fWrite.write('pause-at-end={}\n'.format(data[13])) fWrite.write('gas-pressure={}\n'.format(data[14])) fWrite.write('cut-mode={}\n'.format(data[15])) fWrite.write('\n') hal.set_p('qtplasmac.material_temp', '{}'.format(tmpMatNum)) matDelay = time.time() while 1: if time.time() > matDelay + 3: codeWarn = True dlg = '\nTemporary materials was not loaded in a timely manner:\n' dlg += '\nTry to reload the G-Code file.\n' dialog_box('WARNING', dlg) break if not hal.get_value('qtplasmac.material_temp'): break
def __init__(self, halcomp,builder,useropts): self.plasmacVersion = 'PlasmaC v0.174' self.W = gtk.Window() self.halcomp = halcomp self.builder = builder self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) hal_glib.GPin(halcomp.newpin('config-disable', hal.HAL_BIT, hal.HAL_IN)) configDisable = self.i.find('PLASMAC', 'CONFIG_DISABLE') or '0' hal.set_p('plasmac_config.config-disable',configDisable) self.idlePin = hal_glib.GPin(halcomp.newpin('program-is-idle', hal.HAL_BIT, hal.HAL_IN)) hal.connect('plasmac_config.program-is-idle', 'plasmac:program-is-idle') self.idlePin.connect('value-changed', self.idle_changed) self.thcFeedRate = (float(self.i.find('AXIS_Z', 'MAX_VELOCITY')) * \ float(self.i.find('AXIS_Z', 'OFFSET_AV_RATIO'))) * 60 self.configFile = self.i.find('EMC', 'MACHINE').lower() + '_config.cfg' self.prefFile = self.i.find('EMC', 'MACHINE') + '.pref' self.configDict = {} self.oldMode = 9 self.materialsUpdate = False self.maxHeight = hal.get_value('ini.z.max_limit') - hal.get_value('ini.z.min_limit') self.configure_widgets() self.builder.get_object('probe-feed-rate-adj').set_upper(self.builder.get_object('setup-feed-rate').get_value()) self.load_settings() self.set_theme() gobject.timeout_add(100, self.periodic)
def __init__(self, halcomp,builder,useropts): self.halcomp = halcomp self.builder = builder self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) self.s = linuxcnc.stat(); self.c = linuxcnc.command() self.prefFile = self.i.find('EMC', 'MACHINE') + '.pref' hal.set_p('plasmac.torch-enable','0') self.torchButton = self.builder.get_object('torch-enable') self.torchButton.set_label('Torch Disabled') self.torchButton.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('red')) self.torchButton.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.color_parse('red')) self.torchButton.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.color_parse('red')) self.torchButton.modify_bg(gtk.STATE_SELECTED, gtk.gdk.color_parse('red')) self.iniButtonName = ['Names'] self.iniButtonCode = ['Codes'] self.probePressed = False self.probeTimer = 0 self.probeButton = '' for button in range(1,5): bname = self.i.find('PLASMAC', 'BUTTON_' + str(button) + '_NAME') or '0' self.iniButtonName.append(bname) self.iniButtonCode.append(self.i.find('PLASMAC', 'BUTTON_' + str(button) + '_CODE')) if bname != '0': bname = bname.split('\\') if len(bname) > 1: blabel = bname[0] + '\n' + bname[1] else: blabel = bname[0] self.builder.get_object('button' + str(button)).set_label(blabel) self.builder.get_object('button' + str(button)).children()[0].set_justify(gtk.JUSTIFY_CENTER) self.set_theme() gobject.timeout_add(100, self.periodic)
def periodic(self): self.s.poll() isIdleHomed = True isIdleOn = True if hal.get_value('halui.program.is-idle') and hal.get_value('halui.machine.is-on'): if hal.get_value('plasmac.arc-ok-out'): isIdleOn = False for joint in range(0,int(self.i.find('KINS','JOINTS'))): if not self.s.homed[joint]: isIdleHomed = False break else: isIdleHomed = False isIdleOn = False for n in range(1,5): if 'ohmic-test' in self.iniButtonCode[n]: # or 'probe-test' in self.iniButtonCode[n]: if isIdleOn or hal.get_value('halui.program.is-paused'): self.builder.get_object('button' + str(n)).set_sensitive(True) else: self.builder.get_object('button' + str(n)).set_sensitive(False) # elif not self.iniButtonCode[n] in ['ohmic-test'] and not self.iniButtonCode[n].startswith('%'): elif not self.iniButtonCode[n].startswith('%'): if isIdleHomed: self.builder.get_object('button' + str(n)).set_sensitive(True) else: self.builder.get_object('button' + str(n)).set_sensitive(False) if self.probeTimer: if time.time() >= self.probeTimer: self.probeTimer = 0 if not self.probePressed: hal.set_p('plasmac.probe-test','0') return True
def preview_rotate(self, event): if self.aEntry.get_text(): angle = float(self.aEntry.get_text()) else: angle = 90 if self.xOEntry.get_text(): xOffset = float(self.xOEntry.get_text()) else: xOffset = 0 if self.yOEntry.get_text(): yOffset = float(self.yOEntry.get_text()) else: yOffset = 0 self.fCode = '{}/rotate_code.ngc'.format(self.tmpDir) self.s.poll() if self.previewed: md = gtk.MessageDialog(self.W, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_NONE, 'ROTATE\n\nCalculating.....') md.set_keep_above(True) md.set_position(gtk.WIN_POS_CENTER_ALWAYS) md.set_default_size(200, 100) md.show_all() self.c.program_open(self.fOriginal) watchdog = time.time() + 5 while (1): self.s.poll() if os.path.basename(self.s.file) == os.path.basename( self.fOriginal): n = time.time() + 1 while (1): if time.time() > n: break while gtk.events_pending(): gtk.main_iteration() break if time.time() > watchdog: md.destroy() self.dialog_error('Rotate file error') return outNgc = open(self.fNgc, 'w') inCod = open(self.fOriginal, 'r') for line in inCod: if line.strip().lower().startswith('g'): rLine = self.rotate_object(line) if rLine is not None: outNgc.write(rLine) else: return else: outNgc.write(line) inCod.close() outNgc.close() self.load_file(self.fNgc) if self.previewed: md.destroy() hal.set_p('plasmac_run.preview-tab', '1') self.previewed = True self.data_changed = False self.accept.set_sensitive(True)
def periodic(self): if self.builder.get_object('thc-auto').get_active(): self.halcomp['thc-enable-out'] = self.builder.get_object('thc-enable').get_active() mode = hal.get_value('plasmac.mode') if mode != self.oldMode: if mode == 0: self.builder.get_object('kerfcross-enable').show() self.builder.get_object('kerfcross-enable-label').show() self.builder.get_object('volts-box').show() elif mode == 1: self.builder.get_object('kerfcross-enable').show() self.builder.get_object('kerfcross-enable-label').show() self.builder.get_object('volts-box').show() elif mode == 2: self.builder.get_object('kerfcross-enable').hide() self.builder.get_object('kerfcross-enable-label').hide() self.builder.get_object('volts-box').hide() else: pass self.oldMode = mode self.s.poll() homed = True for n in range(self.s.joints): if not self.s.homed[n]: homed = False hal.set_p('plasmac.homed', str(homed)) if homed and self.s.interp_state == linuxcnc.INTERP_IDLE: self.builder.get_object('single-cut').set_sensitive(True) else: self.builder.get_object('single-cut').set_sensitive(False) return True
def initialized__(self): self.w.torch_on.hal_pin_changed.connect(self.torch_changed) self.w.sensor_flt.pressed.connect(self.float_pressed) self.w.sensor_ohm.pressed.connect(self.ohmic_pressed) self.w.sensor_brk.pressed.connect(self.break_pressed) self.w.arc_ok.pressed.connect(self.arc_ok_pressed) self.w.estop.pressed.connect(self.estop_pressed) self.fTimer = QtCore.QTimer() self.fTimer.setInterval(500) self.fTimer.setSingleShot(True) self.fTimer.timeout.connect(self.float_timer_done) self.oTimer = QtCore.QTimer() self.oTimer.setInterval(500) self.oTimer.setSingleShot(True) self.oTimer.timeout.connect(self.ohmic_timer_done) self.bTimer = QtCore.QTimer() self.bTimer.setInterval(500) self.bTimer.setSingleShot(True) self.bTimer.timeout.connect(self.break_timer_done) self.backColor = QColor(self.w.sensor_flt.palette().color( QPalette.Background)).name() mode = hal.get_value('plasmac.mode') self.set_mode(mode) hal.set_p('estop_or.in0', '1') self.w.estop.setStyleSheet('background: red')
def estop_pressed(self): if hal.get_value('estop_or.in0') == 0: hal.set_p('estop_or.in0', '1') self.w.estop.setStyleSheet('background: red') else: hal.set_p('estop_or.in0', '0') self.w.estop.setStyleSheet('background: {}'.format(self.backColor))
def periodic(self): self.s.poll() isIdleHomed = True isIdleOn = True if hal.get_value('halui.program.is-idle') and hal.get_value( 'halui.machine.is-on'): if hal.get_value('plasmac.arc-ok-out'): isIdleOn = False for joint in range(0, int(self.i.find('KINS', 'JOINTS'))): if not self.s.homed[joint]: isIdleHomed = False break else: isIdleHomed = False isIdleOn = False for n in range(1, 5): if 'change-consumables' in self.iniButtonCode[n]: if hal.get_value('halui.program.is-paused'): self.builder.get_object('button' + str(n)).set_sensitive(True) else: self.builder.get_object('button' + str(n)).set_sensitive(False) elif 'ohmic-test' in self.iniButtonCode[n]: if isIdleOn or hal.get_value('halui.program.is-paused'): self.builder.get_object('button' + str(n)).set_sensitive(True) else: self.builder.get_object('button' + str(n)).set_sensitive(False) elif not 'cut-type' in self.iniButtonCode[ n] and not self.iniButtonCode[n].startswith('%'): if isIdleHomed: self.builder.get_object('button' + str(n)).set_sensitive(True) else: self.builder.get_object('button' + str(n)).set_sensitive(False) if self.probeTimer: if time.time() >= self.probeTimer: self.probeTimer = 0 if not self.probePressed: hal.set_p('plasmac.probe-test', '0') if self.inFile and self.inFile != self.s.file: if not 'PlaSmaC' in self.s.file or 'PlaSmaC0' in self.s.file: self.builder.get_object(self.cutButton).set_style( self.buttonPlain) self.builder.get_object( self.cutButton).set_label('Pierce & Cut') self.cutType = 0 elif 'PlaSmaC1' in self.s.file: self.builder.get_object(self.cutButton).set_style( self.buttonOrange) self.builder.get_object( self.cutButton).set_label('Pierce Only') self.cutType = 1 if (hal.get_value('axis.x.eoffset') or hal.get_value('axis.y.eoffset') ) and not hal.get_value('halui.program.is-paused'): hal.set_p('plasmac.consumable-change', '0') return True
def initialized__(self): self.w.setWindowTitle('QtPlasmaC Sim') self.w.torch_on.hal_pin_changed.connect(self.torch_changed) self.w.sensor_flt.pressed.connect(self.float_pressed) self.w.sensor_ohm.pressed.connect(self.ohmic_pressed) self.w.sensor_brk.pressed.connect(self.break_pressed) self.w.arc_ok.clicked.connect(self.arc_ok_clicked) self.w.estop.pressed.connect(self.estop_pressed) self.fTimer = QtCore.QTimer() self.fTimer.setInterval(500) self.fTimer.setSingleShot(True) self.fTimer.timeout.connect(self.float_timer_done) self.oTimer = QtCore.QTimer() self.oTimer.setInterval(500) self.oTimer.setSingleShot(True) self.oTimer.timeout.connect(self.ohmic_timer_done) self.bTimer = QtCore.QTimer() self.bTimer.setInterval(500) self.bTimer.setSingleShot(True) self.bTimer.timeout.connect(self.break_timer_done) mode = hal.get_value('plasmac.mode') self.set_mode(mode) hal.set_p('estop_or.in0', '1') self.w.estop.setStyleSheet('color: {}; background: {}'.format( self.foreColor, self.estopColor))
def __init__(self, halcomp, builder, useropts): self.halcomp = halcomp self.builder = builder self.i = labvcnc.ini(os.environ['INI_FILE_NAME']) self.s = labvcnc.stat() self.c = labvcnc.command() self.prefFile = self.i.find('LBV', 'MACHINE') + '.pref' self.set_theme() self.maxFeed = int( float(self.i.find("DISPLAY", "MAX_FEED_OVERRIDE") or '1') * 100) self.maxRapid = int( float(self.i.find("DISPLAY", "MAX_RAPID_OVERRIDE") or '1') * 100) self.oldMode = 9 self.configure_widgets() self.feed_override = 0 self.rapid_override = 0 self.torch_height = 0 self.builder.get_object('height-override').set_text('{:.1f} V'.format( self.torch_height)) hal.set_p('plasmac.height-override', '{:f}'.format(self.torch_height)) self.configure_comboboxes('feed-override', 0, self.maxFeed, 1, '100') self.feed_override = 1 self.configure_comboboxes('rapid-override', 0, self.maxRapid, 1, '100') self.rapid_override = 1 pause_motion_init = self.i.find("PLASMAC", "PAUSED_MOTION_SPEED") or '50' torch_pulse_init = self.i.find("PLASMAC", "TORCH_PULSE_TIME") or '1.0' self.configure_comboboxes('paused-motion-speed', 0, 100, 5, pause_motion_init) self.configure_comboboxes('torch-pulse-time', 0, 10, 0.1, torch_pulse_init) gobject.timeout_add(100, self.periodic)
def change_material(self, material, fr): if material in self.materialList: self.materialName = self.materialFileDict[material][0] self.builder.get_object('kerf-width').set_value(self.materialFileDict[material][1]) self.builder.get_object('thc-enable').set_active(self.materialFileDict[material][2]) self.builder.get_object('pierce-height').set_value(self.materialFileDict[material][3]) self.builder.get_object('pierce-delay').set_value(self.materialFileDict[material][4]) self.builder.get_object('puddle-jump-height').set_value(self.materialFileDict[material][5]) self.builder.get_object('puddle-jump-delay').set_value(self.materialFileDict[material][6]) self.builder.get_object('cut-height').set_value(self.materialFileDict[material][7]) self.builder.get_object('cut-feed-rate').set_value(self.materialFileDict[material][8]) self.builder.get_object('cut-amps').set_value(self.materialFileDict[material][9]) self.builder.get_object('cut-volts').set_value(self.materialFileDict[material][10]) self.builder.get_object('pause-at-end').set_value(self.materialFileDict[material][11]) hal.set_p('plasmac_run.material-change-number',str(material)) else: print('material not in material list') # if material < self.oldMaterial: # self.change_material(self.materialList[self.materialList.index(self.oldMaterial) - 1]) # else: # self.change_material(self.materialList[self.materialList.index(self.oldMaterial) + 1]) if material in self.materialList: if self.autoChange: self.builder.get_object('material').set_active(self.materialFileDict[material][len(self.materialFileDict[material]) - 1]) # self.builder.get_object('material').set_active(self.materialFileDict[material][12]) self.oldMaterial = material
def __init__(self, halcomp,builder,useropts): self.W = gtk.Window() self.halcomp = halcomp self.builder = builder self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) self.c = linuxcnc.command() self.s = linuxcnc.stat() self.materialNumberPin = hal_glib.GPin(halcomp.newpin('material-change-number', hal.HAL_S32, hal.HAL_IN)) self.materialChangePin = hal_glib.GPin(halcomp.newpin('material-change', hal.HAL_S32, hal.HAL_IN)) self.thcEnablePin = hal_glib.GPin(halcomp.newpin('thc-enable-out', hal.HAL_BIT, hal.HAL_OUT)) self.materialNumberPin.connect('value-changed', self.material_change_number_changed) self.materialChangePin.connect('value-changed', self.material_change_changed) self.thcFeedRate = (float(self.i.find('AXIS_Z', 'MAX_VELOCITY')) * \ float(self.i.find('AXIS_Z', 'OFFSET_AV_RATIO'))) * 60 hal.set_p('plasmac.thc-feed-rate','{}'.format(self.thcFeedRate)) self.configFile = self.i.find('EMC', 'MACHINE').lower() + '_run.cfg' self.prefFile = self.i.find('EMC', 'MACHINE') + '.pref' self.materialFile = self.i.find('EMC', 'MACHINE').lower() + '_material.cfg' self.materialFileDict = {} self.materialDict = {} self.configDict = {} hal.set_p('plasmac.mode','{}'.format(int(self.i.find('PLASMAC','MODE') or '0'))) self.oldMode = 9 self.oldMaterial = -1 self.materialUpdate = False self.autoChange = False self.manualChange = False self.configure_widgets() self.load_settings() self.check_material_file() self.get_material() self.set_theme() gobject.timeout_add(100, self.periodic)
def do_material_change(): global firstMaterial if '(' in line: c = line.split('(', 1)[0] elif ';' in line: c = line.split(';', 1)[0] else: c = line a, b = c.split('p', 1) m = '' # get the material number for mNum in b.strip(): if mNum in '0123456789': m += mNum material[0] = int(m) material[1] = True if material[0] not in materialDict: codeError = True if material[0] < 1000000: dlg = '\nMaterial #{} is missing from the material file.\n'.format( material[0]) dlg += '\nError near line #{}.\n'.format(lineNum) dlg += '\nAdd a new material or edit the G-Code file to suit.\n' else: dlg = '\nThe G-Code file contains a reference to a temporary material near line #{}.\n'.format( lineNum) dlg += '\nEdit the G-Code file outside of QtPlasmaC to reference an existing material and then reload the G-Code file.\n' dialog_box('ERROR', dlg) print(line) quit() hal.set_p('qtplasmac.material_change_number', '{}'.format(material[0])) if not firstMaterial: firstMaterial = material[0] print(line)
def write_temp_default_material(data): global lineNum, warnMatLoad try: with open(tmpMaterialFile, 'w') as fWrite: fWrite.write('#plasmac temporary material file\n') fWrite.write('\nnumber={}\n'.format(tmpMatNum)) fWrite.write('name={}\n'.format(tmpMatNam)) fWrite.write('kerf-width={}\n'.format(data[3])) fWrite.write('thc-enable={}\n'.format(data[4])) fWrite.write('pierce-height={}\n'.format(data[5])) fWrite.write('pierce-delay={}\n'.format(data[6])) fWrite.write('puddle-jump-height={}\n'.format(data[7])) fWrite.write('puddle-jump-delay={}\n'.format(data[8])) fWrite.write('cut-height={}\n'.format(data[9])) fWrite.write('cut-feed-rate={}\n'.format(data[10])) fWrite.write('cut-amps={}\n'.format(data[11])) fWrite.write('cut-volts={}\n'.format(data[12])) fWrite.write('pause-at-end={}\n'.format(data[13])) fWrite.write('gas-pressure={}\n'.format(data[14])) fWrite.write('cut-mode={}\n'.format(data[15])) fWrite.write('\n') except: codeError = True errorTempMat.append(lineNum) hal.set_p('qtplasmac.material_temp', '{}'.format(tmpMatNum)) matDelay = time.time() while 1: if time.time() > matDelay + 3: codeWarn = True warnMatLoad.append(lineNum) break if not hal.get_value('qtplasmac.material_temp'): break
def do_material_change(): global firstMaterial if '(' in line: c = line.split('(', 1)[0] elif ';' in line: c = line.split(';', 1)[0] else: c = line a, b = c.split('p', 1) m = '' # get the material number for mNum in b.strip(): if mNum in '0123456789': m += mNum material[0] = int(m) material[1] = True if material[0] not in materialDict: codeError = True dlg = '\nMaterial #{} is missing from the material file\n'.format( material[0]) dlg += '\nError near line #{}\n'.format(lineNum) dlg += '\nAdd a new material or edit GCode file to suit.\n' dialog_box('ERROR', dlg) print(line) quit() hal.set_p('qtplasmac.material_change_number', '{}'.format(material[0])) if not firstMaterial: firstMaterial = material[0] print(line)
def __init__(self, halcomp, builder, useropts): self.halcomp = halcomp self.builder = builder self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) self.s = linuxcnc.stat() self.c = linuxcnc.command() self.prefFile = self.i.find('EMC', 'MACHINE') + '.pref' self.set_theme() self.maxFeed = int( float(self.i.find("DISPLAY", "MAX_FEED_OVERRIDE") or '1') * 100) self.maxRapid = int( float(self.i.find("DISPLAY", "MAX_RAPID_OVERRIDE") or '1') * 100) self.oldMode = 9 self.configure_widgets() self.feed_override = 0 self.rapid_override = 0 self.torch_height = 0 self.builder.get_object('height-override').set_text( '%0.1f V' % (self.torch_height)) hal.set_p('plasmac.height-override', '%f' % (self.torch_height)) self.configure_comboboxes('feed-override', 0, self.maxFeed, 1, '100') self.feed_override = 1 self.configure_comboboxes('rapid-override', 0, self.maxRapid, 1, '100') self.rapid_override = 1 self.configure_comboboxes('paused-motion-speed', 0, 100, 5, '50') self.configure_comboboxes('torch-pulse-time', 0, 10, 0.1, '1.0') gobject.timeout_add(100, self.periodic)
def setp(self, setpString): arguments = len(setpString.lower().replace('setp ', '').split(' ')) if arguments == 2: halpin, value = setpString.lower().replace('setp ', '').split(' ') else: ACTION.SET_ERROR_MESSAGE( 'SETP UNSUCCESSFUL:\nsetp requires 2 arguments, {} given\n'. format(arguments)) return try: hal.get_value(halpin) except Exception as err: ACTION.SET_ERROR_MESSAGE('SETP UNSUCCESSFUL:\n{}\n'.format(err)) return try: hal.set_p(halpin, value) except Exception as err: ACTION.SET_ERROR_MESSAGE('SETP UNSUCCESSFUL:\n"{}" {}\n'.format( halpin, err)) return if type(hal.get_value(halpin)) == bool: if value.lower() in ['true', '1']: value = True elif value.lower() in ['false', '0']: value = False else: ACTION.SET_ERROR_MESSAGE( 'SETP UNSUCCESSFUL:\nValue "{}" invalid for a BIT pin/parameter\n' .format(value)) return if hal.get_value(halpin) != value: ACTION.SET_ERROR_MESSAGE( 'SETP UNSUCCESSFUL:\nBIT value comparison error\n') return elif type(hal.get_value(halpin)) == float: try: value = float(value) except: ACTION.SET_ERROR_MESSAGE( 'SETP UNSUCCESSFUL:\nValue "{}" invalid for a Float pin/parameter\n' .format(value)) return if hal.get_value(halpin) != value: ACTION.SET_ERROR_MESSAGE( 'SETP UNSUCCESSFUL:\nFloat value comparison error\n') return else: try: value = int(value) except: ACTION.SET_ERROR_MESSAGE( 'SETP UNSUCCESSFUL:\nValue "{}" invalid for S32 or U32 pin/parameter\n' .format(value)) return if hal.get_value(halpin) != value: ACTION.SET_ERROR_MESSAGE( 'SETP UNSUCCESSFUL:\nS32 or U32 value comparison error\n') return
def consumable_change_setup(self, ccParm): self.ccX = self.ccY = ccF = '' X = Y = F = '' ccAxis = [X, Y, F] ccName = ['x', 'y', 'f'] for loop in range(3): count = 0 if ccName[loop] in ccParm: while 1: if not ccParm[count]: break if ccParm[count] == ccName[loop]: count += 1 break count += 1 while 1: if count == len(ccParm): break if ccParm[count].isdigit() or ccParm[count] in '.-': ccAxis[loop] += ccParm[count] else: break count += 1 if ccName[loop] == 'x' and ccAxis[loop]: self.ccX = float(ccAxis[loop]) elif ccName[loop] == 'y' and ccAxis[loop]: self.ccY = float(ccAxis[loop]) elif ccName[loop] == 'f' and ccAxis[loop]: ccF = float(ccAxis[loop]) if self.ccX and \ (self.ccX < round(float(self.i.find('AXIS_X', 'MIN_LIMIT')), 6) or \ self.ccX > round(float(self.i.find('AXIS_X', 'MAX_LIMIT')), 6)): self.dialog_error( 'X out of limits for consumable change\n\nCheck .ini file settings\n' ) print('x out of bounds for consumable change\n') raise SystemExit() if self.ccY and \ (self.ccY < round(float(self.i.find('AXIS_Y', 'MIN_LIMIT')), 6) or \ self.ccY > round(float(self.i.find('AXIS_Y', 'MAX_LIMIT')), 6)): self.dialog_error( 'Y out of limits for consumable change\n\nCheck .ini file settings\n' ) print('y out of bounds for consumable change\n') raise SystemExit() if not ccF: self.dialog_error( 'invalid feed rate for consumable change\n\nCheck .ini file settings\n' ) print('invalid consumable change feed rate\n') raise SystemExit() self.ccScale = round(hal.get_value('plasmac.offset-scale'), 3) / 100 ccVel = int(1 / hal.get_value('halui.machine.units-per-mm') / 60 * ccF * 100) hal.set_p('axis.x.eoffset-scale', str(self.ccScale)) hal.set_p('axis.y.eoffset-scale', str(self.ccScale)) hal.set_p('plasmac.x-y-velocity', str(ccVel)) hal.set_p('axis.x.eoffset-enable', '1') hal.set_p('axis.y.eoffset-enable', '1')
def user_button_released(self, button, commands): self.probePressed = False if not commands: return if commands.lower() == 'ohmic-test': hal.set_p('plasmac.ohmic-test', '0') elif 'probe-test' in commands.lower(): if not self.probeTimer and button == self.probeButton: hal.set_p('plasmac.probe-test', '0') self.probeButton = ''
def Xplus_pressed(self, widget): if hal.get_value('plasmac.axis-x-position') + \ hal.get_value('axis.x.eoffset-counts') * self.oScale + \ hal.get_value('plasmac_run.kerf-width-f') > self.xMax: msg = 'X axis motion would trip X maximum limit' self.dialog_error(msg) return move = int(hal.get_value('plasmac_run.kerf-width-f') / self.oScale * 1) hal.set_p('plasmac.x-offset', '{}'.format(str(hal.get_value('axis.x.eoffset-counts') + move))) hal.set_p('plasmac.cut-recovery', '1')
def Yminus_pressed(self, widget): if hal.get_value('plasmac.axis-y-position') + \ hal.get_value('axis.y.eoffset-counts') * self.oScale - \ hal.get_value('plasmac_run.kerf-width-f') < self.yMin: msg = 'Y axis motion would trip Y minimum limit' self.dialog_error(msg) return move = int(hal.get_value('plasmac_run.kerf-width-f') / self.oScale * -1) hal.set_p('plasmac.y-offset', '{}'.format(str(hal.get_value('axis.y.eoffset-counts') + move))) hal.set_p('plasmac.cut-recovery', '1')
def __init__(self, halcomp,builder,useropts): self.inifile = linuxcnc.ini(os.environ["INI_FILE_NAME"]) self.configpath = os.environ['CONFIG_DIR'] self.toolfile = os.path.join( self.configpath, self.inifile.find("EMCIO", "TOOL_TABLE") ) self.builder = builder self.halcomp = halcomp self.change_text = builder.get_object("lbl_tool_change_info") self.ref_tool = builder.get_object("reftool") self.command_value_to_name = {} value = 1 for command in self.commands: self.halcomp.newpin(command, hal.HAL_FLOAT, hal.HAL_IN) hal.set_p(halcomp.getprefix() + "." + command, str(value)) self.command_value_to_name[value] = command value = value + 1 self.gcode_command = hal_glib.GPin(halcomp.newpin("gcode-command", hal.HAL_FLOAT, hal.HAL_IN)) self.gcode_param = hal_glib.GPin(halcomp.newpin("gcode-parameter", hal.HAL_FLOAT, hal.HAL_IN)) self.num_of_tools = hal_glib.GPin(halcomp.newpin("num_of_tools", hal.HAL_FLOAT, hal.HAL_IN)) self.gcode_command.connect("value-changed", self.command_from_gcode) self.gcode_param.connect("value-changed", self.parameter_from_gcode) self.parameter = None self.tools_in_file = [] self.tooledit1 = self.builder.get_object("tooledit1") self.tooledit1.set_filename(self.toolfile) self.liststore1 = self.builder.get_object("liststore1") self.treeview1 = self.builder.get_object("treeview1") # Set tool table columns tool_table_width = self.treeview1.get_property("width_request") self.cell_desc = self.builder.get_object("cell_desc") self.cell_desc.props.wrap_mode = pango.WRAP_WORD self.cell_desc.props.wrap_width = int(self.COL_TOOL_NAME_WIDTH * tool_table_width) self.cell_operation = self.builder.get_object("cell_operation") self.cell_operation.props.wrap_mode = pango.WRAP_WORD self.cell_operation.props.wrap_width = int(self.COL_TOOL_OPERATION_WIDTH * tool_table_width) self.current_tool_index = -1 self.spindle_rpm_bar = self.builder.get_object("spindle_speed") self.gcode_command = hal_glib.GPin(halcomp.newpin("spindle-target-speed", hal.HAL_FLOAT, hal.HAL_IN)) self.gcode_command.connect("value-changed", self.spindle_target_changed) self.file_progress_bar = self.builder.get_object("file_progress") self.rows_in_file = 200 self.current_row = 0 self.spindle_on_timer = 0 glib.timeout_add_seconds(1, self._on_timer_tick) self.runtime = self.builder.get_object("runtime")
def initialized__(self): self.w.setWindowTitle('QtPlasmaC Sim') self.IMAGES = os.path.join(self.PATHS.IMAGEDIR, 'qtplasmac/images/') self.w.setWindowIcon( QIcon(os.path.join(self.IMAGES, 'linuxcncicon.png'))) self.breakPin = self.hal.newpin('sensor_breakaway', hal.HAL_BIT, hal.HAL_OUT) self.floatPin = self.hal.newpin('sensor_float', hal.HAL_BIT, hal.HAL_OUT) self.ohmicPin = self.hal.newpin('sensor_ohmic', hal.HAL_BIT, hal.HAL_OUT) self.torchPin = self.hal.newpin('torch_on', hal.HAL_BIT, hal.HAL_IN) self.statePin = self.hal.newpin('state', hal.HAL_S32, hal.HAL_IN) self.zPosPin = self.hal.newpin('z_position', hal.HAL_FLOAT, hal.HAL_IN) self.arcVoltsPin = self.hal.newpin('arc_voltage_out-f', hal.HAL_FLOAT, hal.HAL_OUT) CALL([ 'halcmd', 'net', 'plasmac:axis-position', 'qtplasmac_sim.z_position' ]) CALL(['halcmd', 'net', 'plasmac:state', 'qtplasmac_sim.state']) self.torchPin.value_changed.connect(self.torch_changed) self.zPosPin.value_changed.connect( lambda v: self.z_position_changed(v)) self.w.arc_voltage_out.valueChanged.connect( lambda v: self.arc_volts_changed(v)) self.w.sensor_flt.pressed.connect(self.float_pressed) self.w.sensor_ohm.pressed.connect(self.ohmic_pressed) self.w.sensor_brk.pressed.connect(self.break_pressed) self.w.arc_ok.clicked.connect(self.arc_ok_clicked) self.w.estop.pressed.connect(self.estop_pressed) self.w.auto_flt.pressed.connect(self.auto_float_pressed) self.w.auto_flt.setChecked(True) self.w.auto_ohm.pressed.connect(self.auto_ohmic_pressed) self.fTimer = QtCore.QTimer() self.fTimer.setInterval(500) self.fTimer.setSingleShot(True) self.fTimer.timeout.connect(self.float_timer_done) self.oTimer = QtCore.QTimer() self.oTimer.setInterval(500) self.oTimer.setSingleShot(True) self.oTimer.timeout.connect(self.ohmic_timer_done) self.bTimer = QtCore.QTimer() self.bTimer.setInterval(500) self.bTimer.setSingleShot(True) self.bTimer.timeout.connect(self.break_timer_done) self.w.help.pressed.connect(self.help_pressed) mode = hal.get_value('plasmac.mode') self.set_mode(mode) hal.set_p('estop_or.in0', '1') zMin = hal.get_value('ini.z.min_limit') self.zProbe = zMin + (10 * hal.get_value('halui.machine.units-per-mm')) self.w.estop.setStyleSheet('color: {}; background: {}'.format( self.foreColor, self.estopColor))
def on_button_released(self, button): self.probePressed = False bNum = int(button.get_name().split('button')[1]) commands = self.iniButtonCode[bNum] if not commands: return if commands.lower() == 'ohmic-test': hal.set_p('plasmac.ohmic-test','0') elif 'probe-test' in commands.lower(): if not self.probeTimer and button == self.probeButton: hal.set_p('plasmac.probe-test','0') self.probeButton = ''
def consumable_change_setup(self): ccParm = self.i.find('PLASMAC','BUTTON_1_CODE').replace('change-consumables','').replace(' ','').lower() or None if ccParm: self.ccX = self.ccY = ccF = '' X = Y = F = '' ccAxis = [X, Y, F] ccName = ['x', 'y', 'f'] for loop in range(3): count = 0 if ccName[loop] in ccParm: while 1: if not ccParm[count]: break if ccParm[count] == ccName[loop]: count += 1 break count += 1 while 1: if count == len(ccParm): break if ccParm[count].isdigit() or ccParm[count] in '.-': ccAxis[loop] += ccParm[count] else: break count += 1 if ccName[loop] == 'x': self.ccX = float(ccAxis[loop]) elif ccName[loop] == 'y': self.ccY = float(ccAxis[loop]) elif ccName[loop] == 'f': ccF = float(ccAxis[loop]) if self.ccX and \ (self.ccX < round(float(self.i.find('AXIS_X', 'MIN_LIMIT')), 6) or \ self.ccX > round(float(self.i.find('AXIS_X', 'MAX_LIMIT')), 6)): print('x out of bounds for consumable change\n') raise SystemExit() if self.ccY and \ (self.ccY < round(float(self.i.find('AXIS_Y', 'MIN_LIMIT')), 6) or \ self.ccY > round(float(self.i.find('AXIS_Y', 'MAX_LIMIT')), 6)): print('y out of bounds for consumable change\n') raise SystemExit() if not ccF: print('invalid consumable change feed rate\n') raise SystemExit() self.ccScale = round(hal.get_value('plasmac.offset-scale'), 3) / 100 ccVel = int(1 / hal.get_value('halui.machine.units-per-mm') / 60 * ccF * 100) hal.set_p('axis.x.eoffset-scale', str(self.ccScale)) hal.set_p('axis.y.eoffset-scale', str(self.ccScale)) hal.set_p('plasmac.x-y-velocity', str(ccVel)) hal.set_p('axis.x.eoffset-enable', '1') hal.set_p('axis.y.eoffset-enable', '1') else: print('consumable change parameters required\n')
def user_button_pressed(self, button, commands): if not commands: return if commands.lower() == 'ohmic-test': hal.set_p('plasmac.ohmic-test', '1') elif 'probe-test' in commands.lower(): self.probePressed = True self.probeButton = button if commands.lower().replace('probe-test', '').strip(): self.probeTimer = float(commands.lower().replace( 'probe-test', '').strip()) + time.time() hal.set_p('plasmac.probe-test', '1') elif 'cut-type' in commands.lower( ) and not hal.get_value('halui.program.is-running'): self.cutType ^= 1 if self.cutType: hal.set_p('plasmac_run.cut-type', '1') self.builder.get_object(button).set_style(self.buttonOrange) self.builder.get_object(button).set_label('Pierce Only') else: hal.set_p('plasmac_run.cut-type', '0') self.builder.get_object(button).set_style(self.buttonPlain) self.builder.get_object(button).set_label('Pierce & Cut') self.message( '\nSwitching between cut types requires re-opening of the program.\n\n' 'Reload is NOT sufficient.\n\n') else: for command in commands.split('\\'): if command.strip()[0] == '%': command = command.strip().strip('%') + '&' Popen(command, stdout=PIPE, stderr=PIPE, shell=True) else: if '{' in command: newCommand = subCommand = '' for char in command: if char == '{': subCommand = ':' elif char == '}': f1, f2 = subCommand.replace(':', "").split() newCommand += self.i.find(f1, f2) subCommand = '' elif subCommand.startswith(':'): subCommand += char else: newCommand += char command = newCommand self.s.poll() if not self.s.estop and self.s.enabled and self.s.homed and ( self.s.interp_state == linuxcnc.INTERP_IDLE): mode = self.s.task_mode if mode != linuxcnc.MODE_MDI: mode = self.s.task_mode self.c.mode(linuxcnc.MODE_MDI) self.c.wait_complete() self.c.mdi(command) self.s.poll() while self.s.interp_state != linuxcnc.INTERP_IDLE: self.s.poll() self.c.mode(mode) self.c.wait_complete()
def on_torch_enable_pressed(self,event): if hal.get_value('plasmac.torch-enable'): hal.set_p('plasmac.torch-enable','0') self.torchButton.set_label('Torch Disabled') self.torchButton.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('red')) self.torchButton.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.color_parse('red')) self.torchButton.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.color_parse('red')) self.torchButton.modify_bg(gtk.STATE_SELECTED, gtk.gdk.color_parse('red')) else: hal.set_p('plasmac.torch-enable','1') self.torchButton.set_label('Torch Enabled') self.torchButton.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('green')) self.torchButton.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.color_parse('green')) self.torchButton.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.color_parse('green')) self.torchButton.modify_bg(gtk.STATE_SELECTED, gtk.gdk.color_parse('green'))
def material_change_number_changed(self, halpin): hal.set_p('motion.digital-in-03', '0') material = halpin.get() if material in self.materialKerfMap.keys(): self.builder.get_object('material-number').set_value(material) hal.set_p('plasmac_run.material-change', '1') hal.set_p('motion.digital-in-03', '1') else: hal.set_p('plasmac_run.material-change', '-1')
def _on_timer_tick(self, userdata=None): s = linuxcnc.stat() s.poll() if self.rows_in_file > 0: hal.set_p("gladevcp.file_progress", str(self.current_row * 100 / self.rows_in_file)) if s.spindle_speed >= 0.01 or s.spindle_speed <= -0.01: self.spindle_on_timer += 1 seconds = self.spindle_on_timer hours = int(seconds / 3600) seconds -= hours * 3600 minutes = int(seconds / 60) seconds -= minutes * 60 text = "%d:%02d:%02d" % (hours, minutes, seconds) self.runtime.set_label(text) return True