|
||||||||||
| 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 |
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(). |
StringAttribute |
finalStateNames
Attribute specifying the names of the final states of this actor. |
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(CompositeEntity container,
java.lang.String name)
Create an FSMActor in the specified container with the specified name. |
|
FSMActor(Workspace workspace)
Construct an FSMActor in the specified workspace with an empty string as its name. |
|
| Method Summary | |
protected void |
_addEntity(ComponentEntity entity)
Add a state to this FSMActor. |
protected void |
_addRelation(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(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(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(Attribute attribute)
React to a change in an attribute. |
java.lang.Object |
clone(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. |
Entity |
getContext()
Return the change context being made explicit. |
Director |
getDirector()
Return the director responsible for the execution of this actor. |
Director |
getExecutiveDirector()
Return the executive director (same as getDirector()). |
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. |
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. |
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. |
Port |
newPort(java.lang.String name)
Create a new TypedIOPort with the specified name. |
Receiver |
newReceiver()
Return a new receiver obtained from the director. |
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.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 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 StringAttribute finalStateNames
public StringAttribute initialStateName
protected State _currentState
protected java.util.Map _inputTokenMap
protected Transition _lastChosenTransition
protected boolean _stopRequested
| Constructor Detail |
public FSMActor()
public FSMActor(Workspace workspace)
workspace - The workspace that will list the actor.
public FSMActor(CompositeEntity container,
java.lang.String name)
throws IllegalActionException,
NameDuplicationException
container - The container.name - The name of this actor within the container.
IllegalActionException - If the entity cannot be contained
by the proposed container.
NameDuplicationException - If the name coincides with
an entity already in the container.| Method Detail |
public void attributeChanged(Attribute attribute)
throws IllegalActionException
attributeChanged in class NamedObjattribute - The attribute that changed.
IllegalActionException - If thrown by the superclass
attributeChanged() method.
public java.lang.Object clone(Workspace workspace)
throws java.lang.CloneNotSupportedException
clone in class CompositeEntityworkspace - 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 IllegalActionException
fire in interface ExecutableIllegalActionException - If there is more than one
transition enabled.public Entity getContext()
getContext in interface ExplicitChangeContextpublic Director getDirector()
getDirector in interface Actorpublic Director getExecutiveDirector()
getExecutiveDirector in interface Actor
public State getInitialState()
throws IllegalActionException
IllegalActionException - If this actor does not contain
a state with the specified name.public FunctionDependency getFunctionDependency()
getFunctionDependency in interface ActorFunctionDependencypublic Manager getManager()
getManager in interface Actor
public java.util.List getModifiedVariables()
throws IllegalActionException
getModifiedVariables in interface ExplicitChangeContextIllegalActionException - If the list of modified
variables cannot be returned.public ParserScope getPortScope()
public void initialize()
throws IllegalActionException
initialize in interface ExecutableIllegalActionException - If a derived class throws it.public java.util.List inputPortList()
inputPortList in interface Actorpublic boolean isOpaque()
isOpaque in class CompositeEntityCompositeEntity
public int iterate(int count)
throws IllegalActionException
iterate in interface Executablecount - The number of iterations to perform.
IllegalActionException - If iterating is not
permitted, or if prefire(), fire(), or postfire() throw it.
public Port newPort(java.lang.String name)
throws NameDuplicationException
newPort in class ComponentEntityname - 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 ActorIllegalActionException - If there is no director.
public ComponentRelation newRelation(java.lang.String name)
throws IllegalActionException,
NameDuplicationException
newRelation in class CompositeEntityname - The name of the new transition.
IllegalActionException - If the name argument is null.
NameDuplicationException - If name collides with that
of a transition already in this actor.public java.util.List outputPortList()
outputPortList in interface Actor
public boolean postfire()
throws IllegalActionException
postfire in interface ExecutableIllegalActionException - If any action throws it.
public boolean prefire()
throws IllegalActionException
prefire in interface ExecutableIllegalActionException - Not thrown in this base class.
public void preinitialize()
throws IllegalActionException
preinitialize in interface ExecutableIllegalActionException - If this actor does not contain a
state with name specified by the initialStateName attribute.
public void reset()
throws IllegalActionException
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 Executablepublic void stopFire()
stopFire in interface Executablepublic void terminate()
terminate in interface Executablepublic java.util.List typeConstraintList()
typeConstraintList in interface TypedActorInequality
public void wrapup()
throws IllegalActionException
wrapup in interface ExecutableIllegalActionException - Not thrown in this base class.
protected void _addEntity(ComponentEntity entity)
throws IllegalActionException,
NameDuplicationException
_addEntity in class CompositeEntityentity - State to contain.
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.
NameDuplicationException - If the name collides with a name
already on the state list.
protected void _addRelation(ComponentRelation relation)
throws IllegalActionException,
NameDuplicationException
_addRelation in class CompositeEntityrelation - Transition to contain.
IllegalActionException - If the transition has no name, or
is not an instance of Transition.
NameDuplicationException - If the name collides with a name
already on the contained transitions list.
protected Transition _checkTransition(java.util.List transitionList)
throws IllegalActionException
transitionList - A list of transitions.
IllegalActionException - If there is more than one
transition enabled.
protected Transition _chooseTransition(java.util.List transitionList)
throws IllegalActionException
transitionList - A list of transitions.
IllegalActionException - If there is more than one
transition enabled.
protected void _commitLastChosenTransition()
throws IllegalActionException
IllegalActionException - If any commit action throws it,
or the last chosen transition does not have a destination state.
protected boolean _isRefinementOutput(IOPort port,
int channel)
throws IllegalActionException
port - An input port of this actor.channel - A channel of the input port.
IllegalActionException - If the refinement specified for
one of the states is not valid.
protected void _setCurrentConnectionMap()
throws IllegalActionException
IllegalActionException
protected void _readInputs()
throws IllegalActionException
IllegalActionException - If a shadow variable cannot take
the token read from its corresponding channel (should not occur).
protected void _readInputs(IOPort port,
int channel)
throws IllegalActionException
port - An input port of this actor.channel - A channel of the input port.
IllegalActionException - If the port is not contained by
this actor.
protected void _readOutputsFromRefinement()
throws IllegalActionException
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 | |||||||||