Skip to content

Commit

Permalink
update on optional tool measure blocks
Browse files Browse the repository at this point in the history
Works when measureToolsAtStart is `false`, however doesn't work when it's `true`
  • Loading branch information
pan261 authored and will1742 committed Sep 7, 2021
1 parent 7b3058b commit 045ad88
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 34 deletions.
4 changes: 2 additions & 2 deletions Haas_Mills_BIDC/Bechtel DT.cps
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,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"
}
};
Expand Down Expand Up @@ -2405,7 +2405,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) {
Expand Down
87 changes: 55 additions & 32 deletions Haas_Mills_BIDC/Bechtel VF2.cps
Original file line number Diff line number Diff line change
Expand Up @@ -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: false,
scope: "post"
}
};

Expand Down Expand Up @@ -886,15 +894,16 @@ function prepareForToolCheck() {
}

function writeToolMeasureBlock(tool, preMeasure) {
// var writeFunction = measureTool ? writeBlock : writeOptionalBlock;
var writeFunction = writeBlock;
var writeBlockFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock;
var writeWordsFunction = getProperty("measureToolsAtStart") ? writeWords() : writeWordsOptional;
var comment = measureTool ? formatComment("MEASURE TOOL") : "";
if (!preMeasure) {
prepareForToolCheck();
}
if (!staticProperties.useP9995) { // use Macro P9023 to measure tools
var probingType = getHaasProbingTypeBIDC(tool.type, true);
writeFunction(
writeBlockFunction(
gFormat.format(65),
"P9023",
"A" + probingType + ".",
Expand All @@ -905,10 +914,10 @@ 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(
writeBlockFunction(
gFormat.format(65),
"P9995",
"A0.",
Expand All @@ -921,13 +930,13 @@ function writeToolMeasureBlock(tool, preMeasure) {
"I0.",
comment
); // probe tool
writeWords("IF [[#" + (2000 + tool.number) + " GT " +
writeWordsFunction("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)");
if (probeType == 3) {
writeWords("IF [[#" + (2400 + tool.number) + " GT " +
writeWordsFunction("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)");
Expand All @@ -939,10 +948,19 @@ 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) {
writeWordsOptional("#" + macro + "=" + value, "(" + comment + ")");
} else {
writeWords("#" + macro + "=" + value, "(" + comment + ")");
}
}

function writeWordsOptional(text) {
writeWords("/ " + text);
}


function defineMachineModel() {
var useTCPC = getProperty("useTCPC");
switch (staticProperties.machineModel) {
Expand Down Expand Up @@ -1316,8 +1334,12 @@ function onOpen() {
// 6/21/21 | Gavin Williams | will1742
// Probing now required. Using P9995.
// optionally cycle through all tools
if (staticProperties.optionallyCycleToolsAtStart || getProperty("measureToolsAtStart")) {
// if (staticProperties.optionallyCycleToolsAtStart || getProperty("measureToolsAtStart")) {
if (true) {
var tools = getToolTable();
var writeFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock;
if (tools.getNumberOfTools() > 0) {
writeln("");
/*
Expand All @@ -1334,8 +1356,8 @@ function onOpen() {
writeComment("Load and probe tools");

// Display general tool probe info
displayMedia("toolProbeReminder.jpg");
writeBlock(mFormat.format(0));
displayMedia("toolProbeReminder.jpg", !getProperty("measureToolsAtStart"));
writeFunction(mFormat.format(0));

let parsedTools = [];

Expand Down Expand Up @@ -1422,15 +1444,12 @@ function onOpen() {
comment += " " + localize("TAPER") + "=" + taperFormat.format(tool.taperAngle) + localize("deg");
}
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("measureToolsAtStart"));
writeFunction(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool
writeToolMeasureBlock(tool, true);
}
}

Expand Down Expand Up @@ -2308,7 +2327,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));
}

Expand All @@ -2324,7 +2343,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");
Expand All @@ -2336,7 +2355,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"));
Expand Down Expand Up @@ -2398,7 +2417,7 @@ function onSection() {
}

if (!isFirstSection()) {
displayMedia("checkPartTool.jpg");
displayMedia("checkPartTool.jpg", false);
writeBlock(mFormat.format(0));
writeBlock(mFormat.format(131));
}
Expand Down Expand Up @@ -2775,7 +2794,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");
Expand Down Expand Up @@ -2815,8 +2834,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
Expand All @@ -2834,7 +2857,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));
Expand Down Expand Up @@ -4516,22 +4539,22 @@ 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));
}
}
writeBlock(mFormat.format(131));

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");
Expand Down

0 comments on commit 045ad88

Please sign in to comment.