public class Transition extends ComponentRelation
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 broadcast 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 history parameter specifies whether the refinement of the destination state refinement is initialized when the transition is taken. By default, this is false, which means that the destination refinement is initialized. If you change this to true, then the destination refinement will not be initialized, so when the state is re-entered, the refinement will continue executing where it left off.
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 immediateTransition parameter, if given a value true, specifies that this transition is may be taken as soon as its source state is entered, in the same iteration. This may lead to transient states, where a state is passed through without ever becoming the current state.
The defaultTransition parameter, if given a value true, specifies that this transition is enabled if no other non-default transition is enabled and if its guard evaluates to true.
The error parameter, if given a value true, specifies that this transition is enabled if the refinement of the source state of the transition throws a model error or an exception while executing. The default value is a boolean token with value false. When such an exception or model error occurs, two variables are set that may be used in the guard or the output or set actions of this transition:
State
,
Action
,
ChoiceAction
,
CommitAction
,
CommitActionsAttribute
,
FSMActor
,
OutputActionsAttribute
Red (hyzheng) |
Yellow (hyzheng) |
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
StringParameter |
annotation
An annotation that describes the transition.
|
Parameter |
defaultTransition
Indicator that this transition is a default transition.
|
Parameter |
error
Parameter specifying whether this transition should be treated
as an error transition.
|
Parameter |
exitAngle
Attribute the exit angle of a visual rendition.
|
Parameter |
fsmTransitionParameterName
The name of the transition, which defaults to the name of
the transition followed by the string "Parameter".
|
Parameter |
gamma
Attribute giving the orientation of a self-loop.
|
StringAttribute |
guardExpression
Attribute specifying the guard expression.
|
Parameter |
history
Parameter specifying whether the refinements of the destination
state are initialized when the transition is taken.
|
Parameter |
immediate
Parameter specifying whether this transition is immediate.
|
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
Deprecated.
Use immediate transitions.
|
CommitActionsAttribute |
setActions
The action commands that set parameters when the transition is taken.
|
Parameter |
showFSMTransitionParameter
True of the the value of the
fsmTransitionParameterName parameter
should be returned by getLabel() . |
Parameter |
termination
Parameter specifying whether the refinements of the origin
state must have terminated (postfire has returned false)
for the transition to be enabled.
|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_checkPort(Port port)
Throw an IllegalActionException if the port cannot be linked
to this transition.
|
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 |
getFullLabel()
Return the full label, which may include the guard expression,
the output expression and the set actions.
|
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,
and false if the guard evaluates to false.
|
boolean |
isEnabled(ParserScope scope)
Return true if the transition is enabled, that is the guard is true,
and false if the guard evaluates to false.
|
boolean |
isErrorTransition()
Return true if this transition is an error transition.
|
boolean |
isHistory()
Return true if this transition is a history transition.
|
boolean |
isImmediate()
Return true if this transition is immediate.
|
boolean |
isNondeterministic()
Return true if this transition is nondeterministic.
|
boolean |
isPreemptive()
Return true if this transition is preemptive.
|
boolean |
isTermination()
Return true if this transition is a termination transition.
|
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 |
setFsmTransitionParameter(FSMTransitionParameter parameter)
Set the FSMTransitionParameter.
|
void |
setGuardExpression(java.lang.String expression)
Set the guard expression.
|
State |
sourceState()
Return the source state of this transition.
|
_checkContainer, _checkRelation, _propagateExistence, deepLinkedPortList, deepLinkedPorts, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, unlinkAll
_description, _getContainedObject, link, linkedObjectsList, linkedPortList, linkedPortList, linkedPorts, linkedPorts, numLinks, relationGroupList, unlink
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
public StringParameter annotation
public Parameter defaultTransition
public Parameter error
public Parameter exitAngle
public Parameter fsmTransitionParameterName
public Parameter gamma
public StringAttribute guardExpression
public Parameter history
public Parameter immediate
public Parameter nondeterministic
public OutputActionsAttribute outputActions
public Parameter preemptive
@Deprecated public StringAttribute refinementName
public CommitActionsAttribute setActions
public Parameter showFSMTransitionParameter
fsmTransitionParameterName
parameter
should be returned by getLabel()
.public Parameter termination
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.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 getFullLabel()
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 default parameter
cannot be evaluated.public boolean isEnabled() throws IllegalActionException
IllegalActionException
- If the guard cannot be evaluated.public boolean isEnabled(ParserScope scope) throws IllegalActionException
scope
- The parser scope in which the guard is to be evaluated.IllegalActionException
- If the guard cannot be evaluated.public boolean isErrorTransition() throws IllegalActionException
IllegalActionException
- If the parameter cannot be evaluated.public boolean isHistory() throws IllegalActionException
IllegalActionException
- If the value of the history parameter
cannot be read.public boolean isImmediate()
public boolean isNondeterministic()
public boolean isTermination() throws IllegalActionException
IllegalActionException
- If the parameter cannot be evaluated.public boolean isPreemptive() throws IllegalActionException
IllegalActionException
- If the parameter cannot be evaluated.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 void setFsmTransitionParameter(FSMTransitionParameter parameter)
parameter
- The parameter.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.