示例#1
0
def do_material_change():
    global lineNum, lineNumOrg, errorLines, firstMaterial, codeError, errorMissMat
    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 and material[0] < 1000000:
        codeError = True
        errorMissMat.append(lineNum)
        errorLines.append(lineNumOrg)
    RUN([
        'halcmd', 'setp', 'qtplasmac.material_change_number',
        '{}'.format(material[0])
    ])
    if not firstMaterial:
        firstMaterial = material[0]
    gcodeList.append(line)
示例#2
0
def rewrite_material_file(newMaterial):
    global lineNum, warnMatLoad, errorLines
    copyFile = '{}.bkp'.format(materialFile)
    shutil.copy(materialFile, copyFile)
    inFile = open(copyFile, 'r')
    outFile = open(materialFile, 'w')
    while 1:
        line = inFile.readline()
        if not line:
            break
        if not line.strip().startswith('[MATERIAL_NUMBER_'):
            outFile.write(line)
        else:
            break
    while 1:
        if not line:
            add_edit_material(newMaterial, outFile)
            break
        if line.strip().startswith('[MATERIAL_NUMBER_'):
            mNum = int(line.split('NUMBER_')[1].replace(']', ''))
            if mNum == newMaterial[1]:
                add_edit_material(newMaterial, outFile)
        if mNum != newMaterial[1]:
            outFile.write(line)
        line = inFile.readline()
        if not line:
            break
    if newMaterial[1] not in materialDict:
        add_edit_material(newMaterial, outFile)
    inFile.close()
    outFile.close()
    RUN(['halcmd', 'setp', 'qtplasmac.material_reload', '1'])
    get_materials()
    matDelay = time.time()
    while 1:
        if time.time() > matDelay + 3:
            codeWarn = True
            warnMatLoad.append(lineNum)
            errorLines.append(lineNumOrg)
            break
        response = RUN(['halcmd', 'getp', 'qtplasmac.material_reload'],
                       capture_output=True)
        if not int(response.stdout.decode()):
            break
示例#3
0
def write_temporary_material(data):
    global lineNum, lineNumOrg, errorLines, errorTempMat, warnMatLoad, material, codeError
    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)
        errorLines.append(lineNumOrg)
    materialDict[tmpMatNum] = [data[10], data[3]]
    RUN(['halcmd', 'setp', 'qtplasmac.material_temp', '{}'.format(tmpMatNum)])
    material[0] = tmpMatNum
    matDelay = time.time()
    while 1:
        if time.time() > matDelay + 3:
            codeWarn = True
            warnMatLoad.append(lineNum)
            errorLines.append(lineNumOrg)
            break
        response = RUN(['halcmd', 'getp', 'qtplasmac.material_temp'],
                       capture_output=True)
        if not int(response.stdout.decode()):
            break
示例#4
0
def set_timeout():
    RUN(['halcmd', 'setp', 'qtplasmac.material_change_timeout', 1])
示例#5
0
def set_change(value):
    RUN(['halcmd', 'setp', 'qtplasmac.material_change', '{}'.format(value)])
示例#6
0
def get_change():
    response = RUN(['halcmd', 'getp', 'qtplasmac.material_change'],
                   capture_output=True)
    return int(response.stdout.decode())
示例#7
0
def set_material(material):
    RUN([
        'halcmd', 'setp', 'qtplasmac.material_change_number',
        '{}'.format(material)
    ])
示例#8
0
inPath = sys.argv[1]
inFile = os.path.basename(inPath)
if inFile == 'rfl.ngc':
    with open(inPath, 'r') as inCode:
        for line in inCode:
            print(line.strip())
    sys.exit()
filteredBkp = '/tmp/qtplasmac/filtered_bkp.ngc'
errorFile = '/tmp/qtplasmac/gcode_errors.txt'
materialFile = '{}_material.cfg'.format(ini.find('EMC', 'MACHINE'))
tmpMaterialFile = '/tmp/qtplasmac/{}_material.gcode'.format(
    ini.find('EMC', 'MACHINE'))
tmpMatNum = 1000000
tmpMatNam = ''
prefsFile = ini.find('EMC', 'MACHINE') + '.prefs'
response = RUN(['halcmd', 'getp', 'qtplasmac.cut_type'], capture_output=True)
cutType = int(response.stdout.decode())
response = RUN(['halcmd', 'getp', 'qtplasmac.material_change_number'],
               capture_output=True)
currentMat = int(response.stdout.decode())
response = RUN(['halcmd', 'getp', 'qtplasmac.color_fg'], capture_output=True)
fgColor = str(hex(int(response.stdout.decode()))).replace('0x', '#')
response = RUN(['halcmd', 'getp', 'qtplasmac.color_bg'], capture_output=True)
bgColor = str(hex(int(response.stdout.decode()))).replace('0x', '#')
response = RUN(['halcmd', 'getp', 'qtplasmac.color_bgalt'],
               capture_output=True)
bgAltColor = str(hex(int(response.stdout.decode()))).replace('0x', '#')
response = RUN(['halcmd', 'getp', 'plasmac.max-offset'], capture_output=True)
zMaxOffset = float(response.stdout.decode())
RUN(['halcmd', 'setp', 'qtplasmac.conv_block_loaded', '0'])
metric = ['mm', 4]