Skip to content

Commit

Permalink
Refactored to Reflect Updated NGC
Browse files Browse the repository at this point in the history
  • Loading branch information
will1742 committed Jul 7, 2021
1 parent 87bb943 commit 21d17f9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

Old/haas next generation.cps
*.nc
Haas_Next_Generation/haas next*
44 changes: 22 additions & 22 deletions Haas_Next_Generation/haas vf2.cps
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,9 @@ properties = {
staticProperties = {
machineModel: "none",
safePositionMethod: "G53",
hasAAxis: "false",
hasAAxis: "reversed",
hasBAxis: "false",
hasCAxis: "false",
hasCAxis: "true",
useDPMFeeds: false,
useTCPC: true,
useDWO: true,
Expand Down Expand Up @@ -651,7 +651,6 @@ function writeComment(text) {
/**
Returns the matching HAAS tool type for the tool.
*/

function getHaasToolType(toolType) {
switch (toolType) {
case TOOL_DRILL:
Expand Down Expand Up @@ -852,7 +851,6 @@ function writeToolMeasureBlock(tool, preMeasure) {
);
} else { // use Macro P9995 to measure tools
// writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool
// TODO: fix tool type
setMacro(1600 + tool.number, tool.numberOfFlutes, "Number of Flutes");
writeFunction(
gFormat.format(65),
Expand Down Expand Up @@ -967,7 +965,7 @@ function activateMachine() {
}

// retract/reconfigure
safeRetractDistance = staticProperties.singleResultsFile != undefined ? staticProperties.singleResultsFile :
safeRetractDistance = staticProperties.safeRetractDistance != undefined ? staticProperties.safeRetractDistance :
(typeof safeRetractDistance == "number" ? safeRetractDistance : 0);
if (machineConfiguration.performRewinds() || (typeof performRewinds == "undefined" ? false : performRewinds)) {
machineConfiguration.enableMachineRewinds(); // enables the rewind/reconfigure logic
Expand All @@ -991,11 +989,11 @@ function activateMachine() {
var section = getSection(i);
if (section.isMultiAxis()) {
machineConfiguration.setToolLength(section.getTool().getBodyLength()); // define the tool length for head adjustments
section.optimizeMachineAnglesByMachine(machineConfiguration, OPTIMIZE_AXIS);
section.optimizeMachineAnglesByMachine(machineConfiguration, tcpIsSupported ? 0 : 1);
}
}
} else {
optimizeMachineAngles2(OPTIMIZE_AXIS);
optimizeMachineAngles2(tcpIsSupported ? 0 : 1);
}
}

Expand Down Expand Up @@ -1125,9 +1123,10 @@ function onOpen() {
if (!staticProperties.separateWordsWithSpace) {
setWordSeparator("");
}
saveshowSequenceNumbers = staticProperties.showSequenceNumbers;
saveShowSequenceNumbers = staticProperties.showSequenceNumbers;
sequenceNumber = staticProperties.sequenceNumberStart;
writeln("%");

if (programName) {
var programId;
try {
Expand Down Expand Up @@ -2046,7 +2045,7 @@ function subprogramEnd() {
}
forceAny();
firstPattern = false;
staticProperties.showSequenceNumbers = saveshowSequenceNumbers;
staticProperties.showSequenceNumbers = saveShowSequenceNumbers;
closeRedirection();
}

Expand Down Expand Up @@ -2484,10 +2483,9 @@ function onSection() {
// writeComment("PREPOSITIONING END");
skipBlock = _skipBlock;
writeBlock(
gMotionModal.format(G),
conditional(!currentSection.isMultiAxis() || !tcpIsSupported, gFormat.format(43)),
conditional(currentSection.isMultiAxis() && tcpIsSupported, gFormat.format(234)),
xOutput.format(initialPosition.x), yOutput.format(initialPosition.y), zOutput.format(initialPosition.z), F,
gMotionModal.format(0), // G0 motion mode is required for the G234 command
gFormat.format(234),
xOutput.format(initialPosition.x), yOutput.format(initialPosition.y), zOutput.format(initialPosition.z),
hFormat.format(lengthOffset)
);
} else {
Expand All @@ -2506,7 +2504,7 @@ function onSection() {
skipBlock = _skipBlock;
writeBlock(
gAbsIncModal.format(90),
gMotionModal.format(G),
gMotionModal.format(currentSection.isMultiAxis() && tcpIsSupported ? 0 : G),
conditional(!currentSection.isMultiAxis() || !tcpIsSupported, gFormat.format(43)),
conditional(currentSection.isMultiAxis() && tcpIsSupported, gFormat.format(234)),
xOutput.format(initialPosition.x),
Expand All @@ -2529,7 +2527,9 @@ function onSection() {
writeBlock(gAbsIncModal.format(90), gMotionModal.format(0), x, y);
}
}

if (gMotionModal.getCurrent() == 0) {
forceFeed();
}
gMotionModal.reset();
} else {
validate(lengthCompensationActive, "Length compensation is not active.");
Expand Down Expand Up @@ -3524,7 +3524,6 @@ function onRadiusCompensation() {
pendingRadiusCompensation = radiusCompensation;
}

var forceG0 = false;
function onRapid(_x, _y, _z) {
var x = xOutput.format(_x);
var y = yOutput.format(_y);
Expand All @@ -3534,14 +3533,13 @@ function onRapid(_x, _y, _z) {
error(localize("Radius compensation mode cannot be changed at rapid traversal."));
return;
}
if (!staticProperties.useG0 && !forceG0 && (((x ? 1 : 0) + (y ? 1 : 0) + (z ? 1 : 0)) > 1)) {
if (!staticProperties.useG0 && (((x ? 1 : 0) + (y ? 1 : 0) + (z ? 1 : 0)) > 1)) {
// axes are not synchronized
writeBlock(gFeedModeModal.format(94), gMotionModal.format(1), x, y, z, getFeed(toPreciseUnit(highFeedrate, MM)));
} else {
writeBlock(gMotionModal.format(0), x, y, z);
forceFeed();
}
forceG0 = false;
}
}

Expand Down Expand Up @@ -3587,6 +3585,7 @@ function onLinear(_x, _y, _z, feed) {
}
}

var forceG0 = false;
function onRapid5D(_x, _y, _z, _a, _b, _c) {
if (!currentSection.isOptimizedForMachine()) {
error(localize("This post configuration has not been customized for 5-axis simultaneous toolpath."));
Expand All @@ -3605,7 +3604,8 @@ function onRapid5D(_x, _y, _z, _a, _b, _c) {
((bOutput.isEnabled() && abcFormat.areDifferent(_b, bOutput.getCurrent())) ? 1 : 0) +
((cOutput.isEnabled() && abcFormat.areDifferent(_c, cOutput.getCurrent())) ? 1 : 0);
if (!staticProperties.useG0 && !forceG0 && (tcpIsSupported || (num > 1))) {
invokeOnLinear5D(_x, _y, _z, _a, _b, _c, toPreciseUnit(highFeedrate, MM)); // onLinear5D handles inverse time feedrates
invokeOnLinear5D(_x, _y, _z, _a, _b, _c, highFeedrate); // onLinear5D handles inverse time feedrates
forceG0 = false;
return;
}

Expand Down Expand Up @@ -3707,7 +3707,8 @@ function onRotateAxes(_x, _y, _z, _a, _b, _c) {
function onReturnFromSafeRetractPosition(_x, _y, _z) {
// reinstate TCP
if (tcpIsSupported) {
writeBlock(gFormat.format(234), hFormat.format(tool.lengthOffset), formatComment("TCPC ON"));
writeBlock(gMotionModal.format(0), gFormat.format(234), hFormat.format(tool.lengthOffset), formatComment("TCPC ON"));
forceFeed();
lengthCompensationActive = true;
}

Expand All @@ -3716,7 +3717,6 @@ function onReturnFromSafeRetractPosition(_x, _y, _z) {
xOutput.reset();
yOutput.reset();
zOutput.disable();
forceG0 = true;
invokeOnRapid(_x, _y, _z);

// position in Z
Expand Down Expand Up @@ -5045,7 +5045,7 @@ function forceSequenceNumbers(force) {
if (force) {
staticProperties.showSequenceNumbers = true;
} else {
staticProperties.showSequenceNumbers = saveshowSequenceNumbers;
staticProperties.showSequenceNumbers = saveShowSequenceNumbers;
}
}

Expand Down

0 comments on commit 21d17f9

Please sign in to comment.