public class CIDirector extends Director
When a relation connects the push(pull) output port of one actor with the push(pull) input port of another, the style of interaction between the two actors is push(pull). To configure a port as a push port, add a parameter named push to the port, and give the value "true" to the parameter. Ports are pull ports by default. Relations connecting both push and pull ports are not supported. (TODO: add check in the director.)
Actors in a CI model are classified as either active or inactive. Each
active actor is controlled by an actor manager
,
which runs asynchronously with respect to the director (i.e. not in the
same thread of control). Active actors include:
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected long |
_interval
The default interval between iterations of active actors.
|
protected boolean |
_pauseRequested
If true, pause the execution of the model.
|
_actorsFinishedExecution, _aspectForActor, _aspectsPresent, _defaultMicrostep, _executionAspects, _finishRequested, _initializables, _nextScheduleTime, _stopRequested, _tokenSentToCommunicationAspect, _zeroTime, localClock, startTime, stopTime
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
CIDirector()
Construct a director in the default workspace with an empty string
as its name.
|
CIDirector(CompositeEntity container,
java.lang.String name)
Construct a director in the given container with the given name.
|
CIDirector(Workspace workspace)
Construct a director in the workspace with an empty name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_actorEnabled(Actor actor)
Schedule the pulled inactive actor to fire.
|
protected void |
_addActorManager(ActiveActorManager actorManager)
Add the actor manager to the set of active actor managers.
|
protected void |
_addAsyncPushedActor(Actor actor)
Add the given actor to the list of actors that received pushed
data from active actors.
|
protected void |
_addSyncPushedActor(Actor actor)
Add the given actor to the list of synchronously pushed actors.
|
protected static boolean |
_isActive(Actor actor)
Return true if the actor is active, such as: source with push
output; sink with pull input; actor with pull input and push
output.
|
protected boolean |
_isPulled(Actor actor)
Return true if the given actor has a pending pull request.
|
protected static boolean |
_isPushPort(IOPort port)
Return true if the port is a push port, that is a port having a
parameter named push with boolean value true.
|
protected boolean |
_isStopRequested()
Return true if this director is requested to stop.
|
protected void |
_removeActorManager(ActiveActorManager actorManager)
Remove the actor manager from the set of active actor managers.
|
protected void |
_requestAsyncPull(Actor actor)
Handle the pull request from the given active actor.
|
protected void |
_requestSyncPull(Actor actor)
Record the given actor as being pulled, and recursively propagate
the pull request to those actors providing data to it.
|
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace.
|
void |
fire()
Check whether there is an actor pushed or pulled by an active
actor.
|
void |
initialize()
Initialize the model controlled by this director.
|
Receiver |
newReceiver()
Return a new receiver of type CIReceiver.
|
boolean |
postfire()
Return false if all active actors have finished execution and
there is no pushed data or pull request to be processed;
otherwise, return true.
|
boolean |
prefire()
If this director is at the top level of the model or there is pushed
data or pull request to be processed, return true; otherwise, return
false.
|
void |
preinitialize()
Validate the attributes and then invoke the preinitialize()
methods of all its deeply contained actors.
|
void |
stop()
Request that the director cease execution altogether.
|
void |
stopFire()
Request that execution of the current iteration stop.
|
void |
terminate()
Terminate any currently executing model with extreme prejudice.
|
void |
wrapup()
Invoke the wrapup() method of all the actors contained in the
director's container.
|
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _schedule, _transferInputs, _transferOutputs, addInitializable, attributeChanged, createSchedule, defaultDependency, delayDependency, elapsedTimeSinceStart, finish, fireAt, fireAt, fireAt, fireAtCurrentTime, fireContainerAt, fireContainerAt, getCausalityInterface, getCurrentTime, getDeadline, getEnvironmentTime, getExecutionAspect, getGlobalTime, getModelNextIterationTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, initialize, invalidateResolvedTypes, invalidateSchedule, isEmbedded, isFireFunctional, isStopRequested, isStrict, iterate, mutexLockObject, notifyTokenSentToCommunicationAspect, preinitialize, removeInitializable, requestInitialization, resume, resumeActor, scheduleContainedActors, setContainer, setCurrentTime, setEmbedded, setModelTime, setTimeResolution, suggestedModalModelDirectors, supportMultirateFiring, suspend, transferInputs, transferOutputs, transferOutputs
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
protected boolean _pauseRequested
protected long _interval
public CIDirector() throws IllegalActionException, NameDuplicationException
NameDuplicationException
- If construction of Time objects fails.IllegalActionException
- If construction of Time objects fails.public CIDirector(Workspace workspace) throws IllegalActionException, NameDuplicationException
workspace
- The workspace of this director.NameDuplicationException
- If construction of Time objects fails.IllegalActionException
- If construction of Time objects fails.public CIDirector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of this director.IllegalActionException
- If the name has a period in it, or
the director is not compatible with the specified container.NameDuplicationException
- If the container already contains
an attribute with the specified name.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class Director
workspace
- The workspace for the cloned object.java.lang.CloneNotSupportedException
- Not thrown in this base classNamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void fire() throws IllegalActionException
If this director is not at the top level of the model, return after completing the data-driven computation for a pushed actor or propagating the pull request for a pulled actor; otherwise, wait until active actors produce pushed data or pull requests.
This method is not synchronized on the workspace, so the caller should be.
fire
in interface Executable
fire
in class Director
IllegalActionException
- If any called method of one
of the associated actors throws it.public void initialize() throws IllegalActionException
This method is not synchronized on the workspace, so the caller should be.
initialize
in interface Initializable
initialize
in class Director
IllegalActionException
- If the initialize() method of
one of the associated actors throws it.public Receiver newReceiver()
newReceiver
in class Director
public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class Director
IllegalActionException
- Not thrown in this base class.public boolean prefire() throws IllegalActionException
prefire
in interface Executable
prefire
in class Director
IllegalActionException
- Not thrown in this base class.public void preinitialize() throws IllegalActionException
This method is not synchronized on the workspace, so the caller should be.
preinitialize
in interface Initializable
preinitialize
in class Director
IllegalActionException
- If the preinitialize() method of
one of the associated actors throws it.public void stop()
stop
in interface Executable
stop
in class Director
public void stopFire()
stopFire
in interface Executable
stopFire
in class Director
public void terminate()
Calls terminate() on all actors contained by the container of this director. Set the _stopRequested flag to be true, and interrupt the actor manager threads.
terminate
in interface Executable
terminate
in class Director
public void wrapup() throws IllegalActionException
wrapup
in interface Initializable
wrapup
in class Director
IllegalActionException
- If the wrapup() method of
one of the associated actors throws it.protected void _actorEnabled(Actor actor)
actor
- The pulled actor that is ready to fire.protected void _addActorManager(ActiveActorManager actorManager)
actorManager
- An active actor manager.protected void _addAsyncPushedActor(Actor actor)
actor
- The actor that received pushed data from an active
actor.protected void _addSyncPushedActor(Actor actor)
actor
- The actor that received synchronously pushed data.protected static boolean _isActive(Actor actor) throws IllegalActionException
actor
- The actor to be tested whether it is active.IllegalActionException
protected boolean _isPulled(Actor actor)
actor
- The actor to test.protected static boolean _isPushPort(IOPort port)
port
- The port to test.protected boolean _isStopRequested()
protected void _removeActorManager(ActiveActorManager actorManager)
actorManager
- An active actor manager.protected void _requestAsyncPull(Actor actor)
actor
- The active actor with pull request.protected void _requestSyncPull(Actor actor) throws IllegalActionException
actor
- The actor being pulled.IllegalActionException
- If calling prefire() on an actor
in that provides data to the actor being pulled throws it