|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ptolemy.kernel.util.NamedObj ptolemy.kernel.util.Attribute ptolemy.actor.Director ptolemy.domains.ci.kernel.CIDirector
public class CIDirector
Director of the component interaction (CI) domain. The CI domain supports two styles of interaction between actors, push and pull. In push interaction, the actor that produces data initiates the interaction. The receiving actor reacts to the data. The computation proceeds as data-driven. In pull interaction, the actor that consumes data decides when the interaction takes place, and the computation proceeds as demand-driven.
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:
Red (liuxj) |
Yellow (liuxj) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj |
---|
NamedObj.ContainedObjectsIterator |
Field Summary | |
---|---|
private java.util.HashSet |
_actorManagers
|
private java.util.LinkedList |
_actorsToFire
|
private java.util.LinkedList |
_asyncPulledActors
|
private java.util.LinkedList |
_asyncPushedActors
|
protected long |
_interval
The default interval between iterations of active actors. |
private boolean |
_iteratingStarted
|
protected boolean |
_pauseRequested
If true, pause the execution of the model. |
private java.util.HashSet |
_pulledActors
|
Fields inherited from class ptolemy.actor.Director |
---|
_actorsFinishedExecution, _currentTime, _finishRequested, _initializables, _stopRequested, timeResolution |
Fields inherited from class ptolemy.kernel.util.NamedObj |
---|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Fields inherited from interface ptolemy.actor.Executable |
---|
COMPLETED, NOT_READY, STOP_ITERATING |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
private boolean |
_isPullThrough(Actor actor)
|
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. |
private Actor |
_nextAsyncPulledActor()
|
private Actor |
_nextAsyncPushedActor()
|
private java.util.List |
_providerActors(Actor actor)
|
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. |
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. |
Methods inherited from class ptolemy.kernel.util.Attribute |
---|
_checkContainer, _getContainedObject, _propagateExistence, clone, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected boolean _pauseRequested
protected long _interval
private java.util.HashSet _actorManagers
private java.util.LinkedList _asyncPushedActors
private java.util.LinkedList _asyncPulledActors
private java.util.LinkedList _actorsToFire
private java.util.HashSet _pulledActors
private boolean _iteratingStarted
Constructor Detail |
---|
public CIDirector()
public CIDirector(Workspace workspace)
workspace
- The workspace of this director.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.Method Detail |
---|
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 itprivate boolean _isPullThrough(Actor actor) throws IllegalActionException
IllegalActionException
private Actor _nextAsyncPulledActor()
private Actor _nextAsyncPushedActor()
private java.util.List _providerActors(Actor actor)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |