Community
HSM Post Processor Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Move Subprogram from onClose to onOpen

1 REPLY 1
Reply
Message 1 of 2
davidewingJ9PZ3
70 Views, 1 Reply

Move Subprogram from onClose to onOpen

I have an old controller which requires the subprograms at the beginning of the program

(it defines them at the beginning, then calls them throughout the program)

 

if i move the section of code in post processor from 'onClose' to 'onOpen' it does not post anything out.
I am using the fanuc post processor, but noticed the siemens is the same.

 

Hopefully someone knows of a quick solution.

1 REPLY 1
Message 2 of 2

What you are asking is doable, it will take some careful placement of opening, closing, and writing of the redirect buffer.  Take care when editing the post to place the added lines in the correct locations.

 

First, add the following 2 variables at the top of the post.

probeMultipleFeatures = true;
var redirectToMain = false; // <<< Add this line
var mainProgram = ""; // <<< Add this line

 

The following lines need to be added to the onOpen function in the places as shown.

function onOpen() {
  redirectToBuffer(); // <<< Add this line
...
  validateCommonParameters();

  mainProgram += getRedirectionBuffer(); // <<< Add this line
  closeRedirection(); // <<< Add this line
}

 

In the onSection function add the following lines.

function onSection() {
  redirectToBuffer(); // <<< Add this line
...
  mainProgram += getRedirectionBuffer(); // <<< Add this line
  closeRedirection(); // <<< Add this line

  if (subprogramsAreSupported()) {
    subprogramDefine(initialPosition, abc); // define subprogram
  }
  if (!isRedirecting()) { // <<< Add this entire IF-block
    redirectToBuffer();
    redirectToMain = true;
  }
}

 

Add the following IF-block to onSectionEnd.

  if (redirectToMain) { // <<< Add this IF-block
    mainProgram += getRedirectionBuffer();
    closeRedirection();
    redirectToMain = false;
  }

  if (subprogramsAreSupported()) {
    subprogramEnd();
  }

 

In onClose add the following lines.

function onClose() {
  if (subprogramsAreSupported()) { // <<< Add these lines
    writeSubprograms();
  }
  if (mainProgram) {
    write(mainProgram);
  }

 

And comment out the following lines further down in onClose.

  // if (subprogramsAreSupported()) { // <<< Comment out this IF-block
  //   writeSubprograms();
  // }
  writeln("%");
}

 

Modify the following line in subprogramEnd.

/** End of subprogram and close redirection. */
function subprogramEnd() {
  if (isRedirecting() && !redirectToMain) { // <<< Add " && !redirectToMain"

 

And finally, in the subprogramDefine function, add the following lines.

    if (subprogramDefinition.isValid) {
      redirectToBuffer(); // <<< Add this line
      // make sure Z-position is output prior to subprogram call
      var z = zOutput.format(_initialPosition.z);
      if (!state.retractedZ && z) {
        validate(!validateLengthCompensation || state.lengthCompensationActive, "Tool length compensation is not active."); // make sure that length compensation is enabled
        var block = "";
        if (typeof gAbsIncModal != "undefined") {
          block += gAbsIncModal.format(90);
        }
        if (typeof gPlaneModal != "undefined") {
          block += gPlaneModal.format(17);
        }
        writeBlock(block);
        zOutput.reset();
        invokeOnRapid(xOutput.getCurrent(), yOutput.getCurrent(), _initialPosition.z);
      }

      // call subprogram
      subprogramCall();
      mainProgram += getRedirectionBuffer(); // <<< Add this line
      closeRedirection(); // Add this line
      subprogramState.patternIsActive = true;

 

 



Bob Schultz
Sr. Post Processor Developer

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report