From faa9abb51f660c9ecb8b0677d3a5652b0209ab48 Mon Sep 17 00:00:00 2001 From: pan261 Date: Mon, 6 Sep 2021 14:46:19 -0400 Subject: [PATCH] propagated VF2 changes to VF4 and DT --- Haas_Mills_BIDC/Bechtel DT.cps | 101 ++++++++++++++++++++------------ Haas_Mills_BIDC/Bechtel VF4.cps | 93 +++++++++++++++++++---------- 2 files changed, 126 insertions(+), 68 deletions(-) diff --git a/Haas_Mills_BIDC/Bechtel DT.cps b/Haas_Mills_BIDC/Bechtel DT.cps index d5352a4..184e038 100644 --- a/Haas_Mills_BIDC/Bechtel DT.cps +++ b/Haas_Mills_BIDC/Bechtel DT.cps @@ -436,7 +436,15 @@ properties = {/* description: "Tool Probing. By turning this off, you accept responsibility for any resulting crashes.", group: 99, type: "boolean", - value: false, + value: true, + scope: "post" + }, + loadToolsAtStart: { + title: "Tool Loading", + description: "Tool Loading. By turning this off, you accept responsibility for any resulting crashes.", + group: 99, + type: "boolean", + value: true, scope: "post" } }; @@ -886,8 +894,8 @@ function prepareForToolCheck() { } function writeToolMeasureBlock(tool, preMeasure) { - // var writeFunction = measureTool ? writeBlock : writeOptionalBlock; - var writeFunction = writeBlock; + var writeFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock; + // var writeFunction = writeBlock; var comment = measureTool ? formatComment("MEASURE TOOL") : ""; if (!preMeasure) { prepareForToolCheck(); @@ -905,8 +913,8 @@ function writeToolMeasureBlock(tool, preMeasure) { ); } else { // use Macro P9995 to measure tools // writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool - setMacro(1600 + tool.number, tool.numberOfFlutes, "Number of Flutes"); - setMacro(2400 + tool.number, xyzFormat.format(tool.diameter), "Tool Diameter"); + setMacro(1600 + tool.number, tool.numberOfFlutes, "Number of Flutes", !getProperty("measureToolsAtStart")); + setMacro(2400 + tool.number, xyzFormat.format(tool.diameter), "Tool Diameter", !getProperty("measureToolsAtStart")); var probeType = getHaasProbingTypeBIDC(tool, false); writeFunction( gFormat.format(65), @@ -921,16 +929,20 @@ function writeToolMeasureBlock(tool, preMeasure) { "I0.", comment ); // probe tool - writeWords("IF [[#" + (2000 + tool.number) + " GT " + + line1 = "IF [[#" + (2000 + tool.number) + " GT " + (tool.bodyLength + tool.holderLength + LENGTH_TOLERANCE).toFixed(2) + "] OR [#" + (2000 + tool.number) + " LT " + - (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"); + (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"; + + writeWords(getProperty("measureToolsAtStart") ? line1 : "/ " + line1); if (probeType == 3) { - writeWords("IF [[#" + (2400 + tool.number) + " GT " + + line2 = "IF [[#" + (2400 + tool.number) + " GT " + (tool.diameter + DIAM_TOLERANCE).toFixed(2) + "] OR [#" + (2400 + tool.number) + " LT " + - (tool.diameter - DIAM_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool diameter out of tolerance)"); + (tool.diameter - DIAM_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool diameter out of tolerance)"; + + writeWords(getProperty("measureToolsAtStart") ? line2 : "/ " + line2); } } measureTool = false; @@ -939,8 +951,12 @@ function writeToolMeasureBlock(tool, preMeasure) { // 6/28/21 | Gavin Williams | will1742 // 002 Improved Probing // sets specified macro number with value -function setMacro(macro, value, comment) { - writeWords("#" + macro + "=" + value, "(" + comment + ")"); +function setMacro(macro, value, comment, isOptional) { + if (isOptional) { + writeWords("/ #" + macro + "=" + value, "(" + comment + ")"); + } else { + writeWords("#" + macro + "=" + value, "(" + comment + ")"); + } } function defineMachineModel() { @@ -1316,8 +1332,11 @@ function onOpen() { // 6/21/21 | Gavin Williams | will1742 // Probing now required. Using P9995. // optionally cycle through all tools - if (staticProperties.optionallyCycleToolsAtStart || getProperty("measureToolsAtStart")) { + if (true) { var tools = getToolTable(); + + var writeFunction = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; + if (tools.getNumberOfTools() > 0) { writeln(""); /* @@ -1333,11 +1352,13 @@ function onOpen() { // 6/21/21 | Gavin Williams | will1742 writeComment("Load and probe tools"); - displayMedia("toolProbeReminder.jpg"); - writeBlock(mFormat.format(0)); + // Display general tool probe info + displayMedia("toolProbeReminder.jpg", !getProperty("loadToolsAtStart")); + writeFunction(mFormat.format(0)); let parsedTools = []; + // Maybe should be anonymous function?? function defaultFill() { parsedTools = [] for (var i = 0; i < tools.getNumberOfTools(); i++){ @@ -1345,19 +1366,25 @@ function onOpen() { } } - function validateToolNum(toolNum) { + // also maybe anonymous + // TODO: tool.getNumberOfTools needs to be machine-specific constant + function invalidToolNum(toolNum) { return (toolNum < 1 || toolNum > tools.getNumberOfTools() || tools.getTool(toolNum) == undefined); } + // parse string for specific tools to load if (getProperty("toolsToLoad") != "") { + // get list of numbers let toolNumArray = getProperty("toolsToLoad").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 (validateToolNum(parseInt(numRange[0])) || validateToolNum(parseInt(numRange[1]))) { + if (invalidToolNum(parseInt(numRange[0])) || invalidToolNum(parseInt(numRange[1]))) { defaultFill(); break; } @@ -1366,10 +1393,12 @@ function onOpen() { } continue; } - if (validateToolNum(parseInt(toolNumArray[i]))) { + // check if valid num + if (invalidToolNum(parseInt(toolNumArray[i]))) { defaultFill(); break; } + // push single num parsedTools.push(parseInt(toolNumArray[i])); } } else { @@ -1413,14 +1442,10 @@ function onOpen() { } comment += " - " + getToolTypeName(tool.type); writeComment(tool.description); - if (getProperty("measureToolsAtStart")) { - writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool - displayMedia("toolLoad" + tool.number + ".jpg"); - writeBlock(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool - writeToolMeasureBlock(tool, true); - } else { - writeToolCycleBlock(tool); - } + writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool + displayMedia("toolLoad" + tool.number + ".jpg", !getProperty("loadToolsAtStart")); + writeFunction(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool + writeToolMeasureBlock(tool, true); } } @@ -2296,7 +2321,7 @@ function onSection() { // writeBlock(gFormat.format(53), "X" + macroFormat.format(100), yOutput.format(0)); writeBlock(gFormat.format(55), gFormat.format(0), xOutput.format(Stock_X_55)); writeBlock(gFormat.format(53), gFormat.format(0), yOutput.format(0)); - displayMedia("loadStock.jpg"); + displayMedia("loadStock.jpg", false); writeBlock(mFormat.format(0)); } @@ -2312,7 +2337,7 @@ function onSection() { writeBlock("T" + toolFormat.format(19), mFormat.format(6)); //Changes Tool writeBlock(gFormat.format(55), gFormat.format(0), forceX.format(stockMidX), forceY.format(stockMidY)); - displayMedia("xyWCSCheck.jpg"); + displayMedia("xyWCSCheck.jpg", false); writeBlock(mFormat.format(0), formatComment("Open door")); /* displayMedia("Net Share/Media/checkPrompt.jpg"); @@ -2324,7 +2349,7 @@ function onSection() { writeWords("N" + nFormat.format(gotoRef['Y']), mFormat.format(131), formatComment("End Multimedia")); */ writeBlock(gFormat.format(55), gFormat.format(43), hFormat.format(19), zOutput.format(stockTopZ)); - displayMedia("zWCSCheck.jpg"); + displayMedia("zWCSCheck.jpg", false); writeBlock(mFormat.format(0), formatComment("Open door")); writeBlock(mFormat.format(131), formatComment("End Multimedia")); @@ -2386,7 +2411,7 @@ function onSection() { } if (!isFirstSection()) { - displayMedia("checkPartTool.jpg"); + displayMedia("checkPartTool.jpg", false); writeBlock(mFormat.format(0)); writeBlock(mFormat.format(131)); } @@ -2763,7 +2788,7 @@ function onSection() { var toolDistance = initialPosition.z - stockTopZ; // Prompt user to check stock-tool distance - displayMedia("checkDistance" + toolDistance.toPrecision(2).toString().replace(".", "_") + ".jpg"); + displayMedia("checkDistance" + toolDistance.toPrecision(2).toString().replace(".", "_") + ".jpg", false); writeBlock(mFormat.format(0)); writeComment("OPEN DOOR"); //displayMedia("Net Share/Media/checkPrompt.jpg"); @@ -2803,8 +2828,12 @@ function onSection() { // Issue 001 Input and Validation // Displays a file: MP4, MOV, PNG, JPEG. 1920x1080 // Input: Absolute path to file -function displayMedia(file) { - writeBlock(mFormat.format(130), formatComment("Net Share/Media/" + file)); +function displayMedia(file, isOptional) { + if (isOptional) { + writeOptionalBlock(mFormat.format(130), formatComment("Net Share/Media/" + file)); + } else { + writeBlock(mFormat.format(130), formatComment("Net Share/Media/" + file)); + } } // Added 6/14/21 | Gavin Williams | will1742 @@ -2822,7 +2851,7 @@ function takeInput(prompt, options) { if (macroNumber > 549) macroNumber = 500; // init macro var to 0 - setMacro(macroNumber, 0, "Initialize macro variable"); + setMacro(macroNumber, 0, "Initialize macro variable", false); // disply prompt and save response writeBlock(mFormat.format(109), "P" + nFormat.format(macroNumber), formatComment(prompt)); @@ -4504,7 +4533,7 @@ function onClose() { continue; } writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool - displayMedia("removeTool" + tool.number + ".jpg"); + displayMedia("removeTool" + tool.number + ".jpg", false); writeBlock(mFormat.format(0)); } } @@ -4512,14 +4541,14 @@ function onClose() { function gotoWithMessage(xLoc, yLoc, fileName) { writeBlock(gFormat.format(53), xOutput.format(xLoc), yOutput.format(yLoc)); - displayMedia(fileName); + displayMedia(fileName, false); writeBlock(mFormat.format(0)); } writeln(""); writeComment("CLEAN MACHINE"); gotoWithMessage(X_TRAVEL_LIMIT/2, 0, "airGunClean.jpg"); - displayMedia("floodCoolantOff.jpg") + displayMedia("floodCoolantOff.jpg", false) writeBlock(mFormat.format(0)); setCoolant(COOLANT_FLOOD); gotoWithMessage(0, Y_TRAVEL_LIMIT, "sprayLowerRight.jpg"); diff --git a/Haas_Mills_BIDC/Bechtel VF4.cps b/Haas_Mills_BIDC/Bechtel VF4.cps index 29a6290..c37b6a3 100644 --- a/Haas_Mills_BIDC/Bechtel VF4.cps +++ b/Haas_Mills_BIDC/Bechtel VF4.cps @@ -438,6 +438,14 @@ properties = {/* type: "boolean", value: true, scope: "post" + }, + loadToolsAtStart: { + title: "Tool Loading", + description: "Tool Loading. By turning this off, you accept responsibility for any resulting crashes.", + group: 99, + type: "boolean", + value: true, + scope: "post" } }; @@ -886,8 +894,8 @@ function prepareForToolCheck() { } function writeToolMeasureBlock(tool, preMeasure) { - // var writeFunction = measureTool ? writeBlock : writeOptionalBlock; - var writeFunction = writeBlock; + var writeFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock; + // var writeFunction = writeBlock; var comment = measureTool ? formatComment("MEASURE TOOL") : ""; if (!preMeasure) { prepareForToolCheck(); @@ -905,8 +913,8 @@ function writeToolMeasureBlock(tool, preMeasure) { ); } else { // use Macro P9995 to measure tools // writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool - setMacro(1600 + tool.number, tool.numberOfFlutes, "Number of Flutes"); - setMacro(2400 + tool.number, xyzFormat.format(tool.diameter), "Tool Diameter"); + setMacro(1600 + tool.number, tool.numberOfFlutes, "Number of Flutes", !getProperty("measureToolsAtStart")); + setMacro(2400 + tool.number, xyzFormat.format(tool.diameter), "Tool Diameter", !getProperty("measureToolsAtStart")); var probeType = getHaasProbingTypeBIDC(tool, false); writeFunction( gFormat.format(65), @@ -921,16 +929,20 @@ function writeToolMeasureBlock(tool, preMeasure) { "I0.", comment ); // probe tool - writeWords("IF [[#" + (2000 + tool.number) + " GT " + + line1 = "IF [[#" + (2000 + tool.number) + " GT " + (tool.bodyLength + tool.holderLength + LENGTH_TOLERANCE).toFixed(2) + "] OR [#" + (2000 + tool.number) + " LT " + - (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"); + (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"; + + writeWords(getProperty("measureToolsAtStart") ? line1 : "/ " + line1); if (probeType == 3) { - writeWords("IF [[#" + (2400 + tool.number) + " GT " + + line2 = "IF [[#" + (2400 + tool.number) + " GT " + (tool.diameter + DIAM_TOLERANCE).toFixed(2) + "] OR [#" + (2400 + tool.number) + " LT " + - (tool.diameter - DIAM_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool diameter out of tolerance)"); + (tool.diameter - DIAM_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool diameter out of tolerance)"; + + writeWords(getProperty("measureToolsAtStart") ? line2 : "/ " + line2); } } measureTool = false; @@ -939,8 +951,12 @@ function writeToolMeasureBlock(tool, preMeasure) { // 6/28/21 | Gavin Williams | will1742 // 002 Improved Probing // sets specified macro number with value -function setMacro(macro, value, comment) { - writeWords("#" + macro + "=" + value, "(" + comment + ")"); +function setMacro(macro, value, comment, isOptional) { + if (isOptional) { + writeWords("/ #" + macro + "=" + value, "(" + comment + ")"); + } else { + writeWords("#" + macro + "=" + value, "(" + comment + ")"); + } } function defineMachineModel() { @@ -1316,8 +1332,11 @@ function onOpen() { // 6/21/21 | Gavin Williams | will1742 // Probing now required. Using P9995. // optionally cycle through all tools - if (staticProperties.optionallyCycleToolsAtStart || getProperty("measureToolsAtStart")) { + if (true) { var tools = getToolTable(); + + var writeFunction = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; + if (tools.getNumberOfTools() > 0) { writeln(""); /* @@ -1333,11 +1352,13 @@ function onOpen() { // 6/21/21 | Gavin Williams | will1742 writeComment("Load and probe tools"); - displayMedia("toolProbeReminder.jpg"); - writeBlock(mFormat.format(0)); + // Display general tool probe info + displayMedia("toolProbeReminder.jpg", !getProperty("loadToolsAtStart")); + writeFunction(mFormat.format(0)); let parsedTools = []; + // Maybe should be anonymous function?? function defaultFill() { parsedTools = [] for (var i = 0; i < tools.getNumberOfTools(); i++){ @@ -1345,19 +1366,25 @@ function onOpen() { } } - function validateToolNum(toolNum) { + // also maybe anonymous + // TODO: tool.getNumberOfTools needs to be machine-specific constant + function invalidToolNum(toolNum) { return (toolNum < 1 || toolNum > tools.getNumberOfTools() || tools.getTool(toolNum) == undefined); } - + + // parse string for specific tools to load if (getProperty("toolsToLoad") != "") { + // get list of numbers let toolNumArray = getProperty("toolsToLoad").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 (validateToolNum(parseInt(numRange[0])) || validateToolNum(parseInt(numRange[1]))) { + if (invalidToolNum(parseInt(numRange[0])) || invalidToolNum(parseInt(numRange[1]))) { defaultFill(); break; } @@ -1366,10 +1393,12 @@ function onOpen() { } continue; } - if (validateToolNum(parseInt(toolNumArray[i]))) { + // check if valid num + if (invalidToolNum(parseInt(toolNumArray[i]))) { defaultFill(); break; } + // push single num parsedTools.push(parseInt(toolNumArray[i])); } } else { @@ -1413,14 +1442,10 @@ function onOpen() { } comment += " - " + getToolTypeName(tool.type); writeComment(tool.description); - if (getProperty("measureToolsAtStart")) { - writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool - displayMedia("toolLoad" + tool.number + ".jpg"); - writeBlock(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool - writeToolMeasureBlock(tool, true); - } else { - writeToolCycleBlock(tool); - } + writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool + displayMedia("toolLoad" + tool.number + ".jpg", !getProperty("loadToolsAtStart")); + writeFunction(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool + writeToolMeasureBlock(tool, true); } } @@ -2410,7 +2435,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) { @@ -2808,8 +2833,12 @@ function onSection() { // Issue 001 Input and Validation // Displays a file: MP4, MOV, PNG, JPEG. 1920x1080 // Input: Absolute path to file -function displayMedia(file) { - writeBlock(mFormat.format(130), formatComment("Net Share/Media/" + file)); +function displayMedia(file, isOptional) { + if (isOptional) { + writeOptionalBlock(mFormat.format(130), formatComment("Net Share/Media/" + file)); + } else { + writeBlock(mFormat.format(130), formatComment("Net Share/Media/" + file)); + } } // Added 6/14/21 | Gavin Williams | will1742 @@ -2827,7 +2856,7 @@ function takeInput(prompt, options) { if (macroNumber > 549) macroNumber = 500; // init macro var to 0 - setMacro(macroNumber, 0, "Initialize macro variable"); + setMacro(macroNumber, 0, "Initialize macro variable", false); // disply prompt and save response writeBlock(mFormat.format(109), "P" + nFormat.format(macroNumber), formatComment(prompt)); @@ -4509,7 +4538,7 @@ function onClose() { continue; } writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool - displayMedia("removeTool" + tool.number + ".jpg"); + displayMedia("removeTool" + tool.number + ".jpg", false); writeBlock(mFormat.format(0)); } } @@ -4517,14 +4546,14 @@ function onClose() { function gotoWithMessage(xLoc, yLoc, fileName) { writeBlock(gFormat.format(53), xOutput.format(xLoc), yOutput.format(yLoc)); - displayMedia(fileName); + displayMedia(fileName, false); writeBlock(mFormat.format(0)); } writeln(""); writeComment("CLEAN MACHINE"); gotoWithMessage(X_TRAVEL_LIMIT/2, 0, "airGunClean.jpg"); - displayMedia("floodCoolantOff.jpg") + displayMedia("floodCoolantOff.jpg", false) writeBlock(mFormat.format(0)); setCoolant(COOLANT_FLOOD); gotoWithMessage(0, Y_TRAVEL_LIMIT, "sprayLowerRight.jpg");