Package ptolemy.domains.modal.kernel
Class CommitActionsAttribute
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.kernel.util.AbstractSettableAttribute
-
- ptolemy.kernel.util.StringAttribute
-
- ptolemy.domains.modal.kernel.Action
-
- ptolemy.domains.modal.kernel.AbstractActionsAttribute
-
- ptolemy.domains.modal.kernel.CommitActionsAttribute
-
- All Implemented Interfaces:
java.lang.Cloneable
,HasTypeConstraints
,CommitAction
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
,Settable
public class CommitActionsAttribute extends AbstractActionsAttribute implements CommitAction
An action that changes the state of the system. Typical commit actions set variables either in the containing FSMActor or in a state refinement. This action is contained by a transition, and is evaluated whenever that transition is taken. The evaluation is done in the postfire() method of the FSMActor that contains the transition (hereafter called "the FSM actor"). To specify an action that is executed earlier, in the fire() method, when the transition is enabled rather than taken, use the class OutputActionsAttribute.The value of this attribute is a semicolon separated list of commands, where each command gives a destination and a value. The actions are given by calling setExpression() with a string of the form:
command; command; ...
where each command has the form:destination = expression
where destination is variableName, where variableName is either a variable or parameter of the FSM actor, or a variable or parameter of a refinement state. To give a variable of a refinement state, use a dotted name, as follows:refinementStateName.variableName
The 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 destination can also be a port, however, this is discouraged. Commit actions are not executed until postfire(), and the Ptolemy II abstract semantics requires that outputs be produced in fire(). Nonetheless, this is supported. In this case, the destination is either
portName
orportName(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. If destination name is given where there is both a port and a variable with that name, then the port will be used.- Since:
- Ptolemy II 8.0
- Version:
- $Id$
- Author:
- Xiaojun Liu and Edward A. Lee
- See Also:
CommitActionsAttribute
,Transition
,FSMActor
- Pt.AcceptedRating:
- Red (eal)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
Nested classes/interfaces inherited from interface ptolemy.kernel.util.Settable
Settable.Visibility
-
-
Field Summary
-
Fields inherited from class ptolemy.domains.modal.kernel.AbstractActionsAttribute
_destinationNames, _destinations, _destinationsListVersion, _parseTreeEvaluator, _parseTrees
-
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.kernel.util.Settable
EXPERT, FULL, NONE, NOT_EDITABLE
-
-
Constructor Summary
Constructors Constructor Description CommitActionsAttribute(Transition transition, java.lang.String name)
Construct an action with the given name contained by the specified transition.CommitActionsAttribute(Workspace workspace)
Construct an action in the specified workspace with an empty string as a name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected NamedObj
_getDestination(java.lang.String name)
Given a destination name, return a NamedObj that matches that destination.void
execute()
Send tokens to the designated outputs.-
Methods inherited from class ptolemy.domains.modal.kernel.AbstractActionsAttribute
_getParserScope, clone, getChannelNumberList, getDestination, getDestinationNameList, getDestinations, getExpression, getParseTree, getParseTreeList, isChannelSpecified, setExpression, toString, typeConstraints
-
Methods inherited from class ptolemy.domains.modal.kernel.Action
setContainer
-
Methods inherited from class ptolemy.kernel.util.StringAttribute
_propagateValue, addValueListener, exportMoML, getExpression, getVisibility, removeValueListener, setVisibility, validate
-
Methods inherited from class ptolemy.kernel.util.AbstractSettableAttribute
getDefaultExpression, getValueAsString
-
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, 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, uniqueName, validateSettables, 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.Settable
getDisplayName
-
-
-
-
Constructor Detail
-
CommitActionsAttribute
public CommitActionsAttribute(Workspace workspace)
Construct an action in the specified workspace with an empty string as a name. The object is added to the directory of the workspace. Increment the version number of the workspace.- Parameters:
workspace
- The workspace that will list the attribute.
-
CommitActionsAttribute
public CommitActionsAttribute(Transition transition, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct an action with the given name contained by the specified transition. The transition argument must not be null, or a NullPointerException will be thrown. This action will use the workspace of the transition for synchronization and version counts. If the name argument is null, then the name is set to the empty string. This increments the version of the workspace.- Parameters:
transition
- The transition that contains this action.name
- The name of this action.- Throws:
IllegalActionException
- If the action is not of an acceptable class for the container.NameDuplicationException
- If the transition already has an attribute with the name.
-
-
Method Detail
-
execute
public void execute() throws IllegalActionException
Send tokens to the designated outputs. Each token is determined by evaluating the expression portion of the action.- Overrides:
execute
in classAbstractActionsAttribute
- Throws:
IllegalActionException
- If expression evaluation fails, or the specified port is not found, or sending to one of the channels of the port throws a NoRoomException.
-
_getDestination
protected NamedObj _getDestination(java.lang.String name) throws IllegalActionException
Given a destination name, return a NamedObj that matches that destination.- Specified by:
_getDestination
in classAbstractActionsAttribute
- Parameters:
name
- The name of the destination, or null if none is found.- Returns:
- An object (like a port or a variable) with the specified name.
- Throws:
IllegalActionException
- If the associated FSMActor does not have a destination with the specified name.
-
-