|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.Relation
ptolemy.kernel.ComponentRelation
ptolemy.domains.fsm.kernel.Transition
public class Transition
A Transition has a source state and a destination state. A transition has a guard expression, which is evaluated to a boolean value. Whenever a transition is enabled, it must be taken immediately. That is, unlike some state machines formalisms, our guard is not just an enabler for the transition but rather a trigger for the transition.
A transition can contain actions. The way to specify actions is to give value to the outputActions parameter and the setActions parameter. The value of these parameters is a string of the form:
command; command; ...where each command has the form:
destination = expressionFor the outputActions parameter, destination is either
portNameor
portName(channelNumber)Here, portName is the name of a port of the FSM actor, If no channelNumber is given, then the value is broadcasted to all channels of the port.
For the setActions parameter, destination is
variableNamevariableName identifies either a variable or parameter of the FSM actor, or a variable or parameter of the refinement of the destination state of the transition. To give a variable of the refinement, use a dotted name, as follows:
refinementName.variableNameThe expression is a string giving an expression in the usual Ptolemy II expression language. The expression may include references to variables and parameters contained by the FSM actor.
The outputActions and setActions parameters are not the only ways to specify actions. In fact, you can add action attributes that are instances of anything that inherits from Action. (Use the Add button in the Edit Parameters dialog).
An action is either a ChoiceAction or a CommitAction. The setActions parameter is a CommitAction, whereas the outputActions parameter is a ChoiceAction. A commit action is executed when the transition is taken to change the state of the FSM, in the postfire() method of FSMActor. A choice action, by contrast, is executed in the fire() method of the FSMActor when the transition is chosen, but not yet taken. The difference is subtle, and for most domains, irrelevant. A few domains, however, such as CT, which have fixed point semantics, where the fire() method may be invoked several times before the transition is taken (committed). For such domains, it is useful to have actions that fulfill the ChoiceAction interface. Such actions participate in the search for a fixed point, but do not change the state of the FSM.
A transition 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 is only chosen after the refinement of its source state is fired.
The reset parameter specifies whether the refinement of the destination state is reset when the transition is taken. There is no reset() method in the Actor interface, so the initialize() method of the refinement is called. Please note that this feature is still under development.
The nondeterministic parameter specifies whether this transition is nondeterministic. Here nondeterministic means that this transition may not be the only enabled transition at a time. The default value is a boolean token with value as false, meaning that if this transition is enabled, it must be the only enabled transition.
The defaultTransition parameter, if given a value true, specifies that this transition is enabled if and only if no other non-default transition is enabled.
State
,
Action
,
ChoiceAction
,
CommitAction
,
CommitActionsAttribute
,
FSMActor
,
OutputActionsAttribute
,
Serialized Form
Red (hyzheng) |
Yellow (hyzheng) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj |
---|
NamedObj.ContainedObjectsIterator |
Field Summary | |
---|---|
private long |
_actionListsVersion
|
private java.util.List |
_choiceActionList
|
private java.util.List |
_commitActionList
|
private State |
_destinationState
|
private ASTPtRootNode |
_guardParseTree
|
private long |
_guardParseTreeVersion
|
private boolean |
_nondeterministic
|
private ParseTreeEvaluator |
_parseTreeEvaluator
|
private long |
_parseTreeEvaluatorVersion
|
private TypedActor[] |
_refinement
|
private long |
_refinementVersion
|
private State |
_sourceState
|
private long |
_stateVersion
|
StringParameter |
annotation
An annotation that describes the transition. |
Parameter |
defaultTransition
Indicator that this transition is a default transition. |
Parameter |
exitAngle
Attribute the exit angle of a visual rendition. |
Parameter |
gamma
Attribute giving the orientation of a self-loop. |
StringAttribute |
guardExpression
Attribute specifying the guard expression. |
Parameter |
nondeterministic
Parameter specifying whether this transition is nondeterministic. |
OutputActionsAttribute |
outputActions
The action commands that produce outputs when the transition is taken. |
Parameter |
preemptive
Parameter specifying whether this transition is preemptive. |
StringAttribute |
refinementName
Attribute specifying one or more names of refinements. |
Parameter |
reset
Parameter specifying whether the refinement of the destination state is reset when the transition is taken. |
CommitActionsAttribute |
setActions
The action commands that set parameters when the transition is taken. |
Fields inherited from class ptolemy.kernel.Relation |
---|
_linkList |
Fields inherited from class ptolemy.kernel.util.NamedObj |
---|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Constructor Summary | |
---|---|
Transition(FSMActor container,
java.lang.String name)
Construct a transition with the given name contained by the specified entity. |
|
Transition(Workspace workspace)
Construct a transition in the given workspace with an empty string as a name. |
Method Summary | |
---|---|
private void |
_checkConnectedStates()
|
protected void |
_checkPort(Port port)
Throw an IllegalActionException if the port cannot be linked to this transition. |
private FSMDirector |
_getDirector()
Return the FSMDirector in charge of this transition, or null if there is none. |
private void |
_init()
|
private void |
_updateActionLists()
|
void |
attributeChanged(Attribute attribute)
React to a change in an attribute. |
java.util.List |
choiceActionList()
Return the list of choice actions contained by this transition. |
java.lang.Object |
clone(Workspace workspace)
Clone the transition into the specified workspace. |
java.util.List |
commitActionList()
Return the list of commit actions contained by this transition. |
State |
destinationState()
Return the destination state of this transition. |
java.lang.String |
getGuardExpression()
Return the guard expression. |
java.lang.String |
getLabel()
Return a string describing this transition. |
ParseTreeEvaluator |
getParseTreeEvaluator()
Return the parse tree evaluator used by this transition to evaluate the guard expression. |
TypedActor[] |
getRefinement()
Return the refinements of this transition. |
boolean |
isDefault()
Return true if this transition is a default transition. |
boolean |
isEnabled()
Return true if the transition is enabled, that is the guard is true, or some event has been detected due to crossing some level. |
boolean |
isEnabled(ParserScope scope)
Return true if the transition is enabled, that is the guard is true, or some event has been detected due to crossing some level. |
boolean |
isNondeterministic()
Return true if this transition is nondeterministic. |
boolean |
isPreemptive()
Return true if this transition is preemptive. |
void |
setContainer(CompositeEntity container)
Override the base class to ensure that the proposed container is an instance of FSMActor or null; if it is null, then remove it from the container, and also remove any refinement(s) that it references that are not referenced by some other transition or state. |
void |
setGuardExpression(java.lang.String expression)
Set the guard expression. |
State |
sourceState()
Return the source state of this transition. |
Methods inherited from class ptolemy.kernel.ComponentRelation |
---|
_checkContainer, _checkRelation, _propagateExistence, deepLinkedPortList, deepLinkedPorts, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, unlinkAll |
Methods inherited from class ptolemy.kernel.Relation |
---|
_description, _getContainedObject, link, linkedObjectsList, linkedPortList, linkedPortList, linkedPorts, linkedPorts, numLinks, relationGroupList, unlink |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public StringParameter annotation
public Parameter defaultTransition
public Parameter exitAngle
public Parameter gamma
public StringAttribute guardExpression
public Parameter nondeterministic
public OutputActionsAttribute outputActions
public Parameter preemptive
public StringAttribute refinementName
public Parameter reset
public CommitActionsAttribute setActions
private long _actionListsVersion
private java.util.List _choiceActionList
private java.util.List _commitActionList
private State _destinationState
private ASTPtRootNode _guardParseTree
private long _guardParseTreeVersion
private boolean _nondeterministic
private ParseTreeEvaluator _parseTreeEvaluator
private long _parseTreeEvaluatorVersion
private TypedActor[] _refinement
private long _refinementVersion
private State _sourceState
private long _stateVersion
Constructor Detail |
---|
public Transition(FSMActor container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of the transition.
IllegalActionException
- If the container is incompatible
with this transition.
NameDuplicationException
- If the name coincides with
any relation already in the container.public Transition(Workspace workspace) throws IllegalActionException, NameDuplicationException
workspace
- The workspace for synchronization and version
tracking.
IllegalActionException
- If the container is incompatible
with this transition.
NameDuplicationException
- If the name coincides with
any relation already in the container.Method Detail |
---|
public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that changed.
IllegalActionException
- If thrown by the superclass
attributeChanged() method, or the changed attribute is the
preemptive parameter and is given an expression that
does not evaluate to a boolean value.public java.util.List choiceActionList()
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class ComponentRelation
workspace
- The workspace for the new transition.
java.lang.CloneNotSupportedException
- If a derived class contains
an attribute that cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public java.util.List commitActionList()
public State destinationState()
public java.lang.String getGuardExpression()
setGuardExpression(java.lang.String)
public java.lang.String getLabel()
public ParseTreeEvaluator getParseTreeEvaluator()
public TypedActor[] getRefinement() throws IllegalActionException
IllegalActionException
- If the specified refinement
cannot be found, or if a comma-separated list is malformed.public boolean isDefault() throws IllegalActionException
IllegalActionException
- If the defaultTransition parameter
cannot be evaluated.public boolean isEnabled() throws IllegalActionException
IllegalActionException
- If thrown when evaluating the guard.public boolean isEnabled(ParserScope scope) throws IllegalActionException
scope
- The parser scope in which the guard is to be evaluated.
IllegalActionException
- If thrown when evaluating the guard.public boolean isNondeterministic()
public boolean isPreemptive()
public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
setContainer
in class ComponentRelation
container
- The proposed container.
IllegalActionException
- If the transition would result
in a recursive containment structure, or if
this transition and container are not in the same workspace, or
if the argument is not a FSMActor or null.
NameDuplicationException
- If the container already has
an relation with the name of this transition.ComponentRelation.getContainer()
public void setGuardExpression(java.lang.String expression)
expression
- The guard expression.getGuardExpression()
public State sourceState()
protected void _checkPort(Port port) throws IllegalActionException
_checkPort
in class ComponentRelation
port
- The port to link to.
IllegalActionException
- If the port cannot be linked
to this transition.private void _checkConnectedStates()
private FSMDirector _getDirector()
private void _init() throws IllegalActionException, NameDuplicationException
IllegalActionException
NameDuplicationException
private void _updateActionLists()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |