Skip to content

Commit

Permalink
Measure/load independently optional
Browse files Browse the repository at this point in the history
  • Loading branch information
will1742 committed Sep 7, 2021
1 parent cf16a32 commit 9365375
Show file tree
Hide file tree
Showing 3 changed files with 320 additions and 331 deletions.
220 changes: 109 additions & 111 deletions Haas_Mills_BIDC/Bechtel DT.cps
Original file line number Diff line number Diff line change
Expand Up @@ -928,17 +928,16 @@ function writeToolMeasureBlock(tool, preMeasure) {
"K" + xyzFormat.format(getHaasKFactorBIDC(tool)),
"I0.",
comment
); // probe tool
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)";
writeWords(getProperty("measureToolsAtStart") ? line1 : "/ " + line1);
if (probeType == 3) {
line2 = "IF [[#" + (2400 + tool.number) + " GT " +
(tool.diameter + DIAM_TOLERANCE).toFixed(2) + "] OR [#" +
); // probe tooling
var 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)";
writeWords(getProperty("measureToolsAtStart") ? line1 : "/ " + line1);
if (probeType == 3) {
var 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)";
Expand Down Expand Up @@ -1332,128 +1331,127 @@ function onOpen() {
// 6/21/21 | Gavin Williams | will1742
// Probing now required. Using P9995.
// optionally cycle through all tools
if (true) {
var tools = getToolTable();
var tools = getToolTable();

var writeFunction = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock;
var writeFunction = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock;

if (tools.getNumberOfTools() > 0) {
writeln("");
/*
writeOptionalBlock(mFormat.format(0), formatComment(localize("Read note"))); // wait for operator
writeComment(localize("With BLOCK DELETE turned off each tool will cycle through"));
writeComment(localize("the spindle to verify that the correct tool is in the tool magazine"));
if (getProperty("optionallyMeasureToolsAtStart")) {
writeComment(localize("and to automatically measure it"));
}
writeComment(localize("Once the tools are verified turn BLOCK DELETE on to skip verification"));
*/
if (tools.getNumberOfTools() > 0) {
writeln("");
/*
writeOptionalBlock(mFormat.format(0), formatComment(localize("Read note"))); // wait for operator
writeComment(localize("With BLOCK DELETE turned off each tool will cycle through"));
writeComment(localize("the spindle to verify that the correct tool is in the tool magazine"));
if (getProperty("optionallyMeasureToolsAtStart")) {
writeComment(localize("and to automatically measure it"));
}
writeComment(localize("Once the tools are verified turn BLOCK DELETE on to skip verification"));
*/

// 6/21/21 | Gavin Williams | will1742
writeComment("Load and probe tools");
// 6/21/21 | Gavin Williams | will1742
writeComment("Load and probe tools");

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

let parsedTools = [];
let parsedTools = [];

// Maybe should be anonymous function??
function defaultFill() {
parsedTools = []
for (var i = 0; i < tools.getNumberOfTools(); i++){
parsedTools[i] = tools.getTool(i).number;
}
// 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 > tools.getNumberOfTools() || tools.getTool(toolNum) == undefined);
}
// 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 (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]))) {
// 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 (invalidToolNum(parseInt(numRange[0])) || invalidToolNum(parseInt(numRange[1]))) {
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 (tool.bodyLength + tool.holderLength > MAX_TOOL_LENGTH) {
throw "Error: T" + tool.number + " length greater than machine max"
for(var j = numRange[0]; j <= numRange[1]; j++){
parsedTools.push(parseInt(j));
}
continue;
}

if (tool.diameter > MAX_TOOL_DIAM) {
throw "Error : T" + tool.number + " diameter greater than machine max"
// check if valid num
if (invalidToolNum(parseInt(toolNumArray[i]))) {
defaultFill();
break;
}
// push single num
parsedTools.push(parseInt(toolNumArray[i]));
}
} else {
defaultFill();
}

if (parsedTools.indexOf(tool.number) <= -1) {
continue;
}
for (var i = 0; i < tools.getNumberOfTools(); i++) {
var tool = tools.getTool(i);
if (tool.bodyLength + tool.holderLength > MAX_TOOL_LENGTH) {
throw "Error: T" + tool.number + " length greater than machine max"
}

if (getProperty("measureToolsAtStart") && (tool.type == TOOL_PROBE)) {
continue;
}
if (tool.diameter > MAX_TOOL_DIAM) {
throw "Error : T" + tool.number + " diameter greater than machine max"
}

// 07/16/21 | will1742 | Gavin Williams
// Verify tool numbers
if (tool.number == 20 && tool.type != TOOL_PROBE) {
throw "Error: T20 is reserved for Probe";
}
if (parsedTools.indexOf(tool.number) <= -1) {
continue;
}

if (tool.number == 19) {
throw "Error: T19 is reserved for WCS verification tool";
}
if (getProperty("measureToolsAtStart") && (tool.type == TOOL_PROBE)) {
continue;
}

writeln("");
var comment = "T" + toolFormat.format(tool.number) + " " +
"D=" + xyzFormat.format(tool.diameter) + " " +
localize("CR") + "=" + xyzFormat.format(tool.cornerRadius);
if ((tool.taperAngle > 0) && (tool.taperAngle < Math.PI)) {
comment += " " + localize("TAPER") + "=" + taperFormat.format(tool.taperAngle) + localize("deg");
}
comment += " - " + getToolTypeName(tool.type);
writeComment(tool.description);
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);
// 07/16/21 | will1742 | Gavin Williams
// Verify tool numbers
if (tool.number == 20 && tool.type != TOOL_PROBE) {
throw "Error: T20 is reserved for Probe";
}
}

writeln("");
writeComment("SETUP FOR OPERATION");
writeBlock(mFormat.format(131));
if (tool.number == 19) {
throw "Error: T19 is reserved for WCS verification tool";
}

writeln("");
var comment = "T" + toolFormat.format(tool.number) + " " +
"D=" + xyzFormat.format(tool.diameter) + " " +
localize("CR") + "=" + xyzFormat.format(tool.cornerRadius);
if ((tool.taperAngle > 0) && (tool.taperAngle < Math.PI)) {
comment += " " + localize("TAPER") + "=" + taperFormat.format(tool.taperAngle) + localize("deg");
}
comment += " - " + getToolTypeName(tool.type);

writeComment(tool.description);
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);
}
}

writeln("");
writeComment("SETUP FOR OPERATION");
writeFunction(mFormat.format(131));

if (staticProperties.useDWO) {
var failed = false;
var dynamicWCSs = {};
Expand Down Expand Up @@ -2430,7 +2428,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
Loading

0 comments on commit 9365375

Please sign in to comment.