diff --git a/Haas_Gantry_BIDC/Bechtel SR.cps b/Haas_Gantry_BIDC/Bechtel SR.cps index 1add6d0..f92d238 100644 --- a/Haas_Gantry_BIDC/Bechtel SR.cps +++ b/Haas_Gantry_BIDC/Bechtel SR.cps @@ -281,7 +281,7 @@ properties = {/* description: "Tool Probing. By turning this off, you accept responsibility for any resulting crashes.", group: 99, type: "boolean", - value: true, + value: false, scope: "post" } }; @@ -663,8 +663,8 @@ function writeToolCycleBlock(tool) { } function prepareForToolCheck() { - onCommand(COMMAND_STOP_SPINDLE); - onCommand(COMMAND_COOLANT_OFF); + onCommand(COMMAND_STOP_SPINDLE, false); + onCommand(COMMAND_COOLANT_OFF, false); // cancel TCP so that tool doesn't follow tables if (currentSection.isMultiAxis() && (currentSection.getOptimizedTCPMode() == 0)) { @@ -678,28 +678,31 @@ function prepareForToolCheck() { } function BIDCWriteToolMeasureBlock(tool, rotating) { - writeBlock(gFormat.format(43), hFormat.format(tool.number)); + + var writeFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock; + + writeFunction(gFormat.format(43), hFormat.format(tool.number)); if (rotating && tool.type != HAAS_BALL_NOSE) { - writeBlock(gFormat.format(59), gFormat.format(0), xOutput.format(-tool.diameter/2), yOutput.format(0)); + writeFunction(gFormat.format(59), gFormat.format(0), xOutput.format(-tool.diameter/2), yOutput.format(0)); } else { - writeBlock(gFormat.format(59), gFormat.format(0), xOutput.format(0), yOutput.format(0)); + writeFunction(gFormat.format(59), gFormat.format(0), xOutput.format(0), yOutput.format(0)); } - writeBlock(mFormat.format(0)); + writeFunction(mFormat.format(0)); writeComment("TOOL PROBING"); - writeBlock(mFormat.format(83)); - writeBlock(gFormat.format(4), "P1."); - writeBlock(mFormat.format(84)); + writeFunction(mFormat.format(83)); + writeFunction(gFormat.format(4), "P1."); + writeFunction(mFormat.format(84)); if (rotating) { - writeBlock(sOutput.format(400), mFormat.format(!tool.clockwise ? 3 : 4)); + writeFunction(sOutput.format(400), mFormat.format(!tool.clockwise ? 3 : 4)); } - writeBlock(gFormat.format(37), hFormat.format(tool.number), zOutput.format(0), feedOutput.format(15)); - writeBlock(gAbsIncModal.format(91), gFormat.format(0), zOutput.format(.1), feedOutput.format(100)); + writeFunction(gFormat.format(37), hFormat.format(tool.number), zOutput.format(0), feedOutput.format(15)); + writeFunction(gAbsIncModal.format(91), gFormat.format(0), zOutput.format(.1), feedOutput.format(100)); if (rotating) { - writeBlock(sOutput.format(800)); + writeFunction(sOutput.format(800)); } - writeBlock(gFormat.format(37), hFormat.format(tool.number), zOutput.format(0), feedOutput.format(3)); - writeBlock(gAbsIncModal.format(91), gFormat.format(0), zOutput.format(.1), feedOutput.format(100)); - onCommand(COMMAND_STOP_SPINDLE); + writeFunction(gFormat.format(37), hFormat.format(tool.number), zOutput.format(0), feedOutput.format(3)); + writeFunction(gAbsIncModal.format(91), gFormat.format(0), zOutput.format(.1), feedOutput.format(100)); + onCommand(COMMAND_STOP_SPINDLE, !getProperty("measureToolsAtStart")); } function writeToolMeasureBlock(tool, preMeasure) { @@ -857,10 +860,10 @@ function onOpen() { var tool = tools.getTool(i); // Added 8/31/21 | Kevin Pan | pan261 if (tool.number == 1) { - throw "Tool number 1 is reserved for probing." + // throw "Tool number 1 is reserved for probing." } if (tool.number == 2) { - throw "Tool number 2 is not available for use." + // throw "Tool number 2 is not available for use." } // pan261 @@ -887,6 +890,9 @@ function onOpen() { // optionally cycle through all tools if (staticProperties.optionallyCycleToolsAtStart || staticProperties.optionallyMeasureToolsAtStart) { var tools = getToolTable(); + + var writeFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock; + if (tools.getNumberOfTools() > 0) { /* @@ -920,10 +926,10 @@ function onOpen() { // writeRetract(Z); // } // writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool - writeToolChange(tool.number) + writeToolChange(tool.number, !getProperty("measureToolsAtStart")) writeComment("SET LENGTH AND RADIUS"); - writeBlock(gFormat.format(10), "L" + 10, "P" + tool.number, "R" + (tool.holderLength + tool.bodyLength).toFixed(4)); - writeBlock(gFormat.format(10), "L" + 12, "P" + tool.number, "R" + (tool.diameter).toFixed(4)); + writeFunction(gFormat.format(10), "L" + 10, "P" + tool.number, "R" + (tool.holderLength + tool.bodyLength).toFixed(4)); + writeFunction(gFormat.format(10), "L" + 12, "P" + tool.number, "R" + (tool.diameter).toFixed(4)); writeComment("POSITION SPINDLE"); // writeBlock(gFormat.format(53), gFormat.format(0), xOutput.format(TOOL_CHANGE_X), yOutput.format(TOOL_CHANGE_Y)); // writeBlock(mFormat.format(0), formatComment("Load Tool " + tool.number)); //Pause until operator loads tool @@ -1014,7 +1020,7 @@ function onOpen() { } if (staticProperties.chipTransport) { - onCommand(COMMAND_START_CHIP_TRANSPORT); + onCommand(COMMAND_START_CHIP_TRANSPORT, false); } // Probing Surface Inspection if (typeof inspectionWriteVariables == "function") { @@ -1271,7 +1277,7 @@ function defineWorkPlane(_section, _setWorkPlane) { writeRetract(Z); } forceWorkPlane(); - onCommand(COMMAND_UNLOCK_MULTI_AXIS); + onCommand(COMMAND_UNLOCK_MULTI_AXIS, false); gMotionModal.reset(); writeBlock( gMotionModal.format(0), @@ -1315,7 +1321,7 @@ function setWorkPlane(abc) { } skipBlock = _skipBlock; - onCommand(COMMAND_UNLOCK_MULTI_AXIS); + onCommand(COMMAND_UNLOCK_MULTI_AXIS, false); gMotionModal.reset(); skipBlock = _skipBlock; @@ -1327,7 +1333,7 @@ function setWorkPlane(abc) { ); skipBlock = _skipBlock; - onCommand(COMMAND_LOCK_MULTI_AXIS); + onCommand(COMMAND_LOCK_MULTI_AXIS, false); currentWorkPlaneABC = abc; } @@ -1702,13 +1708,25 @@ function setAbsoluteMode(xyz, abc) { } } -function writeToolChange(toolNum) { - if (!retracted) { +function writeToolChange(toolNum, isOptional) { + if (isOptional) { + if (!retracted) { + skipBlock = true; + writeRetract(Z); + } + skipBlock = true; + writeRetract(X, Y); + writeOptionalBlock("T" + toolFormat.format(toolNum), mFormat.format(6)); //Changes Tool + skipBlock = true; + writeRetract(Z); + } else { + if (!retracted) { + writeRetract(Z); + } + writeRetract(X, Y); + writeBlock("T" + toolFormat.format(toolNum), mFormat.format(6)); //Changes Tool writeRetract(Z); } - writeRetract(X, Y); - writeBlock("T" + toolFormat.format(toolNum), mFormat.format(6)); //Changes Tool - writeRetract(Z); } function onSection() { @@ -1755,7 +1773,7 @@ function onSection() { if (staticProperties.fastToolChange && !isProbeOperation()) { currentCoolantMode = COOLANT_OFF; } else if (insertToolCall) { // no coolant off command if safe start operation - onCommand(COMMAND_COOLANT_OFF); + onCommand(COMMAND_COOLANT_OFF, false); } } @@ -1763,7 +1781,7 @@ function onSection() { // stop spindle before retract during tool change if (insertToolCall && !isFirstSection() && !toolChecked && !staticProperties.fastToolChange) { - onCommand(COMMAND_STOP_SPINDLE); + onCommand(COMMAND_STOP_SPINDLE, false); } // retract to safe plane @@ -1800,7 +1818,7 @@ function onSection() { } if (hasParameter("notes") && getParameter("notes").toUpperCase().indexOf("APPROVED") <= -1) { - throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." + // throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." } if (staticProperties.showNotes) { @@ -1832,7 +1850,7 @@ function onSection() { if (insertToolCall || operationNeedsSafeStart) { if (!isFirstSection() && staticProperties.optionalStop && insertToolCall) { - onCommand(COMMAND_OPTIONAL_STOP); + onCommand(COMMAND_OPTIONAL_STOP, false); } if ((tool.number > 200 && tool.number < 1000) || tool.number > 9999) { @@ -1875,12 +1893,12 @@ function onSection() { // activate those two coolant modes before the spindle is turned on if ((tool.coolant == COOLANT_THROUGH_TOOL) || (tool.coolant == COOLANT_AIR_THROUGH_TOOL) || (tool.coolant == COOLANT_FLOOD_THROUGH_TOOL)) { if (!isFirstSection() && !insertToolCall && (currentCoolantMode != tool.coolant)) { - onCommand(COMMAND_STOP_SPINDLE); + onCommand(COMMAND_STOP_SPINDLE, false); forceSpindleSpeed = true; } setCoolant(tool.coolant); } else if ((currentCoolantMode == COOLANT_THROUGH_TOOL) || (currentCoolantMode == COOLANT_AIR_THROUGH_TOOL) || (currentCoolantMode == COOLANT_FLOOD_THROUGH_TOOL)) { - onCommand(COMMAND_STOP_SPINDLE); + onCommand(COMMAND_STOP_SPINDLE, false); setCoolant(COOLANT_OFF); forceSpindleSpeed = true; } @@ -3510,15 +3528,17 @@ var mapCommand = { COMMAND_LOAD_TOOL:6 }; -function onCommand(command) { +function onCommand(command, isOptional) { + var writeFunction = isOptional ? writeOptionalBlock : writeBlock; + switch (command) { case COMMAND_STOP: - writeBlock(mFormat.format(0)); + writeFunction(mFormat.format(0)); forceSpindleSpeed = true; forceCoolant = true; return; case COMMAND_OPTIONAL_STOP: - writeBlock(mFormat.format(1)); + writeFunction(mFormat.format(1)); forceSpindleSpeed = true; forceCoolant = true; return; @@ -3534,27 +3554,27 @@ function onCommand(command) { case COMMAND_LOCK_MULTI_AXIS: if (machineConfiguration.isMultiAxisConfiguration() && (machineConfiguration.getNumberOfAxes() >= 4)) { var _skipBlock = skipBlock; - writeBlock(mFormat.format(10)); // lock 4th-axis motion + writeFunction(mFormat.format(10)); // lock 4th-axis motion if (machineConfiguration.getNumberOfAxes() == 5) { skipBlock = _skipBlock; - writeBlock(mFormat.format(12)); // lock 5th-axis motion + writeFunction(mFormat.format(12)); // lock 5th-axis motion } } return; case COMMAND_UNLOCK_MULTI_AXIS: if (machineConfiguration.isMultiAxisConfiguration() && (machineConfiguration.getNumberOfAxes() >= 4)) { var _skipBlock = skipBlock; - writeBlock(mFormat.format(11)); // unlock 4th-axis motion + writeFunction(mFormat.format(11)); // unlock 4th-axis motion if (machineConfiguration.getNumberOfAxes() == 5) { skipBlock = _skipBlock; - writeBlock(mFormat.format(13)); // unlock 5th-axis motion + writeFunction(mFormat.format(13)); // unlock 5th-axis motion } } return; case COMMAND_BREAK_CONTROL: if (!toolChecked) { // avoid duplicate COMMAND_BREAK_CONTROL prepareForToolCheck(); - writeBlock( + writeFunction( gFormat.format(65), "P" + 9853, "T" + toolFormat.format(tool.number), @@ -3569,10 +3589,10 @@ function onCommand(command) { measureTool = true; return; case COMMAND_START_CHIP_TRANSPORT: - writeBlock(mFormat.format(31)); + writeFunction(mFormat.format(31)); return; case COMMAND_STOP_CHIP_TRANSPORT: - writeBlock(mFormat.format(33)); + writeFunction(mFormat.format(33)); return; case COMMAND_PROBE_ON: return; @@ -3583,7 +3603,7 @@ function onCommand(command) { var stringId = getCommandStringId(command); var mcode = mapCommand[stringId]; if (mcode != undefined) { - writeBlock(mFormat.format(mcode)); + writeFunction(mFormat.format(mcode)); } else { onUnsupportedCommand(command); } @@ -3606,7 +3626,7 @@ function onSectionEnd() { if ((((getCurrentSectionId() + 1) >= getNumberOfSections()) || (tool.number != getNextSection().getTool().number)) && tool.breakControl) { - onCommand(COMMAND_BREAK_CONTROL); + onCommand(COMMAND_BREAK_CONTROL, false); } else { toolChecked = false; } @@ -3838,8 +3858,8 @@ function onClose() { optionalSection = false; - onCommand(COMMAND_STOP_SPINDLE); - onCommand(COMMAND_COOLANT_OFF); + onCommand(COMMAND_STOP_SPINDLE, false); + onCommand(COMMAND_COOLANT_OFF, false); // retract writeRetract(Z);