Skip to content

Commit

Permalink
Added Options For Post
Browse files Browse the repository at this point in the history
  • Loading branch information
will1742 committed Jul 13, 2021
1 parent 7aea377 commit ee851e2
Showing 1 changed file with 79 additions and 62 deletions.
141 changes: 79 additions & 62 deletions Haas_Next_Generation/haas vf2.cps
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ allowSpiralMoves = true;
highFeedrate = 650 * 25.4; // must be in MM

// user-defined properties
/*
properties = {
properties = {/*
machineModel: {
title: "Machine model",
description: "Specifies the pre-configured machine model.",
Expand All @@ -73,7 +72,7 @@ properties = {
],
value: "none",
scope: "post"
},
},*/
hasAAxis: {
title: "Has A-axis rotary",
description: "Enable if the machine has an A-axis table/trunnion. Check the table direction on the machine and use the (Reversed) selection if the table is moving in the opposite direction.",
Expand Down Expand Up @@ -112,23 +111,23 @@ properties = {
],
value: "false",
scope: "post"
},
},/*
useDPMFeeds: {
title: "Rotary moves use DPM feeds",
description: "Enable to output DPM feeds, disable for Inverse Time feeds with rotary axes moves.",
group: 1,
type: "boolean",
value: false,
scope: "post"
},
},*/
useTCPC: {
title: "Use TCPC programming",
description: "The control supports Tool Center Point Control programming.",
group: 1,
type: "boolean",
value: true,
scope: "post"
},
},/*
useDWO: {
title: "Use DWO",
description: "Specifies that the Dynamic Work Offset feature (G254/G255) should be used.",
Expand Down Expand Up @@ -284,7 +283,7 @@ properties = {
type: "spatial",
value: 0,
scope: "post"
},
},*/
useSubroutines: {
title: "Use subroutines",
description: "Select your desired subroutine option. 'All Operations' creates subroutines per each operation, 'Cycles' creates subroutines for cycle operations on same holes, and 'Patterns' creates subroutines for patterned operations.",
Expand All @@ -298,7 +297,7 @@ properties = {
group: 3,
value: "allOperations",
scope: "post"
},
},/*
writeMachine: {
title: "Write machine",
description: "Output the machine settings in the header of the code.",
Expand Down Expand Up @@ -400,15 +399,12 @@ properties = {
type: "boolean",
value: true,
scope: "post"
}
}*/
};
*/

staticProperties = {
machineModel: "none",
safePositionMethod: "G53",
hasAAxis: "reversed",
hasBAxis: "false",
hasCAxis: "true",
useDPMFeeds: false,
useTCPC: true,
useDWO: true,
Expand All @@ -427,9 +423,9 @@ staticProperties = {
forceHomeOnIndexing: true,
toolBreakageTolerance: 0.1,
fastToolChange: false,
useG95forTapping: false,
useG95forTapping: true,
safeRetractDistance: 0,
useSubroutines: "allOperations", //allOperations
//useSubroutines: "allOperations",
writeMachine: false,
writeTools: true,
writeVersion: false,
Expand All @@ -442,7 +438,6 @@ staticProperties = {
useM130ToolImages: false,
coolantPressure: "",
singleResultsFile: true,
pencilWCSVerif: true
};

const HAAS_DRILL = 1;
Expand Down Expand Up @@ -595,8 +590,8 @@ function writeBlock() {
if (!text) {
return;
}
var maximumSequenceNumber = ((staticProperties.useSubroutines == "allOperations") || (staticProperties.useSubroutines == "patterns") ||
(staticProperties.useSubroutines == "cycles")) ? initialSubprogramNumber : 99999;
var maximumSequenceNumber = ((getProperty("useSubroutines") == "allOperations") || (getProperty("useSubroutines") == "patterns") ||
(getProperty("useSubroutines") == "cycles")) ? initialSubprogramNumber : 99999;
if (staticProperties.showSequenceNumbers) {
if (sequenceNumber >= maximumSequenceNumber) {
sequenceNumber = staticProperties.sequenceNumberStart;
Expand Down Expand Up @@ -877,7 +872,7 @@ function setMacro(macro, value, comment) {
}

function defineMachineModel() {
var useTCPC = staticProperties.useTCPC;
var useTCPC = getProperty("useTCPC");
switch (staticProperties.machineModel) {
case "umc-500":
var axis1 = createAxis({coordinate:1, table:true, axis:[0, 1, 0], range:[-35, 120], preference:1, tcp:useTCPC});
Expand Down Expand Up @@ -1014,9 +1009,9 @@ function setFeedrateMode(reset) {
}

function defineMachine() {
hasA = staticProperties.hasAAxis != "false";
hasB = staticProperties.hasBAxis != "false";
hasC = staticProperties.hasCAxis != "false";
hasA = getProperty("hasAAxis") != "false";
hasB = getProperty("hasBAxis") != "false";
hasC = getProperty("hasCAxis") != "false";
if (hasA && hasB && hasC) {
error(localize("Only two rotary axes can be active at the same time."));
Expand All @@ -1033,9 +1028,9 @@ function defineMachine() {
var aAxis;
var bAxis;
var cAxis;
var useTCPC = staticProperties.useTCPC;
var useTCPC = getProperty("useTCPC");
if (hasA) { // A Axis - For horizontal machines and trunnions
var dir = staticProperties.hasAAxis == "reversed" ? -1 : 1;
var dir = getProperty("hasAAxis") == "reversed" ? -1 : 1;
if (hasC || hasB) {
var aMin = (dir == 1) ? -120 - 0.0001 : -30 - 0.0001;
var aMax = (dir == 1) ? 30 + 0.0001 : 120 + 0.0001;
Expand All @@ -1046,7 +1041,7 @@ function defineMachine() {
}

if (hasB) { // B Axis - For horizontal machines and trunnions
var dir = staticProperties.hasBAxis == "reversed" ? -1 : 1;
var dir = getProperty("hasBAxis") == "reversed" ? -1 : 1;
if (hasC) {
var bMin = (dir == 1) ? -120 - 0.0001 : -30 - 0.0001;
var bMax = (dir == 1) ? 30 + 0.0001 : 120 + 0.0001;
Expand All @@ -1059,7 +1054,7 @@ function defineMachine() {
}

if (hasC) { // C Axis - For trunnions only
var dir = staticProperties.hasCAxis == "reversed" ? -1 : 1;
var dir = getProperty("hasCAxis") == "reversed" ? -1 : 1;
cAxis = createAxis({coordinate:2, table:true, axis:[0, 0, dir], cyclic:true, reset:1, tcp:useTCPC});
}

Expand Down Expand Up @@ -1097,9 +1092,9 @@ function onOpen() {
((machineConfiguration.getDescription() != "") || machineConfiguration.isMultiAxisConfiguration());
// removed hardcoded machine configs to allow for simulation
/*if (typeof defineMachine == "function") {
if (typeof defineMachine == "function") {
defineMachine(); // hardcoded machine configuration
}*/
}
activateMachine(); // enable the machine optimizations and settings

if (staticProperties.useDPMFeeds) {
Expand Down Expand Up @@ -1151,7 +1146,7 @@ function onOpen() {
return;
}

writeWords(writeComment(getGlobalParameter("username")), writeComment(getGlobalParameter("generated-at")));
writeWords(writeComment(getGlobalParameter("username") + ": " + getGlobalParameter("document-path")), writeComment(getGlobalParameter("generated-at")));

if (staticProperties.useG0) {
writeComment(localize("Using G0 which travels along dogleg path."));
Expand Down Expand Up @@ -1930,7 +1925,7 @@ function subprogramDefine(_initialPosition, _abc, _retracted, _zIsOutput) {
// convert patterns into subprograms
var usePattern = false;
patternIsActive = false;
if (currentSection.isPatterned && currentSection.isPatterned() && (staticProperties.useSubroutines == "patterns")) {
if (currentSection.isPatterned && currentSection.isPatterned() && (getProperty("useSubroutines") == "patterns")) {
currentPattern = currentSection.getPatternId();
firstPattern = true;
for (var i = 0; i < definedPatterns.length; ++i) {
Expand Down Expand Up @@ -1978,7 +1973,7 @@ function subprogramDefine(_initialPosition, _abc, _retracted, _zIsOutput) {
}

// Output cycle operation as subprogram
if (!usePattern && (staticProperties.useSubroutines == "cycles") && currentSection.doesStrictCycle &&
if (!usePattern && (getProperty("useSubroutines") == "cycles") && currentSection.doesStrictCycle &&
(currentSection.getNumberOfCycles() == 1) && currentSection.getNumberOfCyclePoints() >= minimumCyclePoints) {
var finalPosition = getFramePosition(currentSection.getFinalPosition());
currentPattern = currentSection.getNumberOfCyclePoints();
Expand Down Expand Up @@ -2013,7 +2008,7 @@ function subprogramDefine(_initialPosition, _abc, _retracted, _zIsOutput) {
}

// Output each operation as a subprogram
if (!usePattern && (staticProperties.useSubroutines == "allOperations")) {
if (!usePattern && (getProperty("useSubroutines") == "allOperations")) {
currentSubprogram = ++lastSubprogram;
writeBlock(mFormat.format(97), "P" + nFormat.format(currentSubprogram));
firstPattern = true;
Expand Down Expand Up @@ -2154,7 +2149,7 @@ function onSection() {
// 07/06/21 | Gavin Williams | will1742
// 002 Improved Probing
// uses pencil to verify WCS, prompts user
if (isFirstSection() && staticProperties.pencilWCSVerif) {
if (isFirstSection() && getProperty("pencilWCSValidation")) {
var stockMidX = (stockUpperX + stockLowerX)/2;
var stockMidY = (stockUpperY + stockLowerY)/2;
writeln("");
Expand All @@ -2168,7 +2163,6 @@ function onSection() {
var gotoRef = takeInput("Is the graphite probing device in the middle of the stock?", ['Y']);
writeWords("N" + nFormat.format(gotoRef['Y']), mFormat.format(131), formatComment("End Multimedia"));
// TODO fix work offset for pencil on Z approach
writeBlock(gFormat.format(55), gFormat.format(43), hFormat.format(19), zOutput.format(stockTopZ));
displayMedia("Net Share/Media/zWCSCheck.png");
writeBlock(mFormat.format(0), formatComment("Open door"));
Expand Down Expand Up @@ -2581,40 +2575,45 @@ function onSection() {
}
}

writeComment("BEGIN VALIDATION SECTION");
// Added 06/15/21 | Gavin Williams | will1742
// Verifies tool-stock distance. Post fails if tool fails clearance standards
if (toolDistance < 1) {
throw "Error: Clearance height must be greater than 1 inch from stock";
}
if (getProperty("toolHeightValidation")) {
writeComment("BEGIN VALIDATION SECTION");
// Added 06/15/21 | Gavin Williams | will1742
// Verifies tool-stock distance. Post fails if tool fails clearance standards
if (toolDistance < 1) {
throw "Error: Clearance height must be greater than 1 inch from stock";
}

if (toolDistance == Infinity) {
throw "Error: invalid tool distance. Contact a TA.";
}
var toolDistance = initialPosition.z - stockTopZ;
if (toolDistance == Infinity) {
throw "Error: invalid tool distance. Contact a TA.";
}
var toolDistance = initialPosition.z - stockTopZ;

// Prompt user to check stock-tool distance
displayMedia("Net Share/Media/checkDistance.png");
writeBlock(mFormat.format(0), formatComment("Open door"));
displayMedia("Net Share/Media/arrowDown.png");

// Prompt user to check stock-tool distance
displayMedia("Net Share/Media/checkDistance.png");
writeBlock(mFormat.format(0), formatComment("Open door"));
displayMedia("Net Share/Media/arrowDown.png");
// asks user if measured height is accurate to displayed
var gotoRef = takeInput(("Is the tool " + toolDistance.toPrecision(3) + "in from the stock? [Y/N]"), ['N', 'Y']);

// asks user if measured height is accurate to displayed
var gotoRef = takeInput(("Is the tool " + toolDistance.toPrecision(3) + "in from the stock? [Y/N]"), ['N', 'Y']);
// Create GOTO cases for Y/N selection, halt if N
getTA("Net Share/Media/TAWarning.png", gotoRef['N'], onSecGotoRef);
writeWords("N" + nFormat.format(gotoRef['Y']), mFormat.format(131), formatComment("End Multimedia"));
writeWords(
conditional(!currentSection.isMultiAxis() || !tcpIsSupported, gFormat.format(43)),
conditional(currentSection.isMultiAxis() && tcpIsSupported, gFormat.format(234)),
zOutput.format(initialPosition.z),
hFormat.format(lengthOffset)
);
writeComment("END VALIDATION SECTION");

// Create GOTO cases for Y/N selection, halt if N
getTA("Net Share/Media/TAWarning.png", gotoRef['N'], onSecGotoRef);
writeWords("N" + nFormat.format(gotoRef['Y']), mFormat.format(131), formatComment("End Multimedia"));
writeWords(
conditional(!currentSection.isMultiAxis() || !tcpIsSupported, gFormat.format(43)),
conditional(currentSection.isMultiAxis() && tcpIsSupported, gFormat.format(234)),
zOutput.format(initialPosition.z),
hFormat.format(lengthOffset)
);
writeComment("END VALIDATION SECTION");
// initialize spindle and engage coolant if heights are correct
if (tool.type != TOOL_PROBE) {
writeBlock(mFormat.format((tool.clockwise ? 3 : 4)), formatComment("Restart spindle"));
}
}

// initialize spindle and engage coolant if heights are correct
if (tool.type != TOOL_PROBE) {
writeBlock(mFormat.format((tool.clockwise ? 3 : 4)), formatComment("Restart spindle"));
setCoolant(tool.coolant);
}

Expand Down Expand Up @@ -4412,6 +4411,7 @@ longDescription = "Generic post for the HAAS Next Generation control with inspec

var controlType = "NGC"; // Specifies the control model "NGC" or "Classic"
// >>>>> INCLUDED FROM ../common/haas base inspection.cps
/*
properties.probeLocalVar = {
title: "Local variable start",
description: "Specify the starting value for macro # variables that are to be used for calculations during inspection paths.",
Expand Down Expand Up @@ -4536,6 +4536,23 @@ properties.calibrationNCOutput = {
],
value: "none",
scope: "post"
};*/
properties.toolHeightValidation = {
title: "Tool Length Validation",
description: "Length validation. By turning this off, you accept responsibility for any resulting crashes.",
group: 99,
type: "boolean",
value: true,
scope: "post"
};

properties.pencilWCSValidation = {
title: "WCS Validation",
description: "WCS validation. By turning this off, you accept responsibility for any resulting crashes.",
group: 99,
type: "boolean",
value: true,
scope: "post"
};

var ijkFormat = createFormat({decimals:5, forceDecimal:true});
Expand Down

0 comments on commit ee851e2

Please sign in to comment.