/** Copyright (C) 2012-2019 by Autodesk, Inc. All rights reserved. Hypertherm jet post processor configuration. $Revision: 42473 905303e8374380273c82d214b32b7e80091ba92e $ $Date: 2019-09-04 00:46:02 $ FORKID {E500A33F-FB1E-4529-94BA-2CC6845485A5} } */ description = "Dynatorch Plasma"; vendor = "Dynatorch"; vendorUrl = "https://www.dynatorch.com/"; legal = "Copyright (C) 2012-2019 by Autodesk, Inc."; certificationLevel = 2; minimumRevision = 39000; longDescription = "Generic jet post for Dynatorch Plasma System."; extension = "tap"; setCodePage("ascii"); capabilities = CAPABILITY_JET; tolerance = spatial(0.002, MM); minimumChordLength = spatial(0.25, MM); minimumCircularRadius = spatial(0.01, MM); maximumCircularRadius = spatial(1000, MM); minimumCircularSweep = toRad(0.01); maximumCircularSweep = toRad(90); allowHelicalMoves = false; allowedCircularPlanes = undefined; // allow any circular motion // user-defined properties properties = { writeMachine: true, // write machine writeDetails: true, // write details showSequenceNumbers: false, // show sequence numbers sequenceNumberStart: 10, // first sequence number sequenceNumberIncrement: 10, // increment for sequence numbers separateWordsWithSpace: true, // specifies that the words should be separated with a white space plasmaOnDwell: 0, // specifies the dwell time when turning on the plasma plasmaOffDwell: 0 // specifies the dwell time when turning off the plasma }; // user-defined property definitions propertyDefinitions = { writeMachine: {title:"Write machine", description:"Output the machine settings in the header of the code.", group:0, type:"boolean"}, writeDetails: {title:"Write details", description:"Output details in the header of the code.", group:0, type:"boolean"}, showSequenceNumbers: {title:"Use sequence numbers", description:"Use sequence numbers for each block of outputted code.", group:1, type:"boolean"}, sequenceNumberStart: {title:"Start sequence number", description:"The number at which to start the sequence numbers.", group:1, type:"integer"}, sequenceNumberIncrement: {title:"Sequence number increment", description:"The amount by which the sequence number is incremented by in each block.", group:1, type:"integer"}, separateWordsWithSpace: {title:"Separate words with space", description:"Adds spaces between words if 'yes' is selected.", type:"boolean"}, plasmaOnDwell: {title:"Plasma on dwell", description:"The amount of time to dwell in seconds after turning on the plasma.", type:"number"}, plasmaOffDwell: {title:"Plasma off dwell", description:"The amount of time to dwell in seconds after turning off the plasma.", type:"number"} }; var sequenceFormat = createFormat({prefix:"N", decimals:0, width:4, zeropad:true}); var gFormat = createFormat({prefix:"G", decimals:0, width:2, zeropad:true}); var mFormat = createFormat({prefix:"M", decimals:0, width:2, zeropad:true}); var dFormat = createFormat({prefix:"D", decimals:0}); // kerf index var xyzFormat = createFormat({decimals:(unit == MM ? 3 : 4), trim:false}); var feedFormat = createFormat({decimals:(unit == MM ? 1 : 2)}); var toolFormat = createFormat({decimals:0}); var secFormat = createFormat({decimals:3, forceDecimal:true}); // seconds - range 0.001-1000 var xOutput = createVariable({prefix:"X"}, xyzFormat); var yOutput = createVariable({prefix:"Y"}, xyzFormat); var feedOutput = createVariable({prefix:"F"}, feedFormat); // circular output var iOutput = createReferenceVariable({prefix:"I"}, xyzFormat); var jOutput = createReferenceVariable({prefix:"J"}, xyzFormat); var gMotionModal = createModal({force:true}, gFormat); // modal group 1 // G0-G3, ... var gPlaneModal = createModal({}, gFormat); // modal group 2 // G17-G19 var gAbsIncModal = createModal({}, gFormat); // modal group 3 // G90-91 var gUnitModal = createModal({}, gFormat); // modal group 6 // G20-21 var gEtchModal = createModal({}, gFormat); // modal group 7 // G60-61 var WARNING_WORK_OFFSET = 0; // collected state var sequenceNumber; var currentWorkOffset; /** Writes the specified block. */ function writeBlock() { if (properties.showSequenceNumbers) { writeWords2(sequenceFormat.format(sequenceNumber), arguments); sequenceNumber += properties.sequenceNumberIncrement; } else { writeWords(arguments); } } function formatComment(text) { return "(" + String(text).replace(/[()]/g, "") + ")"; } /** Output a comment. */ function writeComment(text) { writeBlock(formatComment(text)); } function onOpen() { if (!properties.separateWordsWithSpace) { setWordSeparator(""); } sequenceNumber = properties.sequenceNumberStart; if (programName) { writeComment(programName); } if (programComment) { writeComment(programComment); } // Write model and post details if (properties.writeDetails) { writeComment("Dynatorch CNC Plasma"); if (hasGlobalParameter("generated-by")) { var value = getGlobalParameter("generated-by"); writeComment(value); } if (hasGlobalParameter("generated-at")) { var value = getGlobalParameter("generated-at"); var date = new Date(value + ' UTC'); writeComment(date.toString()); } if (hasGlobalParameter("username")) { var value = getGlobalParameter("username"); writeComment(value); } if (hasGlobalParameter("document-path")) { var value = getGlobalParameter("document-path"); writeComment(value); } if (hasGlobalParameter("job-description")) { var value = getGlobalParameter("job-description"); writeComment(value); } } // dump machine configuration var vendor = machineConfiguration.getVendor(); var model = machineConfiguration.getModel(); var description = machineConfiguration.getDescription(); if (properties.writeMachine && (vendor || model || description)) { writeComment(localize("Machine")); if (vendor) { writeComment(" " + localize("vendor") + ": " + vendor); } if (model) { writeComment(" " + localize("model") + ": " + model); } if (description) { writeComment(" " + localize("description") + ": " + description); } } switch (unit) { case IN: writeBlock(gUnitModal.format(20)); break; case MM: writeBlock(gUnitModal.format(21)); break; } // absolute coordinates and feed per min writeBlock(gAbsIncModal.format(90)); writeBlock(gPlaneModal.format(17)); } function onComment(message) { writeComment(message); } /** Force output of X, Y, and Z. */ function forceXYZ() { xOutput.reset(); yOutput.reset(); } /** Force output of X, Y, Z, A, B, C, and F on next output. */ function forceAny() { forceXYZ(); feedOutput.reset(); } function onSection() { var insertToolCall = isFirstSection() || currentSection.getForceToolChange && currentSection.getForceToolChange() || (tool.number != getPreviousSection().getTool().number); var retracted = false; // specifies that the tool has been retracted to the safe plane var newWorkOffset = isFirstSection() || (getPreviousSection().workOffset != currentSection.workOffset); // work offset changes var newWorkPlane = isFirstSection() || !isSameDirection(getPreviousSection().getGlobalFinalToolAxis(), currentSection.getGlobalInitialToolAxis()); // writeln(""); if (hasParameter("operation-comment")) { var comment = getParameter("operation-comment"); if (comment) { writeComment(comment); } } if (insertToolCall) { retracted = true; onCommand(COMMAND_COOLANT_OFF); switch (tool.type) { case TOOL_WATER_JET: // writeBlock(mFormat.format(36), "T" + toolFormat.format(6)); // waterjet break; case TOOL_LASER_CUTTER: // writeBlock(mFormat.format(36), "T" + toolFormat.format(5)); // laser break; case TOOL_PLASMA_CUTTER: // process 1 - use T2 for process 2 // writeBlock(mFormat.format(36), "T" + toolFormat.format(1)); // plasma break; /* case TOOL_MARKER: writeBlock(mFormat.format(36), "T" + toolFormat.format(3)); // marker 1 - use 4 for marker 2 break; */ default: error(localize("The CNC does not support the required tool.")); return; } // use could use - G59 Dxxx Xkerf to set kerf if (tool.comment) { writeComment(tool.comment); } switch (currentSection.jetMode) { case JET_MODE_THROUGH: writeComment("Through cutting"); break; case JET_MODE_ETCHING: writeComment("Etch cutting"); break; case JET_MODE_VAPORIZE: writeComment("Vaporize cutting"); break; default: error(localize("Unsupported cutting mode.")); } // writeln(""); } /* // wcs if (insertToolCall) { // force work offset when changing tool currentWorkOffset = undefined; } var workOffset = currentSection.workOffset; if (workOffset == 0) { warningOnce(localize("Work offset has not been specified. Using G54 as WCS."), WARNING_WORK_OFFSET); workOffset = 1; } if (workOffset > 0) { if (workOffset > 6) { var code = workOffset - 6; if (code > 3) { error(localize("Work offset out of range.")); return; } if (workOffset != currentWorkOffset) { writeBlock(gFormat.format(59) + "." + code); currentWorkOffset = workOffset; } } else { if (workOffset != currentWorkOffset) { writeBlock(gFormat.format(53 + workOffset)); // G54->G59 currentWorkOffset = workOffset; } } } */ forceXYZ(); { // pure 3D var remaining = currentSection.workPlane; if (!isSameDirection(remaining.forward, new Vector(0, 0, 1))) { error(localize("Tool orientation is not supported.")); return; } setRotation(remaining); } /* // set coolant after we have positioned at Z if (false) { var c = mapCoolantTable.lookup(tool.coolant); if (c) { writeBlock(mFormat.format(c)); } else { warning(localize("Coolant not supported.")); } } */ forceAny(); if (currentSection.jetMode == JET_MODE_ETCHING) { writeBlock(gEtchModal.format(61)); } else { writeBlock(gEtchModal.format(60)); } var initialPosition = getFramePosition(currentSection.getInitialPosition()); if (insertToolCall || retracted) { gMotionModal.reset(); if (!machineConfiguration.isHeadConfiguration()) { writeBlock( gAbsIncModal.format(90), gMotionModal.format(0), xOutput.format(initialPosition.x), yOutput.format(initialPosition.y) ); } else { writeBlock( gAbsIncModal.format(90), gMotionModal.format(0), xOutput.format(initialPosition.x), yOutput.format(initialPosition.y) ); } } else { writeBlock( gAbsIncModal.format(90), gMotionModal.format(0), xOutput.format(initialPosition.x), yOutput.format(initialPosition.y) ); } } function onDwell(seconds) { if (seconds > 99999.999) { warning(localize("Dwelling time is out of range.")); } seconds = clamp(0.001, seconds, 99999.999); writeBlock(gFormat.format(4), "P" + secFormat.format(seconds)); } function onCycle() { onError("Drilling is not supported by CNC."); } var pendingRadiusCompensation = -1; function onRadiusCompensation() { pendingRadiusCompensation = radiusCompensation; } var deviceOn = false; function setDeviceMode(enable) { if (enable != deviceOn) { deviceOn = enable; if (enable) { writeComment((currentSection.jetMode == JET_MODE_ETCHING) ? "TURN ON ETCHING" : "TURN ON CUTTING"); /*if (currentSection.jetMode == JET_MODE_ETCHING) { writeBlock(gEtchModal.format(61)); }*/ writeBlock(gFormat.format(23)); // DEVICE ON if (properties.plasmaOnDwell > 0) { onDwell(properties.plasmaOnDwell); } } else { writeComment((currentSection.jetMode == JET_MODE_ETCHING) ? "TURN OFF ETCHING" : "TURN OFF CUTTING"); writeBlock(gFormat.format(25)); // DEVICE OFF if (properties.plasmaOffDwell > 0) { onDwell(properties.plasmaOffDwell); } /*if (currentSection.jetMode == JET_MODE_ETCHING) { writeBlock(gEtchModal.format(60)); }*/ } } } var powerMode = false; function onPower(power) { powerMode = power; } function onRapid(_x, _y, _z) { var x = xOutput.format(_x); var y = yOutput.format(_y); if (x || y) { if (pendingRadiusCompensation >= 0) { error(localize("Radius compensation mode cannot be changed at rapid traversal.")); return; } setDeviceMode(powerMode); writeBlock(gMotionModal.format(0), x, y); feedOutput.reset(); } } function onLinear(_x, _y, _z, feed) { var x = xOutput.format(_x); var y = yOutput.format(_y); var f = feedOutput.format(feed); if (x || y) { if (pendingRadiusCompensation >= 0) { error(localize("Radius compensation mode is not supported.")); return; } if (f) { writeBlock(f); } setDeviceMode(powerMode); writeBlock(gMotionModal.format(1), x, y); } else if (f) { if (getNextRecord().isMotion()) { // try not to output feed without motion feedOutput.reset(); // force feed on next line } else { writeBlock(gMotionModal.format(1), f); } } } function onRapid5D(_x, _y, _z, _a, _b, _c) { error(localize("The CNC does not support 5-axis simultaneous toolpath.")); } function onLinear5D(_x, _y, _z, _a, _b, _c, feed) { error(localize("The CNC does not support 5-axis simultaneous toolpath.")); } function onCircular(clockwise, cx, cy, cz, x, y, z, feed) { // one of X/Y and I/J are required and likewise if (pendingRadiusCompensation >= 0) { error(localize("Radius compensation cannot be activated/deactivated for a circular move.")); return; } var start = getCurrentPosition(); setDeviceMode(powerMode); var f = feedOutput.format(feed); if (f) { writeBlock(f); } if (isFullCircle()) { if (isHelical()) { linearize(tolerance); return; } switch (getCircularPlane()) { case PLANE_XY: writeBlock(gMotionModal.format(clockwise ? 2 : 3), xOutput.format(x), iOutput.format(cx - start.x, 0), jOutput.format(cy - start.y, 0)); break; default: linearize(tolerance); } } else { switch (getCircularPlane()) { case PLANE_XY: writeBlock(gMotionModal.format(clockwise ? 2 : 3), xOutput.format(x), yOutput.format(y), iOutput.format(cx - start.x, 0), jOutput.format(cy - start.y, 0)); break; default: linearize(tolerance); } } } var mapCommand = { COMMAND_STOP:0, COMMAND_OPTIONAL_STOP:1, COMMAND_END:2 }; function onCommand(command) { switch (command) { case COMMAND_POWER_ON: return; case COMMAND_POWER_OFF: return; case COMMAND_COOLANT_ON: return; case COMMAND_COOLANT_OFF: return; case COMMAND_LOCK_MULTI_AXIS: return; case COMMAND_UNLOCK_MULTI_AXIS: return; case COMMAND_BREAK_CONTROL: return; case COMMAND_TOOL_MEASURE: return; } var stringId = getCommandStringId(command); var mcode = mapCommand[stringId]; if (mcode != undefined) { writeBlock(mFormat.format(mcode)); } else { onUnsupportedCommand(command); } } function onSectionEnd() { setDeviceMode(false); forceAny(); } function onClose() { // writeln(""); onCommand(COMMAND_COOLANT_OFF); onImpliedCommand(COMMAND_END); writeBlock(mFormat.format(30)); // stop program }