|
||||||||||
| 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.domains.fsm.kernel.FSMActor
An FSMActor contains a set of states and transitions. A transition has a guard expression and a trigger expression. A transition is enabled and can be taken when its guard is true. A transition is triggered and must be taken when its trigger is true. A transition can contain a set of actions.
When an FSMActor is fired, the outgoing transitions of the current state are examined. An IllegalActionException is thrown if there is more than one enabled transition. If there is exactly one enabled transition then it is chosen and the choice actions contained by the transition are executed. An FSMActor does not change state during successive firings in one iteration in order to support domains that iterate to a fixed point. When the FSMActor is postfired, the chosen transition of the latest firing of the actor is committed. The commit actions contained by the transition are executed and the current state of the actor is set to the destination state of the transition.
An FSMActor enters its initial state during initialization. The name of the initial state is specified by the initialStateName string attribute. When the actor reaches a final state, then the postfire method will return false, indicating that the actor does not wish to be fired again. The finalStateNames string attribute is a comma-separated list of the names of final states.
The guards and actions of FSM transitions are specified using expressions. These expressions are evaluated in the scope returned by getPortScope. This scope binds identifiers for FSM ports as defined in the following paragraph. These identifiers are in the scope of guard and action expressions prior to any variables, and may shadow variables with appropriately chosen names. Given appropriately chosen port names, there may be conflicts between these various identifiers. These conflicts are detected and an exception is thrown during execution.
For every input port, the identifier "portName_channelIndex" refers to the last input received from the port on the given channel. The type of this identifier is the same as the type of the port. This token may have been consumed in the current firing or in a previous firing. The identifier "portName_channelIndex_isPresent" is true if the port consumed an input on the given channel in the current firing of the FSM. The type of this identifier is always boolean. Lastly, the identifier "portName_channelIndexArray" refers the array of all tokens consumed from the port in the last firing. This identifier has an array type whose element type is the type of the corresponding input port. Additionally, for conciseness when referencing single ports, the first channel may be referred to without the channel index, i.e. by the identifiers "portName", "portName_isPresent", and "portNameArray".
An FSMActor can be used in a modal model to represent the mode control logic. A state can have a TypedActor refinement. A transition in an FSMActor can be preemptive or non-preemptive. When a preemptive transition is chosen, the refinement of its source state is not fired. A non-preemptive transition can only be chosen after the refinement of its source state is fired.
State,
Transition,
Action,
FSMDirector,
Serialized Form
| Yellow (kienhuis) |
| Yellow (liuxj) |
| Nested Class Summary |
| Nested classes inherited from class ptolemy.kernel.CompositeEntity |
ptolemy.kernel.CompositeEntity.ContainedObjectsIterator |
| Field Summary | |
protected State |
_currentState
|
protected java.util.Map |
_inputTokenMap
|
protected Transition |
_lastChosenTransition
|
protected boolean |
_stopRequested
Indicator that a stop has been requested by a call to stop(). |
ptolemy.kernel.util.StringAttribute |
finalStateNames
Attribute specifying the names of the final states of this actor. |
ptolemy.kernel.util.StringAttribute |
initialStateName
Attribute specifying the name of the initial state of this actor. |
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
| Fields inherited from interface ptolemy.actor.Executable |
COMPLETED, NOT_READY, STOP_ITERATING |
| Constructor Summary | |
FSMActor()
Construct an FSMActor in the default workspace with an empty string as its name. |
|
FSMActor(ptolemy.kernel.CompositeEntity container,
java.lang.String name)
Create an FSMActor in the specified container with the specified name. |
|
FSMActor(ptolemy.kernel.util.Workspace workspace)
Construct an FSMActor in the specified workspace with an empty string as its name. |
|
| Method Summary | |
protected void |
_addEntity(ptolemy.kernel.ComponentEntity entity)
Add a state to this FSMActor. |
protected void |
_addRelation(ptolemy.kernel.ComponentRelation relation)
Add a transition to this FSMActor. |
protected Transition |
_checkTransition(java.util.List transitionList)
Return the enabled transition among the given list of transitions. |
protected Transition |
_chooseTransition(java.util.List transitionList)
Return the enabled transition among the given list of transitions. |
protected void |
_commitLastChosenTransition()
Execute all commit actions contained by the transition chosen during the last call to _chooseTransition(). |
protected boolean |
_isRefinementOutput(ptolemy.actor.IOPort port,
int channel)
Return true if the channel of the port is connected to an output port of the refinement of current state. |
protected void |
_readInputs()
Set the value of the shadow variables for input ports of this actor. |
protected void |
_readInputs(ptolemy.actor.IOPort port,
int channel)
Read tokens from the given channel of the given input port and make them accessible to the expressions of guards and transitions through the port scope. |
protected void |
_readOutputsFromRefinement()
Set the input variables for channels that are connected to an output port of the refinement of current state. |
protected void |
_setCurrentConnectionMap()
|
void |
attributeChanged(ptolemy.kernel.util.Attribute attribute)
React to a change in an attribute. |
java.lang.Object |
clone(ptolemy.kernel.util.Workspace workspace)
Clone the actor into the specified workspace. |
State |
currentState()
Return the current state of this actor. |
void |
fire()
Set the values of input variables. |
ptolemy.kernel.Entity |
getContext()
Return the change context being made explicit. |
ptolemy.actor.Director |
getDirector()
Return the director responsible for the execution of this actor. |
ptolemy.actor.Director |
getExecutiveDirector()
Return the executive director (same as getDirector()). |
ptolemy.actor.util.FunctionDependency |
getFunctionDependency()
Return an instance of DirectedGraph, where the nodes are IOPorts, and the edges are the relations between ports. |
State |
getInitialState()
Return the initial state of this actor. |
ptolemy.actor.Manager |
getManager()
Return the Manager responsible for execution of this actor, if there is one. |
java.util.List |
getModifiedVariables()
Return a list of variables that this entity modifies. |
ptolemy.data.expr.ParserScope |
getPortScope()
Return a scope object that has current values from input ports of this FSMActor in scope. |
void |
initialize()
Initialize this actor. |
java.util.List |
inputPortList()
Return a list of the input ports. |
boolean |
isOpaque()
Return true. |
int |
iterate(int count)
Invoke a specified number of iterations of the actor. |
ptolemy.kernel.Port |
newPort(java.lang.String name)
Create a new TypedIOPort with the specified name. |
ptolemy.actor.Receiver |
newReceiver()
Return a new receiver obtained from the director. |
ptolemy.kernel.ComponentRelation |
newRelation(java.lang.String name)
Create a new instance of Transition with the specified name in this actor, and return it. |
java.util.List |
outputPortList()
Return a list of the output ports. |
boolean |
postfire()
Execute actions on the last chosen transition. |
boolean |
prefire()
Return true. |
void |
preinitialize()
Create receivers and input variables for the input ports of this actor, and validate attributes of this actor, and attributes of the ports of this actor. |
void |
reset()
Reset current state to the initial state. |
void |
setHDFFSMActor(boolean flag)
Set the HDFFSMActor flag. |
void |
setNewIteration(boolean newIteration)
Set the flag indicating whether we are at the start of a new iteration (firing). |
void |
stop()
Request that execution of the current iteration stop as soon as possible. |
void |
stopFire()
Do nothing. |
void |
terminate()
Call stop(). |
java.util.List |
typeConstraintList()
Return the type constraints of this actor. |
void |
wrapup()
Do nothing. |
| Methods inherited from class ptolemy.kernel.CompositeEntity |
_adjustDeferrals, _description, _exportMoMLContents, _finishedAddEntity, _removeEntity, _removeRelation, allAtomicEntityList, allowLevelCrossingConnect, classDefinitionList, connect, connect, containedObjectsIterator, deepEntityList, deepGetEntities, entityList, entityList, exportLinks, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, numberOfClassDefinitions, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, uniqueName, validateSettables |
| Methods inherited from class ptolemy.kernel.ComponentEntity |
_addPort, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, propagateExistence, setContainer, setName |
| Methods inherited from class ptolemy.kernel.Entity |
_removePort, connectedPortList, connectedPorts, connectionsChanged, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition |
| Methods inherited from class ptolemy.kernel.InstantiableNamedObj |
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition |
| Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, attributeTypeChanged, clone, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, workspace |
| 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, getFullName, getName, getName, setName |
| Methods inherited from interface ptolemy.kernel.util.Derivable |
getDerivedLevel, getDerivedList, propagateValue |
| Field Detail |
public ptolemy.kernel.util.StringAttribute finalStateNames
public ptolemy.kernel.util.StringAttribute initialStateName
protected State _currentState
protected java.util.Map _inputTokenMap
protected Transition _lastChosenTransition
protected boolean _stopRequested
| Constructor Detail |
public FSMActor()
public FSMActor(ptolemy.kernel.util.Workspace workspace)
workspace - The workspace that will list the actor.
public FSMActor(ptolemy.kernel.CompositeEntity container,
java.lang.String name)
throws ptolemy.kernel.util.IllegalActionException,
ptolemy.kernel.util.NameDuplicationException
container - The container.name - The name of this actor within the container.
ptolemy.kernel.util.IllegalActionException - If the entity cannot be contained
by the proposed container.
ptolemy.kernel.util.NameDuplicationException - If the name coincides with
an entity already in the container.| Method Detail |
public void attributeChanged(ptolemy.kernel.util.Attribute attribute)
throws ptolemy.kernel.util.IllegalActionException
attribute - The attribute that changed.
ptolemy.kernel.util.IllegalActionException - If thrown by the superclass
attributeChanged() method.
public java.lang.Object clone(ptolemy.kernel.util.Workspace workspace)
throws java.lang.CloneNotSupportedException
workspace - The workspace for the new actor.
java.lang.CloneNotSupportedException - If a derived class contains
an attribute that cannot be cloned.public State currentState()
public void fire()
throws ptolemy.kernel.util.IllegalActionException
fire in interface ptolemy.actor.Executableptolemy.kernel.util.IllegalActionException - If there is more than one
transition enabled.public ptolemy.kernel.Entity getContext()
getContext in interface ptolemy.actor.util.ExplicitChangeContextpublic ptolemy.actor.Director getDirector()
getDirector in interface ptolemy.actor.Actorpublic ptolemy.actor.Director getExecutiveDirector()
getExecutiveDirector in interface ptolemy.actor.Actor
public State getInitialState()
throws ptolemy.kernel.util.IllegalActionException
ptolemy.kernel.util.IllegalActionException - If this actor does not contain
a state with the specified name.public ptolemy.actor.util.FunctionDependency getFunctionDependency()
getFunctionDependency in interface ptolemy.actor.Actorpublic ptolemy.actor.Manager getManager()
getManager in interface ptolemy.actor.Actor
public java.util.List getModifiedVariables()
throws ptolemy.kernel.util.IllegalActionException
getModifiedVariables in interface ptolemy.actor.util.ExplicitChangeContextptolemy.kernel.util.IllegalActionExceptionpublic ptolemy.data.expr.ParserScope getPortScope()
public void initialize()
throws ptolemy.kernel.util.IllegalActionException
initialize in interface ptolemy.actor.Executableptolemy.kernel.util.IllegalActionException - If a derived class throws it.public java.util.List inputPortList()
inputPortList in interface ptolemy.actor.Actorpublic boolean isOpaque()
public int iterate(int count)
throws ptolemy.kernel.util.IllegalActionException
iterate in interface ptolemy.actor.Executablecount - The number of iterations to perform.
ptolemy.kernel.util.IllegalActionException - If iterating is not
permitted, or if prefire(), fire(), or postfire() throw it.
public ptolemy.kernel.Port newPort(java.lang.String name)
throws ptolemy.kernel.util.NameDuplicationException
name - The name for the new port.
ptolemy.kernel.util.NameDuplicationException - If the actor already has a port
with the specified name.
public ptolemy.actor.Receiver newReceiver()
throws ptolemy.kernel.util.IllegalActionException
newReceiver in interface ptolemy.actor.Actorptolemy.kernel.util.IllegalActionException - If there is no director.
public ptolemy.kernel.ComponentRelation newRelation(java.lang.String name)
throws ptolemy.kernel.util.IllegalActionException,
ptolemy.kernel.util.NameDuplicationException
name - The name of the new transition.
ptolemy.kernel.util.IllegalActionException - If the name argument is null.
ptolemy.kernel.util.NameDuplicationException - If name collides with that
of a transition already in this actor.public java.util.List outputPortList()
outputPortList in interface ptolemy.actor.Actor
public boolean postfire()
throws ptolemy.kernel.util.IllegalActionException
postfire in interface ptolemy.actor.Executableptolemy.kernel.util.IllegalActionException - If any action throws it.
public boolean prefire()
throws ptolemy.kernel.util.IllegalActionException
prefire in interface ptolemy.actor.Executableptolemy.kernel.util.IllegalActionException - Not thrown in this base class.
public void preinitialize()
throws ptolemy.kernel.util.IllegalActionException
preinitialize in interface ptolemy.actor.Executableptolemy.kernel.util.IllegalActionException - If this actor does not contain a
state with name specified by the initialStateName attribute.
public void reset()
throws ptolemy.kernel.util.IllegalActionException
ptolemy.kernel.util.IllegalActionException - If this actor does not
contain a state with name specified by the
initialStateName attribute.public void setHDFFSMActor(boolean flag)
flag - Indicator that whether the FSMActor is under a
HDFFSMDirector.public void setNewIteration(boolean newIteration)
newIteration - public void stop()
stop in interface ptolemy.actor.Executablepublic void stopFire()
stopFire in interface ptolemy.actor.Executablepublic void terminate()
terminate in interface ptolemy.actor.Executablepublic java.util.List typeConstraintList()
typeConstraintList in interface ptolemy.actor.TypedActorInequality
public void wrapup()
throws ptolemy.kernel.util.IllegalActionException
wrapup in interface ptolemy.actor.Executableptolemy.kernel.util.IllegalActionException - Not thrown in this base class.
protected void _addEntity(ptolemy.kernel.ComponentEntity entity)
throws ptolemy.kernel.util.IllegalActionException,
ptolemy.kernel.util.NameDuplicationException
entity - State to contain.
ptolemy.kernel.util.IllegalActionException - If the state has no name, or the
action would result in a recursive containment structure, or the
argument is not an instance of State.
ptolemy.kernel.util.NameDuplicationException - If the name collides with a name
already on the state list.
protected void _addRelation(ptolemy.kernel.ComponentRelation relation)
throws ptolemy.kernel.util.IllegalActionException,
ptolemy.kernel.util.NameDuplicationException
relation - Transition to contain.
ptolemy.kernel.util.IllegalActionException - If the transition has no name, or
is not an instance of Transition.
ptolemy.kernel.util.NameDuplicationException - If the name collides with a name
already on the contained transitions list.
protected Transition _checkTransition(java.util.List transitionList)
throws ptolemy.kernel.util.IllegalActionException
transitionList - A list of transitions.
ptolemy.kernel.util.IllegalActionException - If there is more than one
transition enabled.
protected Transition _chooseTransition(java.util.List transitionList)
throws ptolemy.kernel.util.IllegalActionException
transitionList - A list of transitions.
ptolemy.kernel.util.IllegalActionException - If there is more than one
transition enabled.
protected void _commitLastChosenTransition()
throws ptolemy.kernel.util.IllegalActionException
ptolemy.kernel.util.IllegalActionException - If any commit action throws it,
or the last chosen transition does not have a destination state.
protected boolean _isRefinementOutput(ptolemy.actor.IOPort port,
int channel)
throws ptolemy.kernel.util.IllegalActionException
port - An input port of this actor.channel - A channel of the input port.
ptolemy.kernel.util.IllegalActionException - If the refinement specified for
one of the states is not valid.
protected void _setCurrentConnectionMap()
throws ptolemy.kernel.util.IllegalActionException
ptolemy.kernel.util.IllegalActionException
protected void _readInputs()
throws ptolemy.kernel.util.IllegalActionException
ptolemy.kernel.util.IllegalActionException - If a shadow variable cannot take
the token read from its corresponding channel (should not occur).
protected void _readInputs(ptolemy.actor.IOPort port,
int channel)
throws ptolemy.kernel.util.IllegalActionException
port - An input port of this actor.channel - A channel of the input port.
ptolemy.kernel.util.IllegalActionException - If the port is not contained by
this actor.
protected void _readOutputsFromRefinement()
throws ptolemy.kernel.util.IllegalActionException
ptolemy.kernel.util.IllegalActionException - If a value variable cannot take
the token read from its corresponding channel.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||