ptolemy.actor.gt
Class ModelGenerator
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.actor.lib.Source
ptolemy.actor.gt.ModelGenerator
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
public class ModelGenerator
- extends Source
An actor to open a window to display the specified model and applie its inputs
to the model.
If inputs are provided for the moml input port, they are expected to be
MoML strings that are to be applied to the model. This can be used, for
example, to create animations. If inputs are not provided for the moml input
port but for either the trigger port of the modelName port, then empty models
are generated with the name specified by the most updated value of the modelName
PortParameter.
- Since:
- Ptolemy II 6.0
- Version:
- $Id: ModelGenerator.java 54733 2009-06-27 08:58:39Z tfeng $
- Author:
- Thomas Huining Feng
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Method Summary |
private java.net.URI |
_getModelURI(java.lang.String modelName)
Given a model name, generate a URI for the model to be created with that
name. |
java.lang.Object |
clone(Workspace workspace)
Clone the actor into the specified workspace. |
void |
fire()
Read the input at the input ports. |
boolean |
prefire()
Return true if the moml port is connected and has a token, or the
modelName port is connected and has a token, or neither the modelName
port nor the moml port is connected (in which case this actor serves as
a source). |
Methods inherited from class ptolemy.actor.AtomicActor |
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup |
Methods inherited from class ptolemy.kernel.ComponentEntity |
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName |
Methods inherited from class ptolemy.kernel.Entity |
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName |
Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
modelName
public PortParameter modelName
- The port parameter for the model name.
moml
public TypedIOPort moml
- The port to receive moml strings of the models.
_emptyModel
private Entity _emptyModel
- The empty model.
_parser
private MoMLParser _parser
- The parser used to parse the moml strings.
ModelGenerator
public ModelGenerator(CompositeEntity container,
java.lang.String name)
throws IllegalActionException,
NameDuplicationException
- Construct an actor with the given container and name.
The output and trigger ports are also constructed.
- Parameters:
container
- The container.name
- The name of this actor.
- Throws:
IllegalActionException
- If the entity cannot be contained
by the proposed container.
NameDuplicationException
- If the container already has an
actor with this name.
clone
public java.lang.Object clone(Workspace workspace)
throws java.lang.CloneNotSupportedException
- Clone the actor into the specified workspace.
- Overrides:
clone
in class AtomicActor
- Parameters:
workspace
- The workspace for the new object.
- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains
an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
fire
public void fire()
throws IllegalActionException
- Read the input at the input ports. If the moml port has a token, read it
in as a string and parse the string into a model. If not, create an
empty model. If the modelName is not an empty string, set the name of
the model with the value of modelName. Produce the model to the output
port.
- Specified by:
fire
in interface Executable
- Overrides:
fire
in class Source
- Throws:
IllegalActionException
- If the ports cannot be read, or if the
model cannot be produced.
prefire
public boolean prefire()
throws IllegalActionException
- Return true if the moml port is connected and has a token, or the
modelName port is connected and has a token, or neither the modelName
port nor the moml port is connected (in which case this actor serves as
a source).
- Specified by:
prefire
in interface Executable
- Overrides:
prefire
in class Source
- Returns:
- true if the actor is ready to fire; false otherwise.
- Throws:
IllegalActionException
- If connectivity of the input ports
cannot be determined, or availability of the tokens cannot be tested.
_getModelURI
private java.net.URI _getModelURI(java.lang.String modelName)
throws java.net.URISyntaxException
- Given a model name, generate a URI for the model to be created with that
name.
- Parameters:
modelName
- The model name.
- Returns:
- The URI.
- Throws:
java.net.URISyntaxException
- If the URI cannot be determined.