Package ptolemy.actor.lib.hoc
Class MobileModel
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class MobileModel extends TypedCompositeActor
This is a composite actor with an input port that accepts MoML descriptions of changes that are applied to the contents. Rather than specified before executing, the inside model can be dynamically changed either locally or remotely. Currently, the model that dynamically applied to this actor is specified by a moml string from the modelString input. Currently, it only accepts models with one input and one output, and requires the model name its input port as "input", output port as "output".- Since:
- Ptolemy II 4.0
- Version:
- $Id$
- Author:
- Yang Zhao
- Pt.AcceptedRating:
- Red (reviewmoderator)
- Pt.ProposedRating:
- Red (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description Parameter
connectPorts
the Parameter specifies whether to connect the input and output to the inside model.Parameter
defaultValue
The default output token when there is no inside model defined.Parameter
director
The inside Director for executing the inside model.TypedIOPort
input
The input port for incoming data to the inside model.TypedIOPort
modelString
The input port for model changing request of the inside model.TypedIOPort
output
The output port for the result after firing the inside model upon the incoming data.Parameter
refresh
This Parameter specifies whether to replace the previous model when there is model changing request or not.-
Fields inherited from class ptolemy.actor.CompositeActor
_actorFiringListeners, _causalityInterface, _derivedPiggybacks, _initializables, _notifyingActorFiring, _piggybacks, _publishedPorts, _publisherRelations, _stopRequested, _subscribedPorts
-
Fields inherited from class ptolemy.kernel.CompositeEntity
_levelCrossingLinks
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _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
Constructors Constructor Description MobileModel(CompositeEntity container, java.lang.String name)
Construct an actor with a name and a container.MobileModel(Workspace workspace)
Construct an actor in the specified workspace with no container and an empty string as a name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_exportMoMLContents(java.io.Writer output, int depth)
Export the moml description of this.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.void
fire()
Save the model here if there is a new model to apply.boolean
isOpaque()
Return true.boolean
postfire()
Update the model here to achieve consistency.boolean
prefire()
Return true if the actor either of its input port has token.void
preinitialize()
preinitialize this actor.void
wrapup()
Clean up tha changes that have been made.-
Methods inherited from class ptolemy.actor.TypedCompositeActor
_addEntity, _addPort, _addRelation, _checkTypesFromTo, _destinationTypeConstraints, attributeChanged, attributeTypeChanged, isBackwardTypeInferenceEnabled, newPort, newRelation, resolveTypes, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.CompositeActor
_actorFiring, _actorFiring, _finishedAddEntity, _setDirector, _transferPortParameterInputs, addActorFiringListener, addInitializable, addPiggyback, connectionsChanged, createReceivers, createSchedule, getCausalityInterface, getDirector, getExecutiveDirector, getManager, getPublishedPort, getPublishedPortChannel, getPublishedPorts, getSubscribedPortChannel, inferringWidths, inferWidths, initialize, inputPortList, isFireFunctional, isPublishedPort, isStrict, iterate, linkToPublishedPort, linkToPublishedPort, linkToPublishedPort, linkToPublishedPort, needsWidthInference, newInsideReceiver, newReceiver, notifyConnectivityChange, outputPortList, recordFiring, registerPublisherPort, registerPublisherPort, removeActorFiringListener, removeInitializable, removePiggyback, requestChange, setContainer, setDirector, setManager, stop, stopFire, terminate, unlinkToPublishedPort, unlinkToPublishedPort, unlinkToPublishedPort, unlinkToPublishedPort, unregisterPublisherPort, unregisterPublisherPort
-
Methods inherited from class ptolemy.kernel.CompositeEntity
_adjustDeferrals, _containedDecorators, _deepOpaqueEntityList, _description, _removeEntity, _removeRelation, _validateSettables, allAtomicEntityList, allowLevelCrossingConnect, classDefinitionList, connect, connect, containedObjectsIterator, deepCompositeEntityList, deepEntityList, deepGetEntities, deepNamedObjList, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportLinks, exportMoML, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyAllCompositeTransparentAndOpaqueEntityList, lazyClassDefinitionList, lazyDeepEntityList, lazyEntityList, lazyRelationList, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, setClassDefinition, statistics, uniqueName
-
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 ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, clone, decorators, 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, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, 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
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, initialize, removeInitializable
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
input
public TypedIOPort input
The input port for incoming data to the inside model.
-
modelString
public TypedIOPort modelString
The input port for model changing request of the inside model. The type is string.
-
output
public TypedIOPort output
The output port for the result after firing the inside model upon the incoming data. Notice that the type is determined by the type of the defaultValue parameter.
-
director
public Parameter director
The inside Director for executing the inside model.
-
refresh
public Parameter refresh
This Parameter specifies whether to replace the previous model when there is model changing request or not. The type of this parameter is boolean. Select this parameter if it does replace.
-
connectPorts
public Parameter connectPorts
the Parameter specifies whether to connect the input and output to the inside model. The type of this parameter is boolean.
-
defaultValue
public Parameter defaultValue
The default output token when there is no inside model defined. The default value is 0, and the default type is int. Notice that the type of the output port is determined by the type of this parameter.
-
-
Constructor Detail
-
MobileModel
public MobileModel(Workspace workspace) throws IllegalActionException
Construct an actor in the specified workspace with no container and an empty string as a name. You can then change the name with setName(). If the workspace argument is null, then use the default workspace.- Parameters:
workspace
- The workspace that will list the actor.- Throws:
IllegalActionException
- If populating the actor with ports and parameters fails.
-
MobileModel
public MobileModel(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct an actor with a name and a container. The container argument must not be null, or a NullPointerException will be thrown.- Parameters:
container
- The container.name
- The name of this actor.- Throws:
IllegalActionException
- If the container is incompatible with this actor or if populating the actor with ports and parameters fails.NameDuplicationException
- If the name coincides with an actor already in the container.
-
-
Method Detail
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace. This calls the base class and then sets the value public variable in the new object to equal the cloned parameter in that new object.- Overrides:
clone
in classCompositeActor
- 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
Save the model here if there is a new model to apply. and then call super.fire().- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classCompositeActor
- Throws:
IllegalActionException
- If there is no director, or if the director's fire() method throws it, or if the actor is not opaque.
-
isOpaque
public boolean isOpaque()
Return true.- Overrides:
isOpaque
in classCompositeActor
- Returns:
- True if the entity is opaque.
- See Also:
CompositeEntity
-
postfire
public boolean postfire() throws IllegalActionException
Update the model here to achieve consistency.- Specified by:
postfire
in interfaceExecutable
- Overrides:
postfire
in classCompositeActor
- Returns:
- True if the execution can continue into the next iteration.
- Throws:
IllegalActionException
- If there is no director, or if the director's postfire() method throws it, or if this actor is not opaque.
-
prefire
public boolean prefire() throws IllegalActionException
Return true if the actor either of its input port has token.- Specified by:
prefire
in interfaceExecutable
- Overrides:
prefire
in classCompositeActor
- Returns:
- True if the iteration can proceed.
- Throws:
IllegalActionException
- Not thrown in this base class.
-
preinitialize
public void preinitialize() throws IllegalActionException
preinitialize this actor. create the director as specified by the director parameter.- Specified by:
preinitialize
in interfaceInitializable
- Overrides:
preinitialize
in classCompositeActor
- Throws:
IllegalActionException
- If can't create the director, or if the director's preinitialize() method throws it.
-
wrapup
public void wrapup() throws IllegalActionException
Clean up tha changes that have been made.- Specified by:
wrapup
in interfaceInitializable
- Overrides:
wrapup
in classCompositeActor
- Throws:
IllegalActionException
- If there is no director, or if the director's wrapup() method throws it, or if this actor is not opaque.
-
_exportMoMLContents
protected void _exportMoMLContents(java.io.Writer output, int depth) throws java.io.IOException
Export the moml description of this.- Overrides:
_exportMoMLContents
in classCompositeEntity
- Parameters:
output
- The output to write to.depth
- The depth in the hierarchy, to determine indenting.- Throws:
java.io.IOException
- If an I/O error occurs.- See Also:
NamedObj.exportMoML(Writer, int)
-
-