Overview

The StixCtlEvent enumeration describes each of the process conditions that can be returned by advancing a StixCtlCursor. The zero value indicates that the traversal is complete, and other values indicate a normal position change, the starting or ending of various process elements, or an error.

You can request that a cursor stop at particular events using the setWanted() function. The cursor next() function returns an event value. The event() function also returns the most recent event.

StixCtlEvent Definition

enum StixCtlEvent {
    STIXCTL_DONE = 0,
    STIXCTL_ERROR = 1,
    STIXCTL_MOVE = 2,
    STIXCTL_TOOL_CHANGE,
    STIXCTL_PROJECT_START,
    STIXCTL_PROJECT_END,
    STIXCTL_SETUP_START,
    STIXCTL_SETUP_END,
    STIXCTL_EXEC_WORKPLAN_START,
    STIXCTL_EXEC_WORKPLAN_NEXT,
    STIXCTL_EXEC_WORKPLAN_END,
    STIXCTL_EXEC_SELECT_START,
    STIXCTL_EXEC_SELECT_NEXT,
    STIXCTL_EXEC_SELECT_END,
    STIXCTL_EXEC_WORKSTEP_START,
    STIXCTL_EXEC_WORKSTEP_END,
    STIXCTL_EXEC_OTHER_START,
    STIXCTL_EXEC_OTHER_END,
    STIXCTL_EXEC_NCFUN,
    STIXCTL_OPERATION_START,
    STIXCTL_OPERATION_NEXTPATH,
    STIXCTL_OPERATION_END,
    STIXCTL_TOOLPATH_START,
    STIXCTL_TOOLPATH_END,
    STIXCTL_CURVE_START,
    STIXCTL_CURVE_END,
    STIXCTL_LAST_EVENT
};

Event Details

There are events for many different types of object. When next() returns an event, that particular type of object will be at the top of the process stack. The START/END events are returned before and after the contents of an object are processed.

By default, the cursor will only visit executables that are enabled, and at most one element of a selective. No START/END events are returned for the skipped items. Set the cursor to visit all execs if you need to see events for all items.

STIXCTL_DONE
Zero value that indicates that the cursor has finished traversing. This event is always generated.
STIXCTL_ERROR
Something has gone wrong and a description of the error is available in errorMsg(). The offending process element will be popped from the stack.
STIXCTL_MOVE
The tool position has changed. This event is the only one selected by default, and is returned for each waypoint on a toolpath. Check getActiveType() to see if the element on the top of the stack is a linear move, an arc move, or a helix move.
STIXCTL_TOOL_CHANGE
The tool has changed. This event is issued before the OPERATION_START event only when an operation requests a tool that is different from the last one seen. Call getActiveTool() for the new tool object.

The cursor may pass through workplans, functions, and other things that do not explicitly call for a tool, so the active tool is the last tool requested, even if the cursor is not currently in the middle of an operation.

If the tool changes as a result of the Load Tool or Unload Tool NC functions, the change event occurs after the EXEC_NCFUN event.

STIXCTL_PROJECT_START / END
Marks the beginning and completion of a STEP-NC project. A file may only contain one project. The project is assigned to the cursor with startProject() and is always available via the getActiveProject() function. Between these START and END events, the main workplan is pushed on the stack and processed.
STIXCTL_SETUP_START / END
Marks the beginning and completion of a setup. These events are only issued for a workplan that contains a setup description. The workplan is on the top of the stack and available via the getActiveWorkplan() function. These START and END events wrap the normal workplan start and end events described below.
STIXCTL_EXEC_WORKPLAN_START / END
Marks the beginning and completion of workplan processing. These events issued for every workplan. The workplan is on the top of the stack and available via the getActiveWorkplan() function. Between these START and END events, each element of the workplan is pushed on the stack and processed in sequential order.
STIXCTL_EXEC_WORKPLAN_NEXT
Marks the move to a body element in the workplan sequence. The new body element is on the top of the stack but has not been examined yet. The workplan is one stack frame above. The parameter value in the workplan stack frame holds the sequence number of the element. Popping the stack will skip the element.
STIXCTL_EXEC_SELECT_START / END
Marks the beginning and completion of a selective. The selective is on the top of the stack and available via the getActiveExec() function. Between these START and END events, one element of the selective is chosen an pushed on the stack to be processed. The cursor will choose the first enabled executable that it encounters. If the cursor is set to visit all execs, it will iterate over all elements and visit each.
STIXCTL_EXEC_SELECT_NEXT
Marks the move to a body element in the selective. The new body element is on the top of the stack but has not been examined yet. The selective is one stack frame above. The parameter value in the selective stack frame holds the sequence number of the element. Popping the stack will skip the element.
STIXCTL_EXEC_WORKSTEP_START / END
Marks the beginning and completion of workingstep processing. The workingstep is on the top of the stack and available via the getActiveWorkingstep() function. Between these START and END events, the operation of the workingstep is pushed on the stack and processed.
STIXCTL_EXEC_OTHER_START / END
Marks the beginning and completion of some other type of executable. The executable is on the top of the stack and available via the getActiveExec() function. Nothing is done by the cursor between the START and END events, but an application can use these to implement control flow for if/then, while loops, or parallel segments.
STIXCTL_EXEC_NCFUN
Marks the arrival at an NC function element. The NC Function is on the top of the stack and available via the getActiveExec() function. When a Load Tool or Unload Tool function is seen, the EXEC_NCFUN event will be followed by a TOOL_CHANGE event.
STIXCTL_OPERATION_START / END
Marks the beginning and completion of operation processing. The operation is on the top of the stack and available via the getActiveOperation() function. Between these START and END events, each toolpath associated with the operation is pushed on the stack and processed in sequential order.
STIXCTL_OPERATION_NEXTPATH
Marks the move to a new toolpath in the operation. The new body element is on the top of the stack but has not been examined yet. The operation is one stack frame above. The parameter value in the operation stack frame holds the sequence number of the toolpath. Popping the stack will skip the path.
STIXCTL_TOOLPATH_START / END
Marks the beginning and completion of an individual toolpath. The toolpath is on the top of the stack and available via the getActiveToolpath() function. Between these START and END events, the toolpath curve is pushed on the stack and processed.
STIXCTL_CURVE_START / END
Marks the beginning and completion of an individual toolpath curve. The stack frame on the top of the stack contains pointers to the separate curves for the toolpath basis (space curve), axis direction (tool axis), reference direction (x-axis for oriented non-rotating tools), surface normal, speed override ratio, and cross section parameters.

If the toolpath uses composite curves, the process stack may contain nested curves. The parameter value in the stack frame gives the location on the curve. Between these START and END events, the curve parameter is incremented over the full range of values and the matching position on the toolpath is pushed on the stack and processed to give STIXCTL_MOVE events.

STIXCTL_LAST_EVENT
Not an actual event. Marker testing whether a numeric value is in the range of known events.

Examples

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;
    }
}