// // Activity -- state of processing within an action plan // @deftype Activity <DefinedObject, Drop> - run; - next; - step; - stepEntry; - stepExit; - (void) stop; - (void) terminate; - getStatus; - getHoldType; - getRunContext; - (void) setOwnerActivity: anActivity; // unimplemented - getOwnerActivity; - getSubactivities; - getHoldingActions; // unimplemented - getReleasedActions; // unimplemented - setSerialMode: (BOOL)serialMode; - (BOOL) getSerialMode; - getCurrentAction; // serial mode only - getCurrentSubactivity; // serial mode only @end
The Activity types are part of the virtual processing machinery of an action plan interpreter. All the important elements of this machinery, including their current state of processing, are exposed to aid in development of general-purpose tools such as debuggers. Except for applications that need to create and run their own reflective activities, direct use of activity types by a modeling application should be rare.
An new activity object is created by each activateIn: message sent to an action plan. activateIn: initializes a new activity object and prepares it for processing, but does not itself execute any actions. Subsequent messages, such as run, must be used to initiate processing within an activity. If an activity is activated to run under a swarm context, the owning swarm itself controls all processing within the subactivity.
An Activity type holds a tree of currently running, or a potentially runnable, subactivities. Each activity object represents a state of processing within a single action plan. The structure is a tree because multiple activities could be running or eligible to run at the same time. This occurs whenever two activities are specified as concurrent, either because are being performed by concurrent actions in some other plan, or because they were started for autonomous execution under the same swarm. When parallel processing machinery is present, each activity could also be advancing its own state independent of those of any other activity.
The current implementation supports only a single serial processor. Under serial execution, only one activity may be active at one time. This means that the current state of processing may be represented by a single stack of current activities that traces a path to a single leaf of the runnable activity tree. When running in serial mode, messages are available to obtain the currently running leaf activity or useful context information such as the current time available from it.
- run;The run message continue processing of an activity from any state in which its execution has been suspended. An error is raised if the activity is already running. run returns either a Stopped or Completed status that the activity has when it is no longer eligible to be run further.
- step; - stepEntry; - stepExit; - next;The step message executes a single action within a tree of activities. The stepEntry message executes multiple actions within a single currently runnable activity, but stops the activity when a new level of action plan has just been started within the tree of activities. stepExit executes multiple actions in the same action plan until the activity for that action plan has completed, or cannot otherwise be run further. next executes actions within a single action plan while skipping over all processing of any complete action plans executed by those actions. (.. Currently, stepEntry and stepExit are unimplemented.)
- (void) stop; - (void) terminate;The stop message causes the a currently running tree of activities to stop further processing and return a Stopped status. terminate also stops a running tree of activities, but sets all activities within the tree to a status of Completed whenever the tree is next run. terminate may be used on either a running or stopped tree of activities. It is the standard way to terminate schedule that is endlessly repeating under the RepeatInterval option.
- getStatus; - getHoldType;The getStatus message returns one of the following codes for the current run status of a particular activity:
extern id <Symbol> Initialized, Running, Stopped, Holding, Released, Terminated, Completed;The getHoldType returns a code for the particular hold constraint under which an activity is currently holding. It returns nil if the basic status of the activity is not Holding. (.. Currently no hold constraints other than merging within a swarm are supported, and this message always returns nil.)
extern id <Symbol> HoldStart, HoldEnd;
#define getCurrentActivity() #define getCurrentAction() #define getCurrentTime() #define getCurrentScheduleActivity() #define getCurrentSchedule() #define getCurrentSwarmActivity() #define getCurrentSwarm() #define getCurrentSwarmActivity() #define getTopLevelActivity()
(.. Only a synopsis of Activity subtypes is provided here for now. Note, however that access to a current time is available from a schedule or swarm activity, along with the ability to run a schedule until a particular time value is first reached.)
// // GroupActivity -- state of processing within an ActionGroup // @deftype GroupActivity <Activity> @end
// // ForEachActivity -- state of execution within a ForEach action // @deftype ForEachActivity- getCurrentMember; @end
// // ScheduleActivity -- state of execution within a Schedule // @deftype ScheduleActivity- (timeval_t) getCurrentTime; - stepUntil: (timeval_t)tVal; // unimplemented @end
// // SwarmActivity -- a collection of started subactivities // @deftype SwarmActivity@end