ptolemy.domains.modal.kernel
Class AbstractActionsAttribute

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
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, HasTypeConstraints, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, Settable
Direct Known Subclasses:
ActionsAttribute, CommitActionsAttribute, OutputActionsAttribute

public abstract class AbstractActionsAttribute
extends Action
implements HasTypeConstraints

A base class for actions with semicolon delimited lists of commands.

The value of this attribute is a semicolon separated list of commands, where each command gives a destination to send data to and a value to send. 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 either
 name
 
or
 name(number)
 

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.

Since:
Ptolemy II 8.0
Version:
$Id: AbstractActionsAttribute.java 57044 2010-01-27 22:41:05Z cxh $
Author:
Xiaojun Liu and Edward A. Lee
See Also:
CommitActionsAttribute, Transition, FSMActor, Serialized Form
Accepted Rating:
Red (eal)
Proposed Rating:
Yellow (eal)

Nested Class Summary
private  class AbstractActionsAttribute.TypeFunction
           
 
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
protected  java.util.List _destinationNames
          List of destination names.
protected  java.util.List _destinations
          List of destinations.
protected  long _destinationsListVersion
          The workspace version number when the _destinations list is last updated.
private  java.util.List _numbers
          List of channels.
protected  ParseTreeEvaluator _parseTreeEvaluator
          The parse tree evaluator.
protected  java.util.List _parseTrees
          The list of parse trees.
private  ParserScope _scope
          The scope.
 
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
AbstractActionsAttribute(NamedObj container, java.lang.String name)
          Construct an action with the given name contained by the specified container (which should be a Transition when used in the FSM domain, and an Event in the Ptera domain).
AbstractActionsAttribute(Workspace workspace)
          Construct an action in the specified workspace with an empty string as a name.
 
Method Summary
protected abstract  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 evaluate or type-check this action.
private  void _updateDestinations()
           
 java.lang.Object clone(Workspace workspace)
          Clone the actor into the specified workspace.
 void execute()
          Execute this action.
 java.util.List getChannelNumberList()
          Return the list of channel numbers given in expression set for this attribute.
 NamedObj getDestination(java.lang.String name)
          Return the destination object referred to by the given name.
 java.util.List getDestinationNameList()
          Return the list of destination names given in expression set for this attribute.
 java.lang.String getExpression(java.lang.String name)
          Return the expression referred to by the given name.
 ASTPtRootNode getParseTree(java.lang.String name)
          Return the parse tree referred to by the given name.
 java.util.List getParseTreeList()
          Return the list of parse trees given in expression set for this attribute.
 boolean isChannelSpecified(java.lang.String name)
          Test if a channel number is associated with the given name.
 void setExpression(java.lang.String expression)
          Set the action and notify the container that the action has changed by calling attributeChanged(), and notify any listeners that have been registered using addValueListener().
 java.util.Set<Inequality> typeConstraints()
          Return the type constraints of this object.
 
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
 

Field Detail

_destinationNames

protected java.util.List _destinationNames
List of destination names.


_destinations

protected java.util.List _destinations
List of destinations.


_destinationsListVersion

protected long _destinationsListVersion
The workspace version number when the _destinations list is last updated.


_parseTreeEvaluator

protected ParseTreeEvaluator _parseTreeEvaluator
The parse tree evaluator.


_parseTrees

protected java.util.List _parseTrees
The list of parse trees.


_scope

private ParserScope _scope
The scope.


_numbers

private java.util.List _numbers
List of channels. Elements may be numbers or variable names.

Constructor Detail

AbstractActionsAttribute

public AbstractActionsAttribute(NamedObj container,
                                java.lang.String name)
                         throws IllegalActionException,
                                NameDuplicationException
Construct an action with the given name contained by the specified container (which should be a Transition when used in the FSM domain, and an Event in the Ptera domain). The container argument must not be null, or a NullPointerException will be thrown. This action will use the workspace of the container 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:
container - The container that contains this action.
name - The name of this action.
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.

AbstractActionsAttribute

public AbstractActionsAttribute(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.
Method Detail

clone

public java.lang.Object clone(Workspace workspace)
                       throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace. This calls the base class and then sets the attribute public members to refer to the attributes of the new actor.

Overrides:
clone in class Attribute
Parameters:
workspace - The workspace for the new actor.
Returns:
A new FSMActor.
Throws:
java.lang.CloneNotSupportedException - If a derived class contains an attribute that cannot be cloned.
See Also:
NamedObj.exportMoML(Writer, int, String), NamedObj.setDeferringChangeRequests(boolean)

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. This method should be extended by derived classes to perform the evaluation and assignment as appropriate.

Specified by:
execute in class Action
Throws:
IllegalActionException - If a destination is not found.

getChannelNumberList

public java.util.List getChannelNumberList()
                                    throws IllegalActionException
Return the list of channel numbers given in expression set for this attribute. If no destinations are specified, then return an empty list.

Returns:
the list of channel numbers.
Throws:
IllegalActionException

getDestination

public NamedObj getDestination(java.lang.String name)
                        throws IllegalActionException
Return the destination object referred to by the given name. Depending on the subclass of this class, this might be a variable, or an output port.

Parameters:
name - The name of the destination object.
Returns:
The destination object with the given name.
Throws:
IllegalActionException - If the given name is not a valid destination for this action.

getDestinationNameList

public java.util.List getDestinationNameList()
Return the list of destination names given in expression set for this attribute. If no destinations are specified, then return an empty list.

Returns:
the list of destination names.

getExpression

public java.lang.String getExpression(java.lang.String name)
Return the expression referred to by the given name. When the action is executed, this expression will be evaluated and assigned to the object associated with the name.

Parameters:
name - The name of an expression.
Returns:
The expression referred to by the given name.
See Also:
setExpression(java.lang.String)

getParseTree

public ASTPtRootNode getParseTree(java.lang.String name)
Return the parse tree referred to by the given name.

Parameters:
name - The name of a parse tree.
Returns:
The parse tree referred to by the given name.

getParseTreeList

public java.util.List getParseTreeList()
Return the list of parse trees given in expression set for this attribute. If no destinations are specified, then return an empty list.

Returns:
the list of parse trees.

isChannelSpecified

public boolean isChannelSpecified(java.lang.String name)
Test if a channel number is associated with the given name.

Parameters:
name - The channel name.
Returns:
true If a channel was specified.

setExpression

public void setExpression(java.lang.String expression)
                   throws IllegalActionException
Set the action and notify the container that the action has changed by calling attributeChanged(), and notify any listeners that have been registered using addValueListener().

Specified by:
setExpression in interface Settable
Overrides:
setExpression in class StringAttribute
Parameters:
expression - The action.
Throws:
IllegalActionException - If the change is not acceptable to the container, or if the action is syntactically incorrect.
See Also:
getExpression(java.lang.String)

typeConstraints

public java.util.Set<Inequality> typeConstraints()
Return the type constraints of this object. The constraints are a set of inequalities.

Specified by:
typeConstraints in interface HasTypeConstraints
Returns:
a list of instances of Inequality.
See Also:
Inequality

_getDestination

protected abstract NamedObj _getDestination(java.lang.String name)
                                     throws IllegalActionException
Given a destination name, return a NamedObj that matches that destination. An implementation of this method should never return null (throw an exception instead).

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 evaluate or type-check this action.

Returns:
The parser scope.

_updateDestinations

private void _updateDestinations()
                          throws IllegalActionException
Throws:
IllegalActionException