From 4c724931fb5ce70f8edb9a5d6f9110924318d632 Mon Sep 17 00:00:00 2001 From: "Williams, Gavin J" Date: Thu, 14 Oct 2021 10:42:50 -0400 Subject: [PATCH] Param Removal --- Haas_Lathes_BIDC/Bechtel ST-20.cps | 281 +++++++++++++++++++--------- Haas_Lathes_BIDC/Bechtel ST-20Y.cps | 281 +++++++++++++++++++--------- 2 files changed, 382 insertions(+), 180 deletions(-) diff --git a/Haas_Lathes_BIDC/Bechtel ST-20.cps b/Haas_Lathes_BIDC/Bechtel ST-20.cps index fcc6afd..3020843 100644 --- a/Haas_Lathes_BIDC/Bechtel ST-20.cps +++ b/Haas_Lathes_BIDC/Bechtel ST-20.cps @@ -62,7 +62,7 @@ allowSpiralMoves = false; highFeedrate = (unit == IN) ? 470 : 12000; // user-defined properties -properties = { +properties = {/* writeMachine: { title: "Write machine", description: "Output the machine settings in the header of the code.", @@ -276,15 +276,14 @@ properties = { type: "boolean", value: false, scope: "post" - }, + },*/ useSSV: { title: "Use SSV", description: "Outputs M38/M39 to enable SSV for turning operations.", type: "boolean", - group: 1, value: false, scope: "post" - }, + },/* optimizeCAxisSelect: { title: "Optimize C-axis selection", description: "Optimizes the output of enable/disable C-axis codes.", @@ -351,13 +350,21 @@ properties = { type: "boolean", value: false, scope: "post" + },*/ + toolsToLoad: { + title: "Tools to load and probe", + description: "List or provide a range of tools to probe e.g. 1, 2, 3 or 1-5. Leaving this empty will probe all tools", + group: 4, + type: "string", + value: "", + scope: "post" }, measureToolsAtStart: { title: "Tool Probing", description: "Tool loading and probing. By turning this off, you accept responsibility for any resulting crashes.", group: 0, type: "boolean", - value: false, + value: true, scope: "post" }, loadToolsAtStart: { @@ -371,11 +378,49 @@ properties = { }; staticProperties = { - postVersion: "BIDC-ST0.G8.A21", + writeMachine: false, + writeTools: false, + writeVersion: false, + showSequenceNumbers: true, + sequenceNumberStart: 10, + sequenceNumberIncrement: 5, + optionalStop: true, + separateWordsWithSpace: true, + useRadius: false, + maximumSpindleSpeed: 4000, + subMaximumSpindleSpeed: 4000, + useParametricFeed: false, + showNotes: true, + useCycles: true, + autoEject: false, + g53HomePositionX: 0, + g53HomePositionY: 0, + g53HomePositionZ: 0, + g53HomePositionSubZ: 0, + g53WorkPositionSub: 0, + useTailStock: false, + useBarFeeder: false, + gotChipConveyor: false, + useG112: false, + usePolarCircular: false, + xAxisMinimum: 0, + useG61: false, + setting102: 1, + rapidRewinds: false, + optimizeCAxisSelect: false, + gotSecondarySpindle: false, + looping: false, + numberOfRepeats: 1, + useSimpleThread: true, + airCleanChuck: true, + safeStartAllOperations: true, + useYAxisForDrilling: false, useG187: false, - safeStartAllOperations: true + postVersion: "BIDC-ST0.G10.K21", }; +const MAXTOOLS = 12; + var permittedCommentChars = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,=_-"; var gFormat = createFormat({prefix:"G", decimals:0}); @@ -815,7 +860,7 @@ function startSpindle(forceRPMMode, initialPosition, rpm) { } var useConstantSurfaceSpeed = currentSection.getTool().getSpindleMode() == SPINDLE_CONSTANT_SURFACE_SPEED; - var maxSpeed = (currentSection.spindle == SPINDLE_SECONDARY) ? getProperty("subMaximumSpindleSpeed") : getProperty("maximumSpindleSpeed"); + var maxSpeed = (currentSection.spindle == SPINDLE_SECONDARY) ? staticProperties.subMaximumSpindleSpeed : staticProperties.maximumSpindleSpeed; var maximumSpindleSpeed = (tool.maximumSpindleSpeed > 0) ? Math.min(tool.maximumSpindleSpeed, maxSpeed) : maxSpeed; if (useConstantSurfaceSpeed && !forceRPMMode) { skipBlock = _skipBlock; @@ -860,7 +905,7 @@ function startSpindle(forceRPMMode, initialPosition, rpm) { } break; case SPINDLE_SECONDARY: // sub spindle - if (!getProperty("gotSecondarySpindle")) { + if (!staticProperties.gotSecondarySpindle) { error(localize("Secondary spindle is not available.")); return; } @@ -892,15 +937,15 @@ function writeRetract(section, retractZ) { if (!isFirstSection()) { if (gotYAxis) { skipBlock = _skipBlock; - writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(getProperty("g53HomePositionY"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(staticProperties.g53HomePositionY)); // retract yOutput.reset(); } skipBlock = _skipBlock; - writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(getProperty("g53HomePositionX"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(staticProperties.g53HomePositionX)); // retract xOutput.reset(); if (retractZ) { skipBlock = _skipBlock; - writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format((section.spindle == SPINDLE_SECONDARY) ? getProperty("g53HomePositionSubZ") : getProperty("g53HomePositionZ"))); // retract with regard to spindle + writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format((section.spindle == SPINDLE_SECONDARY) ? staticProperties.g53HomePositionSubZ : staticProperties.g53HomePositionZ)); // retract with regard to spindle zOutput.reset(); } } @@ -1049,9 +1094,9 @@ function writeBlock() { skipBlock = false; return; } - if (getProperty("showSequenceNumbers")) { + if (staticProperties.showSequenceNumbers) { if (sequenceNumber > 99999) { - sequenceNumber = getProperty("sequenceNumberStart"); + sequenceNumber = staticProperties.sequenceNumberStart; } if (optionalSection || skipBlock) { if (text) { @@ -1060,7 +1105,7 @@ function writeBlock() { } else { writeWords2("N" + sequenceNumber, arguments); } - sequenceNumber += getProperty("sequenceNumberIncrement"); + sequenceNumber += staticProperties.sequenceNumberIncrement; } else { if (optionalSection || skipBlock) { writeWords2("/", arguments); @@ -1075,11 +1120,11 @@ function writeBlock() { Writes the specified optional block. */ function writeOptionalBlock() { - if (getProperty("showSequenceNumbers")) { + if (staticProperties.showSequenceNumbers) { var words = formatWords(arguments); if (words) { writeWords("/", "N" + sequenceNumber, words); - sequenceNumber += getProperty("sequenceNumberIncrement"); + sequenceNumber += staticProperties.sequenceNumberIncrement; } } else { writeWords2("/", arguments); @@ -1223,15 +1268,15 @@ function writeToolMeasureBlockBIDC(tool) { } function onOpen() { - if (getProperty("useRadius")) { + if (staticProperties.useRadius) { maximumCircularSweep = toRad(90); // avoid potential center calculation errors for CNC } - if (getProperty("useG61")) { + if (staticProperties.useG61) { gExactStopModal.format(64); } - xAxisMinimum = getProperty("xAxisMinimum"); + xAxisMinimum = staticProperties.xAxisMinimum; if (true) { var bAxisMain = createAxis({coordinate:1, table:false, axis:[0, -1, 0], range:[-0.001, 90.001], preference:0}); @@ -1262,11 +1307,11 @@ function onOpen() { return; } - if (!getProperty("separateWordsWithSpace")) { + if (!staticProperties.separateWordsWithSpace) { setWordSeparator(""); } - sequenceNumber = getProperty("sequenceNumberStart"); + sequenceNumber = staticProperties.sequenceNumberStart; writeln("%"); if (programName) { @@ -1300,7 +1345,7 @@ function onOpen() { // will1742 // TODO: Alter versions and headers - if (getProperty("writeVersion")) { + if (staticProperties.writeVersion) { if ((typeof getHeaderVersion == "function") && getHeaderVersion()) { writeComment(localize("Post Version") + ": " + getHeaderVersion()); } @@ -1314,7 +1359,7 @@ function onOpen() { var model = machineConfiguration.getModel(); var description = machineConfiguration.getDescription(); - if (getProperty("writeMachine") && (vendor || model || description)) { + if (staticProperties.writeMachine && (vendor || model || description)) { writeln(""); writeComment(localize("Machine")); if (vendor) { @@ -1329,7 +1374,7 @@ function onOpen() { } // dump tool information - if (getProperty("writeTools")) { + if (staticProperties.writeTools) { writeln(""); var zRanges = {}; @@ -1369,8 +1414,62 @@ function onOpen() { // Auto probe tools var tools = getToolTable(); if (tools.getNumberOfTools() > 0) { + let parsedTools = []; + + // Maybe should be anonymous function?? + function defaultFill() { + parsedTools = [] + for (var i = 0; i < tools.getNumberOfTools(); i++){ + parsedTools[i] = tools.getTool(i).number; + } + } + + // also maybe anonymous + // TODO: tool.getNumberOfTools needs to be machine-specific constant + function invalidToolNum(toolNum) { + return (toolNum < 1 || toolNum > MAXTOOLS); + } + + // parse string for specific tools to load + if (getProperty("toolsToLoad") != "") { + // get list of numbers + let toolNumArray = getProperty("toolsToLoad").toString().split(','); + + // iterate through and fill ranges + for (var i = 0; i < toolNumArray.length; i++){ + toolNumArray[i] = toolNumArray[i].trim(); + + // fill range + if (toolNumArray[i].indexOf("-") >= 0) { + let numRange = toolNumArray[i].split("-"); + if (invalidToolNum(parseInt(numRange[0])) || invalidToolNum(parseInt(numRange[1]))) { + defaultFill(); + break; + } + for(var j = numRange[0]; j <= numRange[1]; j++){ + parsedTools.push(parseInt(j)); + } + continue; + } + // check if valid num + if (invalidToolNum(parseInt(toolNumArray[i]))) { + defaultFill(); + break; + } + // push single num + parsedTools.push(parseInt(toolNumArray[i])); + } + } else { + defaultFill(); + } + for (var i = 0; i < tools.getNumberOfTools(); ++i) { var tool = tools.getTool(i); + + if (parsedTools.indexOf(tool.number) <= -1) { + continue; + } + var compensationOffset = tool.isTurningTool() ? tool.compensationOffset : tool.lengthOffset; var toolPosition = toolFormat.format(tool.number * 100 + compensationOffset % 100); var writeLoad = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; @@ -1418,8 +1517,8 @@ function onOpen() { } // support program looping for bar work - if (getProperty("looping")) { - if (getProperty("numberOfRepeats") < 1) { + if (staticProperties.looping) { + if (staticProperties.numberOfRepeats < 1) { error(localize("numberOfRepeats must be greater than 0.")); return; } @@ -1430,7 +1529,7 @@ function onOpen() { writeln(""); writeComment(localize("Local Looping")); writeln(""); - writeBlock(mFormat.format(97), "P1", "L" + getProperty("numberOfRepeats")); + writeBlock(mFormat.format(97), "P1", "L" + staticProperties.numberOfRepeats); onCommand(COMMAND_OPEN_DOOR); writeBlock(mFormat.format(30)); writeln(""); @@ -1456,7 +1555,7 @@ function onOpen() { onCommand(COMMAND_CLOSE_DOOR); - // writeBlock("#" + (firstFeedParameter - 1) + "=" + ((currentSection.spindle == SPINDLE_SECONDARY) ? getProperty("g53HomePositionSubZ") : getProperty("g53HomePositionZ")), formatComment("g53HomePositionZ")); + // writeBlock("#" + (firstFeedParameter - 1) + "=" + ((currentSection.spindle == SPINDLE_SECONDARY) ? staticProperties.g53HomePositionSubZ : staticProperties.g53HomePositionZ), formatComment("g53HomePositionZ")); var usesPrimarySpindle = false; var usesSecondarySpindle = false; @@ -1475,35 +1574,35 @@ function onOpen() { } } - writeBlock(gFormat.format(50), sOutput.format(getSection(0).spindle == SPINDLE_PRIMARY ? getProperty("maximumSpindleSpeed") : getProperty("subMaximumSpindleSpeed"))); + writeBlock(gFormat.format(50), sOutput.format(getSection(0).spindle == SPINDLE_PRIMARY ? staticProperties.maximumSpindleSpeed : staticProperties.subMaximumSpindleSpeed)); sOutput.reset(); - if (getProperty("gotChipConveyor")) { + if (staticProperties.gotChipConveyor) { onCommand(COMMAND_START_CHIP_TRANSPORT); } if (gotYAxis) { - writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(getProperty("g53HomePositionY"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(staticProperties.g53HomePositionY)); // retract } - writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(getProperty("g53HomePositionX"))); // retract - writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(getProperty("g53HomePositionZ"))); // retract - if (getProperty("gotSecondarySpindle")) { - var b = getSection(0).spindle == SPINDLE_PRIMARY ? 0 : getProperty("g53WorkPositionSub"); + writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(staticProperties.g53HomePositionX)); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(staticProperties.g53HomePositionZ)); // retract + if (staticProperties.gotSecondarySpindle) { + var b = getSection(0).spindle == SPINDLE_PRIMARY ? 0 : staticProperties.g53WorkPositionSub; writeBlock(gFormat.format(53), gMotionModal.format(0), "B" + spatialFormat.format(b)); // retract Sub Spindle if applicable } // automatically eject part at end of program - if (getProperty("autoEject")) { + if (staticProperties.autoEject) { ejectRoutine = true; } /* if (getProperty("useM97")) { for (var i = 0; i < getNumberOfSections(); ++i) { var section = getSection(i); - writeBlock(mFormat.format(97), pFormat.format(section.getId() + getProperty("sequenceNumberStart")), conditional(section.hasParameter("operation-comment"), "(" + section.getParameter("operation-comment") + ")")); + writeBlock(mFormat.format(97), pFormat.format(section.getId() + staticProperties.sequenceNumberStart), conditional(section.hasParameter("operation-comment"), "(" + section.getParameter("operation-comment") + ")")); } writeBlock(mFormat.format(30)); - if (getProperty("showSequenceNumbers") && getProperty("useM97")) { + if (staticProperties.showSequenceNumbers && getProperty("useM97")) { error(localize("Properties 'showSequenceNumbers' and 'useM97' cannot be active together at the same time.")); return; } @@ -2016,7 +2115,7 @@ function onSection() { abcFormat.areDifferent(bAxisOrientationTurning.y, machineState.currentBAxisOrientationTurning.y) || abcFormat.areDifferent(bAxisOrientationTurning.z, machineState.currentBAxisOrientationTurning.z)); - operationNeedsSafeStart = getProperty("safeStartAllOperations") && !isFirstSection(); + operationNeedsSafeStart = staticProperties.safeStartAllOperations && !isFirstSection(); if (insertToolCall || newSpindle || newWorkOffset || newWorkPlane && (!currentSection.isPatterned() && (!machineState.stockTransferIsActive && !partCutoff))) { @@ -2059,7 +2158,7 @@ function onSection() { /* if (getProperty("useM97")) { - writeBlock("N" + spatialFormat.format(currentSection.getId() + getProperty("sequenceNumberStart"))); + writeBlock("N" + spatialFormat.format(currentSection.getId() + staticProperties.sequenceNumberStart)); } */ @@ -2076,11 +2175,11 @@ function onSection() { } if (!insertToolCall && operationNeedsSafeStart) { - skipBlock = true; + skipBlock = false; writeRetract(currentSection, true); // retract in Z also } - if (getProperty("showNotes") && hasParameter("notes")) { + if (staticProperties.showNotes && hasParameter("notes")) { var notes = getParameter("notes"); if (notes) { var lines = String(notes).split("\n"); @@ -2099,12 +2198,12 @@ function onSection() { if (insertToolCall) { forceWorkPlane(); } - if (!getProperty("optimizeCAxisSelect")) { + if (!staticProperties.rapidReoptimizeCAxisSelectinds) { cAxisEngageModal.reset(); } retracted = insertToolCall; - if (!isFirstSection() && getProperty("optionalStop")) { + if (!isFirstSection() && staticProperties.optionalStop) { skipBlock = !insertToolCall; onCommand(COMMAND_OPTIONAL_STOP); } @@ -2140,7 +2239,7 @@ function onSection() { return; } - if (getProperty("gotSecondarySpindle")) { + if (staticProperties.gotSecondarySpindle) { switch (currentSection.spindle) { case SPINDLE_PRIMARY: // main spindle cFormat = createFormat({decimals:3, forceDecimal:true, scale:DEG}); @@ -2167,7 +2266,7 @@ function onSection() { } } - skipBlock = !insertToolCall; + skipBlock = false; writeBlock("T" + toolFormat.format(tool.number * 100 + compensationOffset)); if (tool.comment) { writeComment(tool.comment); @@ -2254,7 +2353,7 @@ function onSection() { } // Engage tailstock - if (getProperty("useTailStock")) { + if (staticProperties.useTailStock) { if (machineState.axialCenterDrilling || (currentSection.spindle == SPINDLE_SECONDARY) || (machineState.liveToolIsActive && (getMachiningDirection(currentSection) == MACHINING_DIRECTION_AXIAL))) { if (currentSection.tailstock) { @@ -2282,7 +2381,7 @@ function onSection() { warning(subst(localize("Spindle speed exceeds maximum value for operation \"%1\"."), getOperationComment())); } } - skipBlock = !insertToolCall && !spindleChange; + skipBlock = false; startSpindle(true, getFramePosition(currentSection.getInitialPosition())); } @@ -2357,7 +2456,7 @@ function onSection() { } } - if (getProperty("useG187")) { + if (staticProperties.useG187) { writeG187(); } @@ -2380,7 +2479,7 @@ function onSection() { } gMotionModal.reset(); - if (getProperty("useG61")) { + if (staticProperties.useG61) { writeBlock(gExactStopModal.format(61)); } @@ -2406,7 +2505,7 @@ function onSection() { startSpindle(false); } - if (getProperty("useParametricFeed") && + if (staticProperties.useParametricFeed && hasParameter("operation-strategy") && (getParameter("operation-strategy") != "drill") && // legacy !(currentSection.hasAnyCycle && currentSection.hasAnyCycle()) && @@ -2551,7 +2650,7 @@ function updateMachiningMode(section) { } } else { // several holes not on XY center bestABCIndex = getBestABCIndex(section); - if (getProperty("useYAxisForDrilling") && (bestABCIndex != undefined) && !doesCannedCycleIncludeYAxisMotion(section)) { + if (staticProperties.useYAxisForDrilling && (bestABCIndex != undefined) && !doesCannedCycleIncludeYAxisMotion(section)) { // use XYZ-mode } else { // use XZC mode machineState.useXZCMode = true; @@ -2823,7 +2922,7 @@ function rewindTable(startXYZ, currentZ, rewindC, feed, retract) { startSpindle(false); if (retract) { var x = getModulus(startXYZ.x, startXYZ.y); - if (getProperty("rapidRewinds")) { + if (staticProperties.rapidRewinds) { writeBlock(gMotionModal.format(1), xOutput.format(x), getFeed(highFeedrate)); writeBlock(gMotionModal.format(0), cOutput.format(rewindC)); } else { @@ -3120,7 +3219,7 @@ function getFeedDPM(_moveLength, _feed) { dpmFeed = previousDPMFeed; } } else { // machine specific calculation - var feedRate = _feed / (_moveLength.radius.z / (toPreciseUnit(getProperty("setting102"), IN) / 2.0)); + var feedRate = _feed / (_moveLength.radius.z / (toPreciseUnit(staticProperties.setting102, IN) / 2.0)); feedRate = Math.min(feedRate, highFeedrate / 2); dpmFeed = Math.min(feedRate, maxDPM); if (Math.abs(dpmFeed - previousDPMFeed) < dpmFeedToler) { @@ -3340,7 +3439,7 @@ function onCircular(clockwise, cx, cy, cz, x, y, z, feed) { return; } - if (machineState.usePolarMode && !getProperty("usePolarCircular")) { + if (machineState.usePolarMode && !staticProperties.usePolarCircular) { linearize(toler); return; } @@ -3358,7 +3457,7 @@ function onCircular(clockwise, cx, cy, cz, x, y, z, feed) { var start = getCurrentPosition(); if (isFullCircle()) { - if (getProperty("useRadius") || isHelical()) { // radius mode does not support full arcs + if (staticProperties.useRadius || isHelical()) { // radius mode does not support full arcs linearize(toler); return; } @@ -3383,7 +3482,7 @@ function onCircular(clockwise, cx, cy, cz, x, y, z, feed) { default: linearize(toler); } - } else if (!getProperty("useRadius")) { + } else if (!staticProperties.useRadius) { if (isHelical() && ((getCircularSweep() < toRad(30)) || (getHelicalPitch() > 10))) { // avoid G112 issue linearize(toler); return; @@ -3452,7 +3551,7 @@ function onCircular(clockwise, cx, cy, cz, x, y, z, feed) { function onCycle() { if ((typeof isSubSpindleCycle == "function") && isSubSpindleCycle(cycleType)) { - if (!getProperty("gotSecondarySpindle")) { + if (!staticProperties.gotSecondarySpindle) { error(localize("Secondary spindle is not available.")); return; } @@ -3494,7 +3593,7 @@ function onCycle() { writeBlock(pOutput.format(transferCodes.spindleRPM), transferCodes.spindleDirection ? getCode("START_SUB_SPINDLE_CCW") : getCode("START_SUB_SPINDLE_CW")); // inverted writeBlock(getCode("SPINDLE_SYNCHRONIZATION_ON"), "R" + abcFormat.format(cycle.spindleOrientation), formatComment("SPINDLE SYNCHRONIZATION ON")); // Sync spindles } - if (getProperty("airCleanChuck")) { + if (staticProperties.airCleanChuck) { writeBlock(getCode("MAINSPINDLE_AIR_BLAST_ON"), formatComment("MAINSPINDLE AIR BLAST ON")); writeBlock(getCode("SUBSPINDLE_AIR_BLAST_ON"), formatComment("SUBSPINDLE AIR BLAST ON")); } @@ -3505,7 +3604,7 @@ function onCycle() { onDwell(cycle.dwell); gMotionModal.reset(); writeBlock(conditional(cycle.useMachineFrame, gFormat.format(53)), gMotionModal.format(0), "B" + spatialFormat.format(cycle.feedPosition)); - if (getProperty("airCleanChuck")) { + if (staticProperties.airCleanChuck) { writeBlock(getCode("MAINSPINDLE_AIR_BLAST_OFF"), formatComment("MAINSPINDLE AIR BLAST OFF")); writeBlock(getCode("SUBSPINDLE_AIR_BLAST_OFF"), formatComment("SUBSPINDLE AIR BLAST OFF")); } @@ -3580,7 +3679,7 @@ function onCycle() { onDwell(cycle.dwell); } } - writeBlock(gMotionModal.format(0), gFormat.format(53), "B" + spatialFormat.format(getProperty("g53WorkPositionSub"))); + writeBlock(gMotionModal.format(0), gFormat.format(53), "B" + spatialFormat.format(staticProperties.g53WorkPositionSub)); if (machineState.spindleSynchronizationIsActive) { // spindles are synchronized if (cycle.unclampMode == "unclamp-secondary") { @@ -3605,7 +3704,7 @@ var pathBlockNumber = {start: 0, end: 0}; var isCannedCycle = false; function onCyclePath() { - saveShowSequenceNumbers = getProperty("showSequenceNumbers"); + saveShowSequenceNumbers = staticProperties.showSequenceNumbers; isCannedCycle = true; // buffer all paths and stop feeds being output feedOutput.disable(); @@ -3670,10 +3769,10 @@ function onCyclePathEnd() { function getStartEndSequenceNumber(cyclePath, start) { if (start) { - pathBlockNumber.start = sequenceNumber + conditional(saveShowSequenceNumbers, getProperty("sequenceNumberIncrement")); + pathBlockNumber.start = sequenceNumber + conditional(saveShowSequenceNumbers, staticProperties.sequenceNumberIncrement); return pathBlockNumber.start; } else { - pathBlockNumber.end = sequenceNumber + getProperty("sequenceNumberIncrement") + conditional(saveShowSequenceNumbers, (cyclePath.length - 1) * getProperty("sequenceNumberIncrement")); + pathBlockNumber.end = sequenceNumber + staticProperties.sequenceNumberIncrement + conditional(saveShowSequenceNumbers, (cyclePath.length - 1) * staticProperties.sequenceNumberIncrement); return pathBlockNumber.end; } } @@ -3720,7 +3819,7 @@ var threadNumber = 0; var numberOfThreads = 1; function onCyclePoint(x, y, z) { - if (!getProperty("useCycles") || currentSection.isMultiAxis() || getMachiningDirection(currentSection) == MACHINING_DIRECTION_INDEXING) { + if (!staticProperties.useCycles || currentSection.isMultiAxis() || getMachiningDirection(currentSection) == MACHINING_DIRECTION_INDEXING) { expandCyclePoint(x, y, z); return; } @@ -3762,7 +3861,7 @@ function onCyclePoint(x, y, z) { var threadPhaseAngle = (360 / numberOfThreads) * (threadNumber - 1); - if (getProperty("useSimpleThread")) { + if (staticProperties.useSimpleThread) { var i = -cycle.incrementalX; // positive if taper goes down - delta radius // move to thread start for infeed angle other than 0, multiple threads and alternate infeed. @@ -4324,11 +4423,11 @@ function engagePartCatcher(engage) { } else { onCommand(COMMAND_COOLANT_OFF); if (gotYAxis) { - writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(getProperty("g53HomePositionY"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(staticProperties.g53HomePositionY)); // retract yOutput.reset(); } - writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(getProperty("g53HomePositionX"))); // retract - writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(currentSection.spindle == SPINDLE_SECONDARY ? getProperty("g53HomePositionSubZ") : getProperty("g53HomePositionZ"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(staticProperties.g53HomePositionX)); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(currentSection.spindle == SPINDLE_SECONDARY ? staticProperties.g53HomePositionSubZ : staticProperties.g53HomePositionZ)); // retract writeBlock(getCode("PART_CATCHER_OFF"), formatComment(localize("PART CATCHER OFF"))); forceXYZ(); } @@ -4343,14 +4442,14 @@ function ejectPart() { //goHome(); // Position all axes to home position if (gotYAxis) { - writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(getProperty("g53HomePositionY"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(staticProperties.g53HomePositionY)); // retract yOutput.reset(); } - writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(getProperty("g53HomePositionX"))); // retract - writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(currentSection.spindle == SPINDLE_SECONDARY ? getProperty("g53HomePositionSubZ") : getProperty("g53HomePositionZ"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(staticProperties.g53HomePositionX)); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(currentSection.spindle == SPINDLE_SECONDARY ? staticProperties.g53HomePositionSubZ : staticProperties.g53HomePositionZ)); // retract onCommand(COMMAND_UNLOCK_MULTI_AXIS); - if (!getProperty("optimizeCAxisSelect")) { + if (!staticProperties.rapidReoptimizeCAxisSelectinds) { cAxisEngageModal.reset(); } writeBlock( @@ -4375,7 +4474,7 @@ function ejectPart() { onDwell(1.1); // clean out chips - if (getProperty("airCleanChuck")) { + if (staticProperties.airCleanChuck) { writeBlock(getCode(currentSection.spindle == SPINDLE_SECONDARY ? "SUBSPINDLE_AIR_BLAST_ON" : "MAINSPINDLE_AIR_BLAST_ON"), formatComment("AIR BLAST ON")); onDwell(2.5); @@ -4403,7 +4502,7 @@ function onSectionEnd() { startSpindle(true, getFramePosition(currentSection.getFinalPosition())); } - if (getProperty("useG61")) { + if (staticProperties.useG61) { writeBlock(gExactStopModal.format(64)); } @@ -4422,7 +4521,7 @@ function onSectionEnd() { } } - if (machineState.cAxisIsEngaged && !getProperty("optimizeCAxisSelect")) { + if (machineState.cAxisIsEngaged && !staticProperties.rapidReoptimizeCAxisSelectinds) { writeBlock(getCode("DISENGAGE_C_AXIS")); // used for c-axis encoder reset forceWorkPlane(); // needed since re-engage would result in undefined c-axis position } @@ -4439,27 +4538,27 @@ function onClose() { onCommand(COMMAND_COOLANT_OFF); - if (getProperty("gotChipConveyor")) { + if (staticProperties.gotChipConveyor) { onCommand(COMMAND_STOP_CHIP_TRANSPORT); } if (getNumberOfSections() > 0) { // Retracting Z first causes safezone overtravel error to keep from crashing into subspindle. Z should already be retracted to and end of section. var section = getSection(getNumberOfSections() - 1); if ((section.getType() != TYPE_TURNING) && isSameDirection(section.workPlane.forward, new Vector(0, 0, 1))) { - writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(getProperty("g53HomePositionX")), conditional(gotYAxis, "Y" + yFormat.format(getProperty("g53HomePositionY")))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(staticProperties.g53HomePositionX), conditional(gotYAxis, "Y" + yFormat.format(staticProperties.g53HomePositionY))); // retract xOutput.reset(); yOutput.reset(); - writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format((currentSection.spindle == SPINDLE_SECONDARY) ? getProperty("g53HomePositionSubZ") : getProperty("g53HomePositionZ"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format((currentSection.spindle == SPINDLE_SECONDARY) ? staticProperties.g53HomePositionSubZ : staticProperties.g53HomePositionZ)); // retract zOutput.reset(); writeBlock(getCode("STOP_SPINDLE")); } else { if (gotYAxis) { - writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(getProperty("g53HomePositionY"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(staticProperties.g53HomePositionY)); // retract } - writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(getProperty("g53HomePositionX"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(staticProperties.g53HomePositionX)); // retract xOutput.reset(); yOutput.reset(); - writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(currentSection.spindle == SPINDLE_SECONDARY ? getProperty("g53HomePositionSubZ") : getProperty("g53HomePositionZ"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(currentSection.spindle == SPINDLE_SECONDARY ? staticProperties.g53HomePositionSubZ : staticProperties.g53HomePositionZ)); // retract zOutput.reset(); writeBlock(getCode("STOP_SPINDLE")); } @@ -4469,7 +4568,7 @@ function onClose() { } gMotionModal.reset(); - if (!getProperty("optimizeCAxisSelect")) { + if (!staticProperties.rapidReoptimizeCAxisSelectinds) { cAxisEngageModal.reset(); } // writeBlock(getCode("DISENGAGE_C_AXIS")); @@ -4479,26 +4578,26 @@ function onClose() { } if (gotYAxis) { - writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(getProperty("g53HomePositionY"))); + writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(staticProperties.g53HomePositionY)); yOutput.reset(); } - if (getProperty("useBarFeeder")) { + if (staticProperties.useBarFeeder) { writeln(""); writeComment(localize("Bar feed")); // feed bar here - // writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(getProperty("g53HomePositionX"))); + // writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(staticProperties.g53HomePositionX)); writeBlock(gFormat.format(105)); } writeln(""); onImpliedCommand(COMMAND_END); onImpliedCommand(COMMAND_STOP_SPINDLE); - if (getProperty("looping")) { + if (staticProperties.looping) { writeBlock(mFormat.format(99)); } else if (true /*!getProperty("useM97")*/) { onCommand(COMMAND_OPEN_DOOR); - writeBlock(mFormat.format(getProperty("useBarFeeder") ? 99 : 30)); // stop program, spindle stop, coolant off + writeBlock(mFormat.format(staticProperties.useBarFeeder ? 99 : 30)); // stop program, spindle stop, coolant off } else { writeBlock(mFormat.format(99)); } @@ -4510,5 +4609,5 @@ function setProperty(property, value) { } // <<<<< INCLUDED FROM ../common/haas lathe.cps -properties.maximumSpindleSpeed.value = 4000; -properties.subMaximumSpindleSpeed.value = 4000; +// properties.maximumSpindleSpeed.value = 4000; +// properties.subMaximumSpindleSpeed.value = 4000; diff --git a/Haas_Lathes_BIDC/Bechtel ST-20Y.cps b/Haas_Lathes_BIDC/Bechtel ST-20Y.cps index bc72153..6b1fb35 100644 --- a/Haas_Lathes_BIDC/Bechtel ST-20Y.cps +++ b/Haas_Lathes_BIDC/Bechtel ST-20Y.cps @@ -62,7 +62,7 @@ allowSpiralMoves = false; highFeedrate = (unit == IN) ? 470 : 12000; // user-defined properties -properties = { +properties = {/* writeMachine: { title: "Write machine", description: "Output the machine settings in the header of the code.", @@ -276,15 +276,14 @@ properties = { type: "boolean", value: false, scope: "post" - }, + },*/ useSSV: { title: "Use SSV", description: "Outputs M38/M39 to enable SSV for turning operations.", type: "boolean", - group: 1, value: false, scope: "post" - }, + },/* optimizeCAxisSelect: { title: "Optimize C-axis selection", description: "Optimizes the output of enable/disable C-axis codes.", @@ -351,13 +350,21 @@ properties = { type: "boolean", value: false, scope: "post" + },*/ + toolsToLoad: { + title: "Tools to load and probe", + description: "List or provide a range of tools to probe e.g. 1, 2, 3 or 1-5. Leaving this empty will probe all tools", + group: 4, + type: "string", + value: "", + scope: "post" }, measureToolsAtStart: { title: "Tool Probing", description: "Tool loading and probing. By turning this off, you accept responsibility for any resulting crashes.", group: 0, type: "boolean", - value: false, + value: true, scope: "post" }, loadToolsAtStart: { @@ -365,13 +372,51 @@ properties = { description: "Tool loading only. By turning this off, you accept responsibility for any resulting crashes.", group: 0, type: "boolean", - value: false, + value: true, scope: "post" } }; staticProperties = { - postVersion: "BIDC-STY.G8.A21" + writeMachine: false, + writeTools: false, + writeVersion: false, + showSequenceNumbers: true, + sequenceNumberStart: 10, + sequenceNumberIncrement: 5, + optionalStop: true, + separateWordsWithSpace: true, + useRadius: false, + maximumSpindleSpeed: 4000, + subMaximumSpindleSpeed: 4000, + useParametricFeed: false, + showNotes: true, + useCycles: true, + autoEject: false, + g53HomePositionX: 0, + g53HomePositionY: 0, + g53HomePositionZ: 0, + g53HomePositionSubZ: 0, + g53WorkPositionSub: 0, + useTailStock: false, + useBarFeeder: false, + gotChipConveyor: false, + useG112: false, + usePolarCircular: false, + xAxisMinimum: 0, + useG61: false, + setting102: 1, + rapidRewinds: false, + optimizeCAxisSelect: false, + gotSecondarySpindle: false, + looping: false, + numberOfRepeats: 1, + useSimpleThread: true, + airCleanChuck: true, + safeStartAllOperations: true, + useYAxisForDrilling: false, + useG187: false, + postVersion: "BIDC-STY.G10.K21" }; var permittedCommentChars = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,=_-"; @@ -501,6 +546,8 @@ const BIDC_CUST_TURNING = 10; const PROBE_CENTERING_OFFSET = .375; // offet to center tool on probe +const MAXTOOLS = 12; + const SOUTHWEST = { num: 1, name: "SOUTHWEST" @@ -881,7 +928,7 @@ function startSpindle(forceRPMMode, initialPosition, rpm) { } var useConstantSurfaceSpeed = currentSection.getTool().getSpindleMode() == SPINDLE_CONSTANT_SURFACE_SPEED; - var maxSpeed = (currentSection.spindle == SPINDLE_SECONDARY) ? getProperty("subMaximumSpindleSpeed") : getProperty("maximumSpindleSpeed"); + var maxSpeed = (currentSection.spindle == SPINDLE_SECONDARY) ? staticProperties.subMaximumSpindleSpeed : staticProperties.maximumSpindleSpeed; var maximumSpindleSpeed = (tool.maximumSpindleSpeed > 0) ? Math.min(tool.maximumSpindleSpeed, maxSpeed) : maxSpeed; if (useConstantSurfaceSpeed && !forceRPMMode) { skipBlock = _skipBlock; @@ -926,7 +973,7 @@ function startSpindle(forceRPMMode, initialPosition, rpm) { } break; case SPINDLE_SECONDARY: // sub spindle - if (!getProperty("gotSecondarySpindle")) { + if (!staticProperties.gotSecondarySpindle) { error(localize("Secondary spindle is not available.")); return; } @@ -958,15 +1005,15 @@ function writeRetract(section, retractZ) { if (!isFirstSection()) { if (gotYAxis) { skipBlock = _skipBlock; - writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(getProperty("g53HomePositionY"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(staticProperties.g53HomePositionY)); // retract yOutput.reset(); } skipBlock = _skipBlock; - writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(getProperty("g53HomePositionX"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(staticProperties.g53HomePositionX)); // retract xOutput.reset(); if (retractZ) { skipBlock = _skipBlock; - writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format((section.spindle == SPINDLE_SECONDARY) ? getProperty("g53HomePositionSubZ") : getProperty("g53HomePositionZ"))); // retract with regard to spindle + writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format((section.spindle == SPINDLE_SECONDARY) ? staticProperties.g53HomePositionSubZ : staticProperties.g53HomePositionZ)); // retract with regard to spindle zOutput.reset(); } } @@ -1115,9 +1162,9 @@ function writeBlock() { skipBlock = false; return; } - if (getProperty("showSequenceNumbers")) { + if (staticProperties.showSequenceNumbers) { if (sequenceNumber > 99999) { - sequenceNumber = getProperty("sequenceNumberStart"); + sequenceNumber = staticProperties.sequenceNumberStart; } if (optionalSection || skipBlock) { if (text) { @@ -1126,7 +1173,7 @@ function writeBlock() { } else { writeWords2("N" + sequenceNumber, arguments); } - sequenceNumber += getProperty("sequenceNumberIncrement"); + sequenceNumber += staticProperties.sequenceNumberIncrement; } else { if (optionalSection || skipBlock) { writeWords2("/", arguments); @@ -1141,11 +1188,11 @@ function writeBlock() { Writes the specified optional block. */ function writeOptionalBlock() { - if (getProperty("showSequenceNumbers")) { + if (staticProperties.showSequenceNumbers) { var words = formatWords(arguments); if (words) { writeWords("/", "N" + sequenceNumber, words); - sequenceNumber += getProperty("sequenceNumberIncrement"); + sequenceNumber += staticProperties.sequenceNumberIncrement; } } else { writeWords2("/", arguments); @@ -1301,15 +1348,15 @@ function writeToolMeasureBlockBIDC(tool) { } function onOpen() { - if (getProperty("useRadius")) { + if (staticProperties.useRadius) { maximumCircularSweep = toRad(90); // avoid potential center calculation errors for CNC } - if (getProperty("useG61")) { + if (staticProperties.useG61) { gExactStopModal.format(64); } - xAxisMinimum = getProperty("xAxisMinimum"); + xAxisMinimum = staticProperties.xAxisMinimum; if (true) { var bAxisMain = createAxis({coordinate:1, table:false, axis:[0, -1, 0], range:[-0.001, 90.001], preference:0}); @@ -1340,11 +1387,11 @@ function onOpen() { return; } - if (!getProperty("separateWordsWithSpace")) { + if (!staticProperties.separateWordsWithSpace) { setWordSeparator(""); } - sequenceNumber = getProperty("sequenceNumberStart"); + sequenceNumber = staticProperties.sequenceNumberStart; writeln("%"); if (programName) { @@ -1378,7 +1425,7 @@ function onOpen() { // will1742 // TODO: Alter versions and headers - if (getProperty("writeVersion")) { + if (staticProperties.writeVersion) { if ((typeof getHeaderVersion == "function") && getHeaderVersion()) { writeComment(localize("Post Version") + ": " + getHeaderVersion()); } @@ -1392,7 +1439,7 @@ function onOpen() { var model = machineConfiguration.getModel(); var description = machineConfiguration.getDescription(); - if (getProperty("writeMachine") && (vendor || model || description)) { + if (staticProperties.writeMachine && (vendor || model || description)) { writeln(""); writeComment(localize("Machine")); if (vendor) { @@ -1407,7 +1454,7 @@ function onOpen() { } // dump tool information - if (getProperty("writeTools")) { + if (staticProperties.writeTools) { writeln(""); var zRanges = {}; @@ -1448,8 +1495,64 @@ function onOpen() { // Auto probe tools var tools = getToolTable(); if (tools.getNumberOfTools() > 0) { + + let parsedTools = []; + + // Maybe should be anonymous function?? + function defaultFill() { + parsedTools = [] + for (var i = 0; i < tools.getNumberOfTools(); i++){ + parsedTools[i] = tools.getTool(i).number; + } + } + + // also maybe anonymous + // TODO: tool.getNumberOfTools needs to be machine-specific constant + function invalidToolNum(toolNum) { + return (toolNum < 1 || toolNum > MAXTOOLS); + } + + // parse string for specific tools to load + if (getProperty("toolsToLoad") != "") { + // get list of numbers + let toolNumArray = getProperty("toolsToLoad").toString().split(','); + + // iterate through and fill ranges + for (var i = 0; i < toolNumArray.length; i++){ + toolNumArray[i] = toolNumArray[i].trim(); + + // fill range + if (toolNumArray[i].indexOf("-") >= 0) { + let numRange = toolNumArray[i].split("-"); + if (invalidToolNum(parseInt(numRange[0])) || invalidToolNum(parseInt(numRange[1]))) { + defaultFill(); + break; + } + for(var j = numRange[0]; j <= numRange[1]; j++){ + parsedTools.push(parseInt(j)); + } + continue; + } + // check if valid num + if (invalidToolNum(parseInt(toolNumArray[i]))) { + defaultFill(); + break; + } + // push single num + parsedTools.push(parseInt(toolNumArray[i])); + } + } else { + defaultFill(); + } + + for (var i = 0; i < tools.getNumberOfTools(); ++i) { var tool = tools.getTool(i); + + if (parsedTools.indexOf(tool.number) <= -1) { + continue; + } + var compensationOffset = tool.isTurningTool() ? tool.compensationOffset : tool.lengthOffset; var toolPosition = toolFormat.format(tool.number * 100 + compensationOffset % 100); var writeLoad = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; @@ -1498,8 +1601,8 @@ function onOpen() { } // support program looping for bar work - if (getProperty("looping")) { - if (getProperty("numberOfRepeats") < 1) { + if (staticProperties.looping) { + if (staticProperties.numberOfRepeats < 1) { error(localize("numberOfRepeats must be greater than 0.")); return; } @@ -1510,7 +1613,7 @@ function onOpen() { writeln(""); writeComment(localize("Local Looping")); writeln(""); - writeBlock(mFormat.format(97), "P1", "L" + getProperty("numberOfRepeats")); + writeBlock(mFormat.format(97), "P1", "L" + staticProperties.numberOfRepeats); onCommand(COMMAND_OPEN_DOOR); writeBlock(mFormat.format(30)); writeln(""); @@ -1536,7 +1639,7 @@ function onOpen() { onCommand(COMMAND_CLOSE_DOOR); - // writeBlock("#" + (firstFeedParameter - 1) + "=" + ((currentSection.spindle == SPINDLE_SECONDARY) ? getProperty("g53HomePositionSubZ") : getProperty("g53HomePositionZ")), formatComment("g53HomePositionZ")); + // writeBlock("#" + (firstFeedParameter - 1) + "=" + ((currentSection.spindle == SPINDLE_SECONDARY) ? staticProperties.g53HomePositionSubZ : staticProperties.g53HomePositionZ), formatComment("g53HomePositionZ")); var usesPrimarySpindle = false; var usesSecondarySpindle = false; @@ -1555,35 +1658,35 @@ function onOpen() { } } - writeBlock(gFormat.format(50), sOutput.format(getSection(0).spindle == SPINDLE_PRIMARY ? getProperty("maximumSpindleSpeed") : getProperty("subMaximumSpindleSpeed"))); + writeBlock(gFormat.format(50), sOutput.format(getSection(0).spindle == SPINDLE_PRIMARY ? staticProperties.maximumSpindleSpeed : staticProperties.subMaximumSpindleSpeed)); sOutput.reset(); - if (getProperty("gotChipConveyor")) { + if (staticProperties.gotChipConveyor) { onCommand(COMMAND_START_CHIP_TRANSPORT); } if (gotYAxis) { - writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(getProperty("g53HomePositionY"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(staticProperties.g53HomePositionY)); // retract } - writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(getProperty("g53HomePositionX"))); // retract - writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(getProperty("g53HomePositionZ"))); // retract - if (getProperty("gotSecondarySpindle")) { - var b = getSection(0).spindle == SPINDLE_PRIMARY ? 0 : getProperty("g53WorkPositionSub"); + writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(staticProperties.g53HomePositionX)); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(staticProperties.g53HomePositionZ)); // retract + if (staticProperties.gotSecondarySpindle) { + var b = getSection(0).spindle == SPINDLE_PRIMARY ? 0 : staticProperties.g53WorkPositionSub; writeBlock(gFormat.format(53), gMotionModal.format(0), "B" + spatialFormat.format(b)); // retract Sub Spindle if applicable } // automatically eject part at end of program - if (getProperty("autoEject")) { + if (staticProperties.autoEject) { ejectRoutine = true; } /* if (getProperty("useM97")) { for (var i = 0; i < getNumberOfSections(); ++i) { var section = getSection(i); - writeBlock(mFormat.format(97), pFormat.format(section.getId() + getProperty("sequenceNumberStart")), conditional(section.hasParameter("operation-comment"), "(" + section.getParameter("operation-comment") + ")")); + writeBlock(mFormat.format(97), pFormat.format(section.getId() + staticProperties.sequenceNumberStart), conditional(section.hasParameter("operation-comment"), "(" + section.getParameter("operation-comment") + ")")); } writeBlock(mFormat.format(30)); - if (getProperty("showSequenceNumbers") && getProperty("useM97")) { + if (staticProperties.showSequenceNumbers && getProperty("useM97")) { error(localize("Properties 'showSequenceNumbers' and 'useM97' cannot be active together at the same time.")); return; } @@ -2096,7 +2199,7 @@ function onSection() { abcFormat.areDifferent(bAxisOrientationTurning.y, machineState.currentBAxisOrientationTurning.y) || abcFormat.areDifferent(bAxisOrientationTurning.z, machineState.currentBAxisOrientationTurning.z)); - operationNeedsSafeStart = getProperty("safeStartAllOperations") && !isFirstSection(); + operationNeedsSafeStart = staticProperties.safeStartAllOperations && !isFirstSection(); if (insertToolCall || newSpindle || newWorkOffset || newWorkPlane && (!currentSection.isPatterned() && (!machineState.stockTransferIsActive && !partCutoff))) { @@ -2139,7 +2242,7 @@ function onSection() { /* if (getProperty("useM97")) { - writeBlock("N" + spatialFormat.format(currentSection.getId() + getProperty("sequenceNumberStart"))); + writeBlock("N" + spatialFormat.format(currentSection.getId() + staticProperties.sequenceNumberStart)); } */ @@ -2156,11 +2259,11 @@ function onSection() { } if (!insertToolCall && operationNeedsSafeStart) { - skipBlock = true; + skipBlock = false; writeRetract(currentSection, true); // retract in Z also } - if (getProperty("showNotes") && hasParameter("notes")) { + if (staticProperties.showNotes && hasParameter("notes")) { var notes = getParameter("notes"); if (notes) { var lines = String(notes).split("\n"); @@ -2184,8 +2287,8 @@ function onSection() { } retracted = insertToolCall; - if (!isFirstSection() && getProperty("optionalStop")) { - skipBlock = !insertToolCall; + if (!isFirstSection() && staticProperties.optionalStop) { + skipBlock = false; onCommand(COMMAND_OPTIONAL_STOP); } @@ -2220,7 +2323,7 @@ function onSection() { return; } - if (getProperty("gotSecondarySpindle")) { + if (staticProperties.gotSecondarySpindle) { switch (currentSection.spindle) { case SPINDLE_PRIMARY: // main spindle cFormat = createFormat({decimals:3, forceDecimal:true, scale:DEG}); @@ -2247,7 +2350,7 @@ function onSection() { } } - skipBlock = !insertToolCall; + skipBlock = false; writeBlock("T" + toolFormat.format(tool.number * 100 + compensationOffset)); if (tool.comment) { writeComment(tool.comment); @@ -2299,7 +2402,7 @@ function onSection() { if (!machineState.stockTransferIsActive) { if (machineState.isTurningOperation || machineState.axialCenterDrilling) { - skipBlock = !insertToolCall && (machineState.cAxisIsEngaged != undefined); + skipBlock = false; writeBlock(conditional(machineState.cAxisIsEngaged || (machineState.cAxisIsEngaged == undefined)), getCode("DISENGAGE_C_AXIS")); } else { // milling var engage = (currentSection.spindle == SPINDLE_PRIMARY) && (!machineState.cAxisIsEngaged || machineState.cAxisIsEngaged == undefined); @@ -2332,7 +2435,7 @@ function onSection() { } // Engage tailstock - if (getProperty("useTailStock")) { + if (staticProperties.useTailStock) { if (machineState.axialCenterDrilling || (currentSection.spindle == SPINDLE_SECONDARY) || (machineState.liveToolIsActive && (getMachiningDirection(currentSection) == MACHINING_DIRECTION_AXIAL))) { if (currentSection.tailstock) { @@ -2435,7 +2538,7 @@ function onSection() { } } - if (getProperty("useG187")) { + if (staticProperties.useG187) { writeG187(); } @@ -2458,7 +2561,7 @@ function onSection() { } gMotionModal.reset(); - if (getProperty("useG61")) { + if (staticProperties.useG61) { writeBlock(gExactStopModal.format(61)); } @@ -2484,7 +2587,7 @@ function onSection() { startSpindle(false); } - if (getProperty("useParametricFeed") && + if (staticProperties.useParametricFeed && hasParameter("operation-strategy") && (getParameter("operation-strategy") != "drill") && // legacy !(currentSection.hasAnyCycle && currentSection.hasAnyCycle()) && @@ -2629,7 +2732,7 @@ function updateMachiningMode(section) { } } else { // several holes not on XY center bestABCIndex = getBestABCIndex(section); - if (getProperty("useYAxisForDrilling") && (bestABCIndex != undefined) && !doesCannedCycleIncludeYAxisMotion(section)) { + if (staticProperties.useYAxisForDrilling && (bestABCIndex != undefined) && !doesCannedCycleIncludeYAxisMotion(section)) { // use XYZ-mode } else { // use XZC mode machineState.useXZCMode = true; @@ -2649,7 +2752,7 @@ function updateMachiningMode(section) { } } else { // toolpath does not match XY ranges, enable interpolation mode - if (getProperty("useG112") || forcePolarMode) { + if (staticProperties.useG112 || forcePolarMode) { if (currentSection.spindle == SPINDLE_SECONDARY) { error(localize("Polar mode is not supported on the secondary spindle.")); } @@ -2901,7 +3004,7 @@ function rewindTable(startXYZ, currentZ, rewindC, feed, retract) { startSpindle(false); if (retract) { var x = getModulus(startXYZ.x, startXYZ.y); - if (getProperty("rapidRewinds")) { + if (staticProperties.rapidRewinds) { writeBlock(gMotionModal.format(1), xOutput.format(x), getFeed(highFeedrate)); writeBlock(gMotionModal.format(0), cOutput.format(rewindC)); } else { @@ -3198,7 +3301,7 @@ function getFeedDPM(_moveLength, _feed) { dpmFeed = previousDPMFeed; } } else { // machine specific calculation - var feedRate = _feed / (_moveLength.radius.z / (toPreciseUnit(getProperty("setting102"), IN) / 2.0)); + var feedRate = _feed / (_moveLength.radius.z / (toPreciseUnit(staticProperties.setting102, IN) / 2.0)); feedRate = Math.min(feedRate, highFeedrate / 2); dpmFeed = Math.min(feedRate, maxDPM); if (Math.abs(dpmFeed - previousDPMFeed) < dpmFeedToler) { @@ -3418,7 +3521,7 @@ function onCircular(clockwise, cx, cy, cz, x, y, z, feed) { return; } - if (machineState.usePolarMode && !getProperty("usePolarCircular")) { + if (machineState.usePolarMode && !staticProperties.usePolarCircular) { linearize(toler); return; } @@ -3436,7 +3539,7 @@ function onCircular(clockwise, cx, cy, cz, x, y, z, feed) { var start = getCurrentPosition(); if (isFullCircle()) { - if (getProperty("useRadius") || isHelical()) { // radius mode does not support full arcs + if (staticProperties.useRadius || isHelical()) { // radius mode does not support full arcs linearize(toler); return; } @@ -3461,7 +3564,7 @@ function onCircular(clockwise, cx, cy, cz, x, y, z, feed) { default: linearize(toler); } - } else if (!getProperty("useRadius")) { + } else if (!staticProperties.useRadius) { if (isHelical() && ((getCircularSweep() < toRad(30)) || (getHelicalPitch() > 10))) { // avoid G112 issue linearize(toler); return; @@ -3530,7 +3633,7 @@ function onCircular(clockwise, cx, cy, cz, x, y, z, feed) { function onCycle() { if ((typeof isSubSpindleCycle == "function") && isSubSpindleCycle(cycleType)) { - if (!getProperty("gotSecondarySpindle")) { + if (!staticProperties.gotSecondarySpindle) { error(localize("Secondary spindle is not available.")); return; } @@ -3572,7 +3675,7 @@ function onCycle() { writeBlock(pOutput.format(transferCodes.spindleRPM), transferCodes.spindleDirection ? getCode("START_SUB_SPINDLE_CCW") : getCode("START_SUB_SPINDLE_CW")); // inverted writeBlock(getCode("SPINDLE_SYNCHRONIZATION_ON"), "R" + abcFormat.format(cycle.spindleOrientation), formatComment("SPINDLE SYNCHRONIZATION ON")); // Sync spindles } - if (getProperty("airCleanChuck")) { + if (staticProperties.airCleanChuck) { writeBlock(getCode("MAINSPINDLE_AIR_BLAST_ON"), formatComment("MAINSPINDLE AIR BLAST ON")); writeBlock(getCode("SUBSPINDLE_AIR_BLAST_ON"), formatComment("SUBSPINDLE AIR BLAST ON")); } @@ -3583,7 +3686,7 @@ function onCycle() { onDwell(cycle.dwell); gMotionModal.reset(); writeBlock(conditional(cycle.useMachineFrame, gFormat.format(53)), gMotionModal.format(0), "B" + spatialFormat.format(cycle.feedPosition)); - if (getProperty("airCleanChuck")) { + if (staticProperties.airCleanChuck) { writeBlock(getCode("MAINSPINDLE_AIR_BLAST_OFF"), formatComment("MAINSPINDLE AIR BLAST OFF")); writeBlock(getCode("SUBSPINDLE_AIR_BLAST_OFF"), formatComment("SUBSPINDLE AIR BLAST OFF")); } @@ -3658,7 +3761,7 @@ function onCycle() { onDwell(cycle.dwell); } } - writeBlock(gMotionModal.format(0), gFormat.format(53), "B" + spatialFormat.format(getProperty("g53WorkPositionSub"))); + writeBlock(gMotionModal.format(0), gFormat.format(53), "B" + spatialFormat.format(staticProperties.g53WorkPositionSub)); if (machineState.spindleSynchronizationIsActive) { // spindles are synchronized if (cycle.unclampMode == "unclamp-secondary") { @@ -3683,7 +3786,7 @@ var pathBlockNumber = {start: 0, end: 0}; var isCannedCycle = false; function onCyclePath() { - saveShowSequenceNumbers = getProperty("showSequenceNumbers"); + saveShowSequenceNumbers = staticProperties.showSequenceNumbers; isCannedCycle = true; // buffer all paths and stop feeds being output feedOutput.disable(); @@ -3748,10 +3851,10 @@ function onCyclePathEnd() { function getStartEndSequenceNumber(cyclePath, start) { if (start) { - pathBlockNumber.start = sequenceNumber + conditional(saveShowSequenceNumbers, getProperty("sequenceNumberIncrement")); + pathBlockNumber.start = sequenceNumber + conditional(saveShowSequenceNumbers, staticProperties.sequenceNumberIncrement); return pathBlockNumber.start; } else { - pathBlockNumber.end = sequenceNumber + getProperty("sequenceNumberIncrement") + conditional(saveShowSequenceNumbers, (cyclePath.length - 1) * getProperty("sequenceNumberIncrement")); + pathBlockNumber.end = sequenceNumber + staticProperties.sequenceNumberIncrement + conditional(saveShowSequenceNumbers, (cyclePath.length - 1) * staticProperties.sequenceNumberIncrement); return pathBlockNumber.end; } } @@ -3798,7 +3901,7 @@ var threadNumber = 0; var numberOfThreads = 1; function onCyclePoint(x, y, z) { - if (!getProperty("useCycles") || currentSection.isMultiAxis() || getMachiningDirection(currentSection) == MACHINING_DIRECTION_INDEXING) { + if (!staticProperties.useCycles || currentSection.isMultiAxis() || getMachiningDirection(currentSection) == MACHINING_DIRECTION_INDEXING) { expandCyclePoint(x, y, z); return; } @@ -3840,7 +3943,7 @@ function onCyclePoint(x, y, z) { var threadPhaseAngle = (360 / numberOfThreads) * (threadNumber - 1); - if (getProperty("useSimpleThread")) { + if (staticProperties.useSimpleThread) { var i = -cycle.incrementalX; // positive if taper goes down - delta radius // move to thread start for infeed angle other than 0, multiple threads and alternate infeed. @@ -4402,11 +4505,11 @@ function engagePartCatcher(engage) { } else { onCommand(COMMAND_COOLANT_OFF); if (gotYAxis) { - writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(getProperty("g53HomePositionY"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(staticProperties.g53HomePositionY)); // retract yOutput.reset(); } - writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(getProperty("g53HomePositionX"))); // retract - writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(currentSection.spindle == SPINDLE_SECONDARY ? getProperty("g53HomePositionSubZ") : getProperty("g53HomePositionZ"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(staticProperties.g53HomePositionX)); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(currentSection.spindle == SPINDLE_SECONDARY ? staticProperties.g53HomePositionSubZ : staticProperties.g53HomePositionZ)); // retract writeBlock(getCode("PART_CATCHER_OFF"), formatComment(localize("PART CATCHER OFF"))); forceXYZ(); } @@ -4421,11 +4524,11 @@ function ejectPart() { //goHome(); // Position all axes to home position if (gotYAxis) { - writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(getProperty("g53HomePositionY"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(staticProperties.g53HomePositionY)); // retract yOutput.reset(); } - writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(getProperty("g53HomePositionX"))); // retract - writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(currentSection.spindle == SPINDLE_SECONDARY ? getProperty("g53HomePositionSubZ") : getProperty("g53HomePositionZ"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(staticProperties.g53HomePositionX)); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(currentSection.spindle == SPINDLE_SECONDARY ? staticProperties.g53HomePositionSubZ : staticProperties.g53HomePositionZ)); // retract onCommand(COMMAND_UNLOCK_MULTI_AXIS); if (!getProperty("optimizeCAxisSelect")) { @@ -4453,7 +4556,7 @@ function ejectPart() { onDwell(1.1); // clean out chips - if (getProperty("airCleanChuck")) { + if (staticProperties.airCleanChuck) { writeBlock(getCode(currentSection.spindle == SPINDLE_SECONDARY ? "SUBSPINDLE_AIR_BLAST_ON" : "MAINSPINDLE_AIR_BLAST_ON"), formatComment("AIR BLAST ON")); onDwell(2.5); @@ -4481,7 +4584,7 @@ function onSectionEnd() { startSpindle(true, getFramePosition(currentSection.getFinalPosition())); } - if (getProperty("useG61")) { + if (staticProperties.useG61) { writeBlock(gExactStopModal.format(64)); } @@ -4517,27 +4620,27 @@ function onClose() { onCommand(COMMAND_COOLANT_OFF); - if (getProperty("gotChipConveyor")) { + if (staticProperties.gotChipConveyor) { onCommand(COMMAND_STOP_CHIP_TRANSPORT); } if (getNumberOfSections() > 0) { // Retracting Z first causes safezone overtravel error to keep from crashing into subspindle. Z should already be retracted to and end of section. var section = getSection(getNumberOfSections() - 1); if ((section.getType() != TYPE_TURNING) && isSameDirection(section.workPlane.forward, new Vector(0, 0, 1))) { - writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(getProperty("g53HomePositionX")), conditional(gotYAxis, "Y" + yFormat.format(getProperty("g53HomePositionY")))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(staticProperties.g53HomePositionX), conditional(gotYAxis, "Y" + yFormat.format(staticProperties.g53HomePositionY))); // retract xOutput.reset(); yOutput.reset(); - writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format((currentSection.spindle == SPINDLE_SECONDARY) ? getProperty("g53HomePositionSubZ") : getProperty("g53HomePositionZ"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format((currentSection.spindle == SPINDLE_SECONDARY) ? staticProperties.g53HomePositionSubZ : staticProperties.g53HomePositionZ)); // retract zOutput.reset(); writeBlock(getCode("STOP_SPINDLE")); } else { if (gotYAxis) { - writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(getProperty("g53HomePositionY"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(staticProperties.g53HomePositionY)); // retract } - writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(getProperty("g53HomePositionX"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(staticProperties.g53HomePositionX)); // retract xOutput.reset(); yOutput.reset(); - writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(currentSection.spindle == SPINDLE_SECONDARY ? getProperty("g53HomePositionSubZ") : getProperty("g53HomePositionZ"))); // retract + writeBlock(gFormat.format(53), gMotionModal.format(0), "Z" + zFormat.format(currentSection.spindle == SPINDLE_SECONDARY ? staticProperties.g53HomePositionSubZ : staticProperties.g53HomePositionZ)); // retract zOutput.reset(); writeBlock(getCode("STOP_SPINDLE")); } @@ -4557,26 +4660,26 @@ function onClose() { } if (gotYAxis) { - writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(getProperty("g53HomePositionY"))); + writeBlock(gFormat.format(53), gMotionModal.format(0), "Y" + yFormat.format(staticProperties.g53HomePositionY)); yOutput.reset(); } - if (getProperty("useBarFeeder")) { + if (staticProperties.useBarFeeder) { writeln(""); writeComment(localize("Bar feed")); // feed bar here - // writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(getProperty("g53HomePositionX"))); + // writeBlock(gFormat.format(53), gMotionModal.format(0), "X" + xFormat.format(staticProperties.g53HomePositionX)); writeBlock(gFormat.format(105)); } writeln(""); onImpliedCommand(COMMAND_END); onImpliedCommand(COMMAND_STOP_SPINDLE); - if (getProperty("looping")) { + if (staticProperties.looping) { writeBlock(mFormat.format(99)); } else if (true /*!getProperty("useM97")*/) { onCommand(COMMAND_OPEN_DOOR); - writeBlock(mFormat.format(getProperty("useBarFeeder") ? 99 : 30)); // stop program, spindle stop, coolant off + writeBlock(mFormat.format(staticProperties.useBarFeeder ? 99 : 30)); // stop program, spindle stop, coolant off } else { writeBlock(mFormat.format(99)); } @@ -4588,5 +4691,5 @@ function setProperty(property, value) { } // <<<<< INCLUDED FROM ../common/haas lathe.cps -properties.maximumSpindleSpeed.value = 4000; -properties.subMaximumSpindleSpeed.value = 4000; +// properties.maximumSpindleSpeed.value = 4000; +// properties.subMaximumSpindleSpeed.value = 4000;