Begin/End Events for Process Elements

The code below assumes that a STEP-NC file is in memory and annotated with ARM objects as described in the Getting Started instructions.

The example below uses a cursor to print a log of just the workplans and operations in a file. It uses setWantedAll() to clear any prior event setting, then calls setWanted() three times to request that the cursor stop at the start and end of workplans and at the start of each operation.

The body of the loop prints different messages based on the event that was seen. It prints the object identifiers for the active workplan and active operation. An operation is always owned by an executable, so we ask for that as well.

RoseDesign * design;
StixCtlCursor p;

p.startProject(design);
p.setWantedAll(0); // clear any default events
p.setWanted(STIXCTL_EXEC_WORKPLAN_START);
p.setWanted(STIXCTL_EXEC_WORKPLAN_END);
p.setWanted(STIXCTL_OPERATION_START);

while (p.next())
{
    switch (p.event()) {
    case STIXCTL_EXEC_WORKPLAN_START:
        printf ("STARTING WORKPLAN #%lu [%s]\n",
                p.getActiveWorkplan()->entity_id(),
                p.getActiveWorkplan()->name());
        break;
                    
    case STIXCTL_EXEC_WORKPLAN_END:
        printf ("ENDING WORKPLAN #%lu\n",
                p.getActiveWorkplan()->entity_id());
        break;

    case STIXCTL_OPERATION_START: 
        printf ("STARTING OPERATION #%lu (workstep #%lu) [%s]\n",
                p.getActiveOperation()->entity_id(),
                p.getActiveExec()->entity_id(),
                p.getActiveOperation()->name());
        break;

    default: 
        printf ("UNEXPECTED EVENT\n");
        break;
    }
}

When run on a file with some nested workplans containing probing operations, it produces the following output.

STARTING WORKPLAN #7598 [main workplan]
STARTING WORKPLAN #7614 [Top]
STARTING OPERATION #6093 (workstep #4241) [Plane probe 0, 2 WS 2]
STARTING OPERATION #6115 (workstep #4259) [Plane probe 0, 3 WS 3]
STARTING OPERATION #6137 (workstep #4272) [Plane probe 0, 4 WS 4]
STARTING OPERATION #6159 (workstep #4285) [Plane probe 0, 5 WS 5]
STARTING OPERATION #6181 (workstep #4298) [Plane probe 0, 6 WS 6]
STARTING OPERATION #6203 (workstep #4311) [Plane probe 0, 7 WS 7]
STARTING OPERATION #6225 (workstep #4324) [Plane probe 9, 2 WS 30]
STARTING OPERATION #6247 (workstep #4337) [Plane probe 9, 3 WS 31]
STARTING OPERATION #6269 (workstep #4350) [Plane probe 9, 4 WS 32]
STARTING OPERATION #6291 (workstep #4363) [Plane probe 9, 5 WS 33]
STARTING OPERATION #6313 (workstep #4376) [Plane probe 9, 6 WS 34]
STARTING OPERATION #6335 (workstep #4389) [Plane probe 9, 7 WS 35]
ENDING WORKPLAN #7614
STARTING WORKPLAN #7631 [Plane 1]
STARTING OPERATION #6357 (workstep #4402) [Plane probe 0, 0 WS 1]
STARTING OPERATION #6380 (workstep #4420) [Plane probe 0, 1 WS 2]
STARTING OPERATION #6402 (workstep #4433) [Plane probe 1, 0 WS 3]
STARTING OPERATION #6424 (workstep #4446) [Plane probe 1, 1 WS 4]
STARTING OPERATION #6446 (workstep #4459) [Plane probe 2, 0 WS 5]
STARTING OPERATION #6468 (workstep #4472) [Plane probe 2, 1 WS 6]
ENDING WORKPLAN #7631

[ ... more probing workplans omitted ... ] 

ENDING WORKPLAN #7598