ptolemy.domains.ptera.kernel
Class ActionsAttribute

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.kernel.util.AbstractSettableAttribute
              extended by ptolemy.kernel.util.StringAttribute
                  extended by ptolemy.domains.modal.kernel.Action
                      extended by ptolemy.domains.modal.kernel.AbstractActionsAttribute
                          extended by ptolemy.domains.ptera.kernel.ActionsAttribute
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, HasTypeConstraints, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, Settable

public class ActionsAttribute
extends AbstractActionsAttribute

An attribute associated with Ptera events containing executable actions. The actions are written as assignments separated with semicolons. They can be executed either to change the values of the variables assigned to, or to send output tokens to ports.

This class is similar to CommitActionsAttribute and OutputActionsAttribute in FSM. The difference is that in Ptera, no distinction is made between commit actions and output actions. The destination of an assignment can be either a variable or a port. If a port and a variable have the same name in a Ptera model, then assigning to that name causes output to be sent to the port instead of changing the value of the variable.

Another difference between this class and those in FSM is that in Ptera, events are allowed to receive parameters. The parameters can be referred to in the actions associated with that event.

Since:
Ptolemy II 8.0
Version:
$Id: ActionsAttribute.java 57044 2010-01-27 22:41:05Z cxh $
Author:
Thomas Huining Feng
See Also:
CommitActionsAttribute, Serialized Form
Accepted Rating:
Red (tfeng)
Proposed Rating:
Yellow (tfeng)

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, _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
ActionsAttribute(Event event, java.lang.String name)
          Construct an ActionsAttribute for a Ptera event.
ActionsAttribute(Workspace workspace)
          Construct an ActionsAttribute in the specified workspace with an empty string as a name.
 
Method Summary
private  Attribute _getAttribute(NamedObj container, java.lang.String name)
          Get an attribute with the given name in the given container.
protected  NamedObj _getDestination(java.lang.String name)
          Given a destination name, return a NamedObj that matches that destination.
protected  ParserScope _getParserScope()
          Return a parser scope used to type-check the actions.
 void execute()
          Execute this action.
 
Methods inherited from class ptolemy.domains.modal.kernel.AbstractActionsAttribute
clone, getChannelNumberList, getDestination, getDestinationNameList, getExpression, getParseTree, getParseTreeList, isChannelSpecified, setExpression, 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, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, 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, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, 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.Settable
getDisplayName
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getFullName, getName, getName, setName
 

Constructor Detail

ActionsAttribute

public ActionsAttribute(Event event,
                        java.lang.String name)
                 throws IllegalActionException,
                        NameDuplicationException
Construct an ActionsAttribute for a Ptera event.

Parameters:
event - The event.
name - The name of the attribute.
Throws:
IllegalActionException - If the action is not of an acceptable class for the container, or if the name contains a period.
NameDuplicationException - If the container already has an attribute with the name.

ActionsAttribute

public ActionsAttribute(Workspace workspace)
Construct an ActionsAttribute in the specified workspace with an empty string as a name. The attribute is added to the directory of the workspace. Increment the version number of the workspace.

Parameters:
workspace - The workspace that will list the attribute.
Method Detail

execute

public void execute()
             throws IllegalActionException
Execute this action. For each destination identified in the action, compute the value in the action and perform the particular assignment.

Overrides:
execute in class AbstractActionsAttribute
Throws:
IllegalActionException - If a destination is not found or if thrown while evaluating the expressions.

_getDestination

protected NamedObj _getDestination(java.lang.String name)
                            throws IllegalActionException
Given a destination name, return a NamedObj that matches that destination. This method never returns null (throw an exception instead).

Specified by:
_getDestination in class AbstractActionsAttribute
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.

_getParserScope

protected ParserScope _getParserScope()
Return a parser scope used to type-check the actions.

Overrides:
_getParserScope in class AbstractActionsAttribute
Returns:
The parser scope.

_getAttribute

private Attribute _getAttribute(NamedObj container,
                                java.lang.String name)
                         throws IllegalActionException
Get an attribute with the given name in the given container. The attribute name may contain "."-separated parts, in which case entities within the container are searched.

Parameters:
container - The container.
name - The name of the attribute.
Returns:
The attribute if found, or null.
Throws:
IllegalActionException - If error occurs when trying to get an attribute.