|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.kernel.CompositeEntity
ptolemy.actor.CompositeActor
public class CompositeActor
A CompositeActor is an aggregation of actors. It may have a local director, which is an attribute of class Director that is responsible for executing the contained actors. At the top level of a hierarchy, a composite actor (the toplevel CompositeActor of the topology) will normally exist with a local Director, and no container. A composite actor at a lower level of the hierarchy may also have a local director. A composite actor with a local director is opaque, and serves the role of the wormhole from Ptolemy Classic. Its ports are opaque, but it can contain actors and relations. The toplevel composite actor is also associated with a Manager object that is responsible for managing any execution within the topology at a high level.
The executive director of a composite actor is the local director of the actor's container. The toplevel composite actor has no executive director, and getExecutiveDirector will return null. For transparent composite actors, the executive director and the local director will be the same.
The getDirector() method returns the local director if there is one. Otherwise, it returns the executive director of the CompositeActor, if there is one. Whatever it returns is called (simply) the director of the composite (it may be local or executive). This Director is responsible for the execution of all the actors contained within the composite actor.
A composite actor must have an executive director in order to communicate with the hierarchy around it. In fact, it cannot even receive data in its input ports without an executive director, since the executive director is responsible for supplying the receivers to the ports. The toplevel composite actor has no executive director and cannot have ports that transmit data, but it can still be executed as long as it has a local director. If the getDirector() method returns null, then the composite is not executable.
When a composite actor has both a director and an executive director, then the model of computation implemented by the director need not be the same as the model of computation implemented by the executive director. This is the source of the hierarchical heterogeneity in Ptolemy II. Multiple models of computation can be cleanly nested.
The ports of a CompositeActor are constrained to be IOPorts, the relations to be IORelations, and the actors to be instances of ComponentEntity that implement the Actor interface. Derived classes may impose further constraints by overriding newPort(), _addPort(), newRelation(), _addRelation(), and _addEntity().
IOPort
,
IORelation
,
ComponentEntity
,
Director
,
Manager
,
Serialized Form
Yellow (neuendor) |
Green (cxh) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity |
---|
CompositeEntity.ContainedObjectsIterator |
Field Summary | |
---|---|
protected java.util.LinkedList<ActorFiringListener> |
_actorFiringListeners
The list of ActorFiringListeners registered with this object. |
private java.util.List<IOPort> |
_cachedInputPorts
|
private java.util.List<IOPort> |
_cachedOutputPorts
|
protected CausalityInterface |
_causalityInterface
The causality interface, if it has been created. |
private Director |
_causalityInterfaceDirector
The director for which the causality interface was created. |
private java.util.Set<Executable> |
_derivedPiggybacks
The derived piggybacked executables. |
private Director |
_director
|
private boolean |
_inConnectionsChanged
|
protected java.util.List<Initializable> |
_initializables
List of objects whose (pre)initialize() and wrapup() methods should be slaved to these. |
private long |
_inputPortsVersion
|
private Manager |
_manager
|
protected boolean |
_notifyingActorFiring
Flag that is true if there are actor firing listeners. |
private long |
_outputPortsVersion
|
private java.util.List<Executable> |
_piggybacks
List piggybacked objects. |
protected java.util.Map<java.lang.String,java.util.List<IOPort>> |
_publishedPorts
Keep track of all published ports accessable in this container. |
protected java.util.Map<java.lang.String,IORelation> |
_publisherRelations
Keep track of all relations with published ports accessable in this container. |
private long |
_receiversVersion
Record of the workspace version the last time receivers were created. |
private RelationWidthInference |
_relationWidthInference
|
protected boolean |
_stopRequested
Indicator that a stop has been requested by a call to stop(). |
Fields inherited from class ptolemy.kernel.CompositeEntity |
---|
_levelCrossingLinks |
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 | |
---|---|
CompositeActor()
Construct a CompositeActor in the default workspace with no container and an empty string as its name. |
|
CompositeActor(CompositeEntity container,
java.lang.String name)
Create an actor with a name and a container. |
|
CompositeActor(Workspace workspace)
Construct a CompositeActor in the specified workspace with no container and an empty string as a name. |
Method Summary | |
---|---|
protected void |
_actorFiring(FiringEvent.FiringEventType type,
int multiplicity)
Send an actor firing event type to all actor firing listeners that have registered with this actor. |
protected void |
_actorFiring(FiringEvent event)
Send an actor firing event to all actor firing listeners that have registered with this actor. |
protected void |
_addEntity(ComponentEntity entity)
Add an actor to this container with minimal error checking. |
protected void |
_addPort(Port port)
Add a port to this actor. |
protected void |
_addRelation(ComponentRelation relation)
Add a relation to this container. |
protected void |
_finishedAddEntity(ComponentEntity entity)
Notify this actor that the given entity has been added inside it. |
protected IOPort |
_getPublishedPort(java.lang.String name)
Get the published port with name name. |
private void |
_getTransparentActorPiggybacks(java.util.Set<Executable> piggybacks,
boolean addPiggyBackAtThisLevel)
Fill in the piggybacks in the containted transparent CompositeActors. |
private RelationWidthInference |
_getWidthInferenceAlgorithm()
Return the RelationWidthInference algorithm. |
protected void |
_setDirector(Director director)
Set the local director for execution of this CompositeActor. |
void |
addActorFiringListener(ActorFiringListener listener)
Append a listener to the current set of actor firing listeners. |
void |
addInitializable(Initializable initializable)
Add the specified object to the list of objects whose preinitialize(), intialize(), and wrapup() methods should be invoked upon invocation of the corresponding methods of this object. |
void |
addPiggyback(Executable piggyback)
Add the specified object to the list of objects whose action methods should be invoked upon invocation of the corresponding actions methods of this object. |
java.lang.Object |
clone(Workspace workspace)
Clone the actor into the specified workspace. |
void |
connectionsChanged(Port port)
Invalidate the schedule and type resolution and create new receivers if the specified port is an opaque output port. |
void |
createReceivers()
Create receivers for each port. |
void |
createSchedule()
Create the schedule for this model, if necessary. |
void |
fire()
If this actor is opaque, transfer any data from the input ports of this composite to the ports connected on the inside, and then invoke the fire() method of its local director. |
CausalityInterface |
getCausalityInterface()
Return a causality interface for this actor. |
Director |
getDirector()
Return the director responsible for execution of the contained actors. |
Director |
getExecutiveDirector()
Return the executive director of this CompositeActor. |
Manager |
getManager()
Get the manager responsible for execution of this composite actor. |
boolean |
inferringWidths()
Determine whether widths are currently being inferred or not. |
void |
inferWidths()
Infer the width of the relations for which no width has been specified yet. |
void |
initialize()
Initialize this actor. |
java.util.List |
inputPortList()
List the input ports of this actor. |
boolean |
isFireFunctional()
If this actor is opaque, invoke the isFireFunctional() method of the local director and return its result. |
boolean |
isOpaque()
Return true if this actor contains a local director. |
boolean |
isStrict()
If this actor is opaque, invoke the isStrict() method of the local director and return its result. |
int |
iterate(int count)
Invoke a specified number of iterations of the actor. |
void |
linkToPublishedPort(java.util.regex.Pattern pattern,
TypedIOPort subscriberPort)
Link the subscriberPort with a already registered "published port" coming from a publisher. |
void |
linkToPublishedPort(java.lang.String name,
IOPort subscriberPort)
Link the subscriberPort with a already registered "published port" coming from a publisher. |
boolean |
needsWidthInference()
Return whether the current widths of the relation in the model are no longer valid anymore and the widths need to be inferred again. |
Receiver |
newInsideReceiver()
Return a new receiver of a type compatible with the local director. |
Port |
newPort(java.lang.String name)
Create a new IOPort with the specified name. |
Receiver |
newReceiver()
Return a new receiver of a type compatible with the executive director. |
ComponentRelation |
newRelation(java.lang.String name)
Create a new IORelation with the specified name, add it to the relation list, and return it. |
void |
notifyConnectivityChange()
Notify the manager that the connectivity in the model changed (width of relation changed, relations added, linked to different ports, ...). |
java.util.List |
outputPortList()
Return an enumeration of the output ports. |
boolean |
postfire()
If this actor is opaque, invoke the postfire() method of its local director and transfer output data. |
boolean |
prefire()
If this actor is opaque, invoke the prefire() method of the local director. |
void |
preinitialize()
Create receivers and invoke the preinitialize() method of the local director. |
void |
recordFiring(FiringEvent.FiringEventType type)
Record a firing event. |
void |
registerPublisherPort(java.lang.String name,
IOPort port)
Register a "published port" coming from a publisher. |
void |
removeActorFiringListener(ActorFiringListener listener)
Unregister an actor firing listener. |
void |
removeInitializable(Initializable initializable)
Remove the specified object from the list of objects whose preinitialize(), intialize(), and wrapup() methods should be invoked upon invocation of the corresponding methods of this object. |
void |
removePiggyback(Executable piggyback)
Remove the specified object from the list of objects whose action methods should be invoked upon invocation of the corresponding actions methods of this object. |
void |
requestChange(ChangeRequest change)
Queue a change request. |
void |
setContainer(CompositeEntity container)
Override the base class to invalidate the schedule and resolved types of the director. |
void |
setDirector(Director director)
Set the local director for execution of this CompositeActor. |
void |
setManager(Manager manager)
Set the Manager for execution of this CompositeActor. |
void |
stop()
Request that execution stop as soon as possible. |
void |
stopFire()
Request that execution of the current iteration complete. |
void |
terminate()
If this is an opaque CompositeActor, then look to our director for help. |
void |
unlinkToPublishedPort(java.util.regex.Pattern pattern,
TypedIOPort subscriberPort)
Unlink the subscriberPort with a already registered "published port" coming from a publisher. |
void |
unlinkToPublishedPort(java.lang.String name,
IOPort subscriberPort)
Unlink the subscriberPort with a already registered "published port" coming from a publisher. |
void |
unregisterPublisherPort(java.lang.String name,
IOPort publisherPort)
Unregister a "published port" coming from a publisher. |
void |
wrapup()
If this actor is opaque, then invoke the wrapup() method of the local director. |
Methods inherited from class ptolemy.kernel.ComponentEntity |
---|
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName |
Methods inherited from class ptolemy.kernel.Entity |
---|
_removePort, connectedPortList, connectedPorts, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts |
Methods inherited from class ptolemy.kernel.InstantiableNamedObj |
---|
_setParent, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ptolemy.kernel.util.Nameable |
---|
description, getContainer, getDisplayName, getFullName, getName, getName, setName |
Methods inherited from interface ptolemy.kernel.util.Derivable |
---|
getDerivedLevel, getDerivedList, propagateValue |
Field Detail |
---|
protected java.util.LinkedList<ActorFiringListener> _actorFiringListeners
protected CausalityInterface _causalityInterface
protected transient java.util.List<Initializable> _initializables
protected boolean _notifyingActorFiring
protected java.util.Map<java.lang.String,java.util.List<IOPort>> _publishedPorts
protected java.util.Map<java.lang.String,IORelation> _publisherRelations
protected boolean _stopRequested
private transient java.util.Set<Executable> _derivedPiggybacks
private Director _director
private boolean _inConnectionsChanged
private Manager _manager
private transient long _inputPortsVersion
private transient java.util.List<IOPort> _cachedInputPorts
private transient long _outputPortsVersion
private transient java.util.List<IOPort> _cachedOutputPorts
private Director _causalityInterfaceDirector
private transient java.util.List<Executable> _piggybacks
private long _receiversVersion
private RelationWidthInference _relationWidthInference
Constructor Detail |
---|
public CompositeActor()
public CompositeActor(Workspace workspace)
workspace
- The workspace that will list the actor.public CompositeActor(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container actor.name
- The name of this actor.
IllegalActionException
- If the container is incompatible
with this actor.
NameDuplicationException
- If the name coincides with
an actor already in the container.Method Detail |
---|
public void addActorFiringListener(ActorFiringListener listener)
addActorFiringListener
in interface FiringsRecordable
listener
- The listener to which to send actor firing messages.removeActorFiringListener(ActorFiringListener)
public void addInitializable(Initializable initializable)
addInitializable
in interface Initializable
initializable
- The object whose methods should be invoked.removeInitializable(Initializable)
,
addPiggyback(Executable)
public void addPiggyback(Executable piggyback)
piggyback
- The piggyback object.addInitializable(Initializable)
,
removePiggyback(Executable)
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class CompositeEntity
workspace
- The workspace for the cloned object.
java.lang.CloneNotSupportedException
- If the actor contains
level crossing transitions so that its connections cannot be cloned,
or if one of the attributes cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void connectionsChanged(Port port)
connectionsChanged
in class Entity
port
- The port that has connection changes.public void fire() throws IllegalActionException
fire
in interface Executable
IllegalActionException
- If there is no director, or if
the director's fire() method throws it, or if the actor is not
opaque.public void createReceivers() throws IllegalActionException
createReceivers
in interface Actor
IllegalActionException
- If any port throws it.AtomicActor.createReceivers()
,
createReceivers()
public void createSchedule() throws IllegalActionException
IllegalActionException
- If the schedule can't be created.public CausalityInterface getCausalityInterface()
CausalityInterfaceForComposites
.
If this is called multiple times, the same object is returned each
time unless the director has changed since the last call, in
which case a new object is returned.
getCausalityInterface
in interface Actor
public Director getDirector()
getDirector
in interface Actor
setDirector(Director)
public Director getExecutiveDirector()
getExecutiveDirector
in interface Actor
public Manager getManager()
getManager
in interface Actor
setManager(Manager)
public boolean inferringWidths()
public void inferWidths() throws IllegalActionException
IllegalActionException
- If the widths of the relations at port are not consistent
or if the width cannot be inferred for a relation.public void initialize() throws IllegalActionException
initialize
in interface Initializable
IllegalActionException
- If there is no director, or
if the director's initialize() method throws it, or if the
actor is not opaque.public java.util.List inputPortList()
inputPortList
in interface Actor
public boolean isFireFunctional()
isFireFunctional
in interface Executable
public boolean isOpaque()
isOpaque
in class CompositeEntity
CompositeEntity
public boolean isStrict() throws IllegalActionException
isStrict
in interface Executable
IllegalActionException
- Thrown if causality interface
cannot be computed.public int iterate(int count) throws IllegalActionException
This base class method actually invokes prefire(), fire(), and postfire(), as described above, but a derived class may override the method to execute more efficient code.
iterate
in interface Executable
count
- The number of iterations to perform.
IllegalActionException
- If iterating is not
permitted, or if prefire(), fire(), or postfire() throw it.public void linkToPublishedPort(java.lang.String name, IOPort subscriberPort) throws IllegalActionException, NameDuplicationException
name
- The name is being used in the matching process
to match publisher and subscriber.subscriberPort
- The subscribed port.
NameDuplicationException
- If there are name conflicts
as a result of the added relations or ports.
IllegalActionException
- If the published port cannot be found.public void linkToPublishedPort(java.util.regex.Pattern pattern, TypedIOPort subscriberPort) throws IllegalActionException, NameDuplicationException
pattern
- The pattern is being used in the matching process
to match publisher and subscriber.subscriberPort
- The subscribed port.
NameDuplicationException
- If there are name conflicts
as a result of the added relations or ports.
IllegalActionException
- If the published port cannot be found.public boolean needsWidthInference() throws KernelRuntimeException
KernelRuntimeException
- If toplevel not a CompositeActor.public void notifyConnectivityChange()
public Receiver newInsideReceiver() throws IllegalActionException
IllegalActionException
- If there is no local director.public Port newPort(java.lang.String name) throws NameDuplicationException
newPort
in class ComponentEntity
name
- The name for the new port.
NameDuplicationException
- If the actor already has a port
with the specified name.public Receiver newReceiver() throws IllegalActionException
newReceiver
in interface Actor
IllegalActionException
- If there is no executive director.public ComponentRelation newRelation(java.lang.String name) throws IllegalActionException, NameDuplicationException
newRelation
in class CompositeEntity
name
- The name of the new relation.
IllegalActionException
- If name argument is null.
NameDuplicationException
- If name collides with a name
already on the container's contents list.public java.util.List outputPortList()
outputPortList
in interface Actor
public boolean postfire() throws IllegalActionException
postfire
in interface Executable
IllegalActionException
- If there is no director,
or if the director's postfire() method throws it, or if this
actor is not opaque.public boolean prefire() throws IllegalActionException
prefire
in interface Executable
IllegalActionException
- If there is no director,
or if the director's prefire() method throws it, or if this actor
is not opaque.public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
IllegalActionException
- If there is no director, or if
the director's preinitialize() method throws it, or if this actor
is not opaque.public void recordFiring(FiringEvent.FiringEventType type)
recordFiring
in interface FiringsRecordable
type
- The firing event to be recorded.public void registerPublisherPort(java.lang.String name, IOPort port) throws NameDuplicationException, IllegalActionException
name
- The name is being used in the matching process
to match publisher and subscriber.port
- The published port.
NameDuplicationException
- If the published port
is already registered.
IllegalActionException
- If the published port can't
be added.public void removeActorFiringListener(ActorFiringListener listener)
removeActorFiringListener
in interface FiringsRecordable
listener
- The listener to remove from the list of listeners
to which actor firing messages are sent.addActorFiringListener(ActorFiringListener)
public void removeInitializable(Initializable initializable)
removeInitializable
in interface Initializable
initializable
- The object whose methods should no longer be invoked.addInitializable(Initializable)
,
removePiggyback(Executable)
public void removePiggyback(Executable piggyback)
piggyback
- The piggyback object.removeInitializable(Initializable)
,
addPiggyback(Executable)
public void requestChange(ChangeRequest change)
requestChange
in interface Changeable
requestChange
in class NamedObj
change
- The requested change.NamedObj.executeChangeRequests()
,
NamedObj.setDeferringChangeRequests(boolean)
,
Changeable
public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
setContainer
in class CompositeEntity
container
- The proposed container.
IllegalActionException
- If the action would result in a
recursive containment structure, or if
this entity and container are not in the same workspace.
NameDuplicationException
- If the container already has
an entity with the name of this entity.ComponentEntity.getContainer()
public void setDirector(Director director) throws IllegalActionException, NameDuplicationException
director
- The Director responsible for execution.
IllegalActionException
- If the director is not in
the same workspace as this actor. It may also be thrown in derived
classes if the director is not compatible.
NameDuplicationException
- If an attribute already exists
in this container with the same name as the given director.getDirector()
public void setManager(Manager manager) throws IllegalActionException
manager
- The Manager
IllegalActionException
- If this actor has a
container, or the manager is not in the same workspace as this
actor.getManager()
public void stop()
stop
in interface Executable
public void stopFire()
stopFire
in interface Executable
public void terminate()
terminate
in interface Executable
public void unlinkToPublishedPort(java.lang.String name, IOPort subscriberPort) throws IllegalActionException
name
- The name is being used in the matching process
to match publisher and subscriber.subscriberPort
- The subscribed port.
NameDuplicationException
- If there are name conflicts
as a result of the added relations or ports.
IllegalActionException
- If the published port cannot be found.public void unlinkToPublishedPort(java.util.regex.Pattern pattern, TypedIOPort subscriberPort) throws IllegalActionException
pattern
- The pattern is being used in the matching process
to match publisher and subscriber.subscriberPort
- The subscribed port.
NameDuplicationException
- If there are name conflicts
as a result of the added relations or ports.
IllegalActionException
- If the published port cannot be found.public void unregisterPublisherPort(java.lang.String name, IOPort publisherPort)
name
- The name is being used in the matching process
to match publisher and subscriber. This will be the port
that should be removedpublisherPort
- The publisher port.public void wrapup() throws IllegalActionException
wrapup
in interface Initializable
IllegalActionException
- If there is no director,
or if the director's wrapup() method throws it, or if this
actor is not opaque.protected final void _actorFiring(FiringEvent event)
event
- The event.protected final void _actorFiring(FiringEvent.FiringEventType type, int multiplicity)
type
- The type.multiplicity
- The multiplicity of the firing, that is,
the number of times the firing will occur or has occurred.protected void _addEntity(ComponentEntity entity) throws IllegalActionException, NameDuplicationException
_addEntity
in class CompositeEntity
entity
- Actor to contain.
IllegalActionException
- If the actor has no name, or the
action would result in a recursive containment structure, or the
argument does not implement the Actor interface.
NameDuplicationException
- If the name collides with a name
already on the actor contents list.protected void _addPort(Port port) throws IllegalActionException, NameDuplicationException
_addPort
in class ComponentEntity
port
- The port to add to this actor.
IllegalActionException
- If the port class is not
acceptable to this actor, or the port has no name.
NameDuplicationException
- If the port name collides with a
name already in the actor.protected void _addRelation(ComponentRelation relation) throws IllegalActionException, NameDuplicationException
_addRelation
in class CompositeEntity
relation
- Relation to contain.
IllegalActionException
- If the relation has no name, or is
not an instance of IORelation.
NameDuplicationException
- If the name collides with a name
already on the contained relations list.protected void _finishedAddEntity(ComponentEntity entity)
_finishedAddEntity
in class CompositeEntity
entity
- Actor to contain.
IllegalActionException
- If the actor has no name, or the
action would result in a recursive containment structure, or the
argument does not implement the Actor interface.
NameDuplicationException
- If the name collides with a name
already on the actor contents list.protected final IOPort _getPublishedPort(java.lang.String name) throws IllegalActionException, NameDuplicationException
name
- The name of the published port.
IllegalActionException
- If the publisher can't be found.
NameDuplicationException
- If there are multiple publishers with the same name.protected void _setDirector(Director director) throws IllegalActionException, NameDuplicationException
director
- The Director responsible for execution.
IllegalActionException
- If removing the old director
causes this to be thrown. Should not be thrown.
NameDuplicationException
- If removing the old director
causes this to be thrown. Should not be thrown.private void _getTransparentActorPiggybacks(java.util.Set<Executable> piggybacks, boolean addPiggyBackAtThisLevel)
piggybacks
- The piggybacks that will be filled it.addPiggyBackAtThisLevel
- True when the piggybacks directly in this composite
actor should also be included.private RelationWidthInference _getWidthInferenceAlgorithm()
KernelRuntimeException
- If toplevel not a CompositeActor.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |