|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| 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
ptolemy.actor.TypedCompositeActor
ptolemy.actor.LazyTypedCompositeActor
ptolemy.cg.lib.ModularCompiledSDFTypedCompositeActor
public class ModularCompiledSDFTypedCompositeActor
An aggregation of typed actors with lazy evaluation. The contents of this actor can be created in the usual way via visual editor by dragging in other actors and ports and connecting them. When it exports a MoML description of itself, it describes its ports and parameters in the usual way, but contained actors, relations, and their interconnections are exported within <configure> </configure> tags. When reloading the MoML description, evaluation of the MoML within the configure tags is deferred until there is an explicit request for the contents. This behavior is useful for large complicated models where the time it takes to instantiate the entire model is large. It permits opening and browsing the model without a long wait. However, the cost comes typically when running the model. The instantiation time will be added to the time it takes to preinitialize the model.
The lazy contents of this composite are specified via the configure() method, which is called by the MoML parser and passed MoML code. The MoML is evaluated lazily; i.e. it is not actually evaluated until there is a request for its contents, via a call to getEntity(), numEntities(), entityList(), relationList(), or any related method. You can also force evaluation of the MoML by calling populate(). Accessing the attributes or ports of this composite does not trigger a populate() call, so a visual editor can interact with the actor from the outside in the usual way, enabling connections to its ports, editing of its parameters, and rendering of its custom icon, if any.
The configure method can be passed a URL or MoML text or both. If it is given MoML text, that text will normally be wrapped in a processing instruction, as follows:
<?momlThe processing instruction, which is enclosed in "<?" and "?>" prevents premature evaluation of the MoML. The processing instruction has a target, "moml", which specifies that it contains MoML code. The keyword "moml" in the processing instruction must be exactly as above, or the entire processing instruction will be ignored. The populate() method strips off the processing instruction and evaluates the MoML elements. The group element allows the library contents to be given as a set of elements (the MoML parser requires that there always be a single top-level element, which in this case will be the group element).... MoML elements giving library contents ... ?>
One subtlety in using this class arises because of a problem typical of lazy evaluation. A number of exceptions may be thrown because of errors in the MoML code when the MoML code is evaluated. However, since that code is evaluated lazily, it is evaluated in a context where these exceptions are not expected. There is no completely clean solution to this problem; our solution is to translate all exceptions to runtime exceptions in the populate() method. This method, therefore, violates the condition for using runtime exceptions in that the condition that causes these exceptions to be thrown is not a testable precondition.
A second subtlety involves cloning. When this class is cloned, if the configure MoML text has not yet been evaluated, then the clone is created with the same (unevaluated) MoML text, rather than being populated with the contents specified by that text. If the object is cloned after being populated, the clone will also be populated. Cloning is used in actor-oriented classes to create subclasses or instances of a class. When a LazyTypedCompositeActor contained by a subclass or an instance is populated, it delegates to the instance in the class definition. When that instance is populated, all of the derived instances in subclasses and instances of the class will also be populated as a side effect.
A third subtlety is that parameters of this actor cannot refer to contained entities or relations, nor to attributes contained by those. This is a rather esoteric use of expressions, so this limitation may not be onerous. You probably didn't know you could do that anyway. An attempt to make such references will simply result in the expression failing to evaluate.
| Red (rodiers) |
| Red (rodiers) |
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class ptolemy.actor.LazyTypedCompositeActor |
|---|
LazyTypedCompositeActor.ContainedObjectsIterator |
| Field Summary | |
|---|---|
private boolean |
_addedSubscribersFromProfile
|
private ModularSDFCodeGenerator |
_codeGenerator
|
private int |
_creatingPubSub
|
private java.lang.reflect.Method |
_fireMethod
|
private boolean |
_generatingCode
|
private boolean |
_isOpaque
|
private java.lang.Object |
_objectWrapper
|
private Profile |
_profile
|
private long |
_receiversVersion
|
private java.util.Map<java.lang.String,IOPort> |
_subscriberPorts
|
private java.util.Map<java.lang.String,IORelation> |
_subscriberRelations
|
private static boolean |
_USE_PROFILE
|
Parameter |
recompileHierarchy
A boolean parameter to enforce recompilation of this ModularCodeGenTypedCompositeActor and all contained ModularCodeGenTypedCompositeActors. |
Parameter |
recompileThisLevel
A boolean parameter to enforce recompilation of this ModularCodeGenTypedCompositeActor. |
| Fields inherited from class ptolemy.actor.LazyTypedCompositeActor |
|---|
_configureDone, _populating |
| Fields inherited from class ptolemy.actor.CompositeActor |
|---|
_actorFiringListeners, _causalityInterface, _initializables, _notifyingActorFiring, _publishedPorts, _publisherRelations, _stopRequested |
| 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 | |
|---|---|
ModularCompiledSDFTypedCompositeActor()
Construct a library in the default workspace with no container and an empty string as its name. |
|
ModularCompiledSDFTypedCompositeActor(CompositeEntity container,
java.lang.String name)
Construct a library with the given container and name. |
|
ModularCompiledSDFTypedCompositeActor(Workspace workspace)
Construct a library in the specified workspace with no container and an empty string as a name. |
|
| Method Summary | |
|---|---|
protected void |
_addEntity(ComponentEntity entity)
Add an entity or class definition to this container. |
protected void |
_addRelation(ComponentRelation relation)
Add a relation to this container. |
private void |
_createCodeGenerator()
|
private void |
_generateCode()
|
private Profile |
_getProfile()
|
private void |
_init()
|
private boolean |
_isPublishedPort(IOPort port)
|
private boolean |
_isSubscribedPort(IOPort port)
|
private boolean |
_modelChanged()
|
private java.lang.String |
_pubSubChannelName(IOPort port,
boolean publisher,
boolean subscriber)
|
protected void |
_removeEntity(ComponentEntity entity)
Remove the specified entity. |
protected void |
_removeRelation(ComponentRelation relation)
Remove the specified relation. |
private void |
_setRecompileFlag()
|
private void |
_transferOutputs(IOPort port,
java.lang.Object outputTokens)
|
void |
attributeChanged(Attribute attribute)
React to a change in an attribute. |
static java.lang.String |
classToActorName(java.lang.String className)
Generate actor name from its class name |
void |
connectionsChanged(Port port)
Invalidate the schedule and type resolution and create new receivers if the specified port is an opaque output port. |
Profile.Port |
convertProfilePort(IOPort port)
Convert this Ptolemy port to a port that will be saved in the profile. |
void |
createReceivers()
Create receivers for each port. |
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. |
Profile |
getProfile()
|
void |
initialize()
Create receivers and invoke the preinitialize() method of the local director. |
boolean |
isOpaque()
Always return true (opaque) |
void |
linkToPublishedPort(java.lang.String name,
IOPort subscriberPort)
Link the subscriberPort with a already registered "published port" coming from a publisher. |
ComponentRelation |
newRelation(java.lang.String name)
Create a new relation with the specified name, add it to the relation list, and return it. |
java.util.List |
portList()
Get the ports belonging to this entity. |
void |
preinitialize()
Create receivers and invoke the preinitialize() method of the local director. |
void |
registerPublisherPort(java.lang.String name,
IOPort port)
Register a "published port" coming from a publisher. |
void |
stopFire()
Request that execution of the current iteration complete. |
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()
Invoke the wrapup() method of all the actors contained in the director's container. |
| Methods inherited from class ptolemy.actor.TypedCompositeActor |
|---|
_addPort, _checkTypesFromTo, _typeConstraintsFromTo, newPort, resolveTypes, typeConstraintList, typeConstraints |
| Methods inherited from class ptolemy.kernel.CompositeEntity |
|---|
_adjustDeferrals, _deepOpaqueEntityList, _description, _recordDecoratedAttributes, _validateSettables, allAtomicEntityList, allowLevelCrossingConnect, connect, connect, containedObjectsIterator, deepGetEntities, exportLinks, getAttribute, getEntities, getPort, getRelations, isAtomic, numEntities, numRelations, removeAllEntities, removeAllRelations, statistics |
| 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, 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.actor.Actor |
|---|
getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList |
| Methods inherited from interface ptolemy.actor.Executable |
|---|
isFireFunctional, isStrict, iterate, postfire, prefire, stop, terminate |
| Methods inherited from interface ptolemy.actor.Initializable |
|---|
addInitializable, removeInitializable |
| 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 |
|---|
public Parameter recompileHierarchy
public Parameter recompileThisLevel
private boolean _addedSubscribersFromProfile
private boolean _generatingCode
private ModularSDFCodeGenerator _codeGenerator
private transient java.lang.reflect.Method _fireMethod
private java.lang.Object _objectWrapper
private boolean _isOpaque
private long _receiversVersion
private int _creatingPubSub
private Profile _profile
private java.util.Map<java.lang.String,IOPort> _subscriberPorts
private java.util.Map<java.lang.String,IORelation> _subscriberRelations
private static boolean _USE_PROFILE
| Constructor Detail |
|---|
public ModularCompiledSDFTypedCompositeActor()
public ModularCompiledSDFTypedCompositeActor(Workspace workspace)
workspace - The workspace that will list the actor.
public ModularCompiledSDFTypedCompositeActor(CompositeEntity container,
java.lang.String name)
throws NameDuplicationException,
IllegalActionException
container - The container.name - The name of this library.
IllegalActionException - If the entity cannot be contained
by the proposed container.
NameDuplicationException - If the container already has an
actor with this name.| Method Detail |
|---|
public Profile.Port convertProfilePort(IOPort port)
throws IllegalActionException
port - The Ptolemy port.
IllegalActionException - When the width can't be retrieved.
public void attributeChanged(Attribute attribute)
throws IllegalActionException
attributeChanged in class NamedObjattribute - The attribute that changed.
IllegalActionException - If the change is not acceptable
to this container.public static java.lang.String classToActorName(java.lang.String className)
className - The class name of the actor
public void connectionsChanged(Port port)
connectionsChanged in class CompositeActorport - The port that has connection changes.
public void createReceivers()
throws IllegalActionException
createReceivers in interface ActorcreateReceivers in class CompositeActorIllegalActionException - If any port throws it.AtomicActor.createReceivers(),
CompositeActor.createReceivers()public java.util.List portList()
portList in class Entity
public void fire()
throws IllegalActionException
fire in interface Executablefire in class CompositeActorIllegalActionException - If there is no director, or if
the director's fire() method throws it, or if the actor is not
opaque.
public void initialize()
throws IllegalActionException
initialize in interface Initializableinitialize in class CompositeActorIllegalActionException - If there is no director, or if
the director's preinitialize() method throws it, or if this actor
is not opaque.public boolean isOpaque()
isOpaque in class CompositeActorCompositeEntity
public void linkToPublishedPort(java.lang.String name,
IOPort subscriberPort)
throws IllegalActionException,
NameDuplicationException
linkToPublishedPort in class CompositeActorname - 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 ComponentRelation newRelation(java.lang.String name)
throws NameDuplicationException
newRelation in class LazyTypedCompositeActorname - The name of the new relation.
IllegalActionException - If name argument is null.
NameDuplicationException - If name collides with a name
already in the container.
public void preinitialize()
throws IllegalActionException
preinitialize in interface Initializablepreinitialize in class CompositeActorIllegalActionException - If there is no director, or if
the director's preinitialize() method throws it, or if this actor
is not opaque.
public void registerPublisherPort(java.lang.String name,
IOPort port)
throws NameDuplicationException,
IllegalActionException
registerPublisherPort in class CompositeActorname - 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 stopFire()
stopFire in interface ExecutablestopFire in class CompositeActor
public void unlinkToPublishedPort(java.lang.String name,
IOPort subscriberPort)
throws IllegalActionException
unlinkToPublishedPort in class CompositeActorname - 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 unregisterPublisherPort(java.lang.String name,
IOPort publisherPort)
unregisterPublisherPort in class CompositeActorname - 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
This method should be invoked once per execution. None of the other action methods should be invoked after it in the execution. This method is not synchronized on the workspace, so the caller should be.
wrapup in interface Initializablewrapup in class CompositeActorIllegalActionException - If the wrapup() method of
one of the associated actors throws it.public Profile getProfile()
protected void _addEntity(ComponentEntity entity)
throws IllegalActionException,
NameDuplicationException
_addEntity in class LazyTypedCompositeActorentity - Entity to contain.
IllegalActionException - If the entity has no name, or the
action would result in a recursive containment structure.
NameDuplicationException - If the name collides with a name
already in the entity.
protected void _addRelation(ComponentRelation relation)
throws IllegalActionException,
NameDuplicationException
_addRelation in class LazyTypedCompositeActorrelation - Relation to contain.
IllegalActionException - If the relation has no name.
NameDuplicationException - If the name collides with a name
already on the contained relations list.protected void _removeEntity(ComponentEntity entity)
_removeEntity in class LazyTypedCompositeActorentity - The entity to remove.protected void _removeRelation(ComponentRelation relation)
_removeRelation in class LazyTypedCompositeActorrelation - The relation to remove.
private void _createCodeGenerator()
throws IllegalActionException,
NameDuplicationException
IllegalActionException
NameDuplicationExceptionprivate void _init()
private boolean _isSubscribedPort(IOPort port)
private boolean _isPublishedPort(IOPort port)
private void _generateCode()
throws KernelException
KernelExceptionprivate Profile _getProfile()
private boolean _modelChanged()
throws IllegalActionException
IllegalActionException
private java.lang.String _pubSubChannelName(IOPort port,
boolean publisher,
boolean subscriber)
private void _setRecompileFlag()
throws IllegalActionException
IllegalActionException
private void _transferOutputs(IOPort port,
java.lang.Object outputTokens)
throws IllegalActionException
IllegalActionException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||