ptolemy.domains.fsm.kernel
Class AbstractActionsAttribute

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.util.Attribute
          extended byptolemy.kernel.util.AbstractSettableAttribute
              extended byptolemy.kernel.util.StringAttribute
                  extended byptolemy.domains.fsm.kernel.Action
                      extended byptolemy.domains.fsm.kernel.AbstractActionsAttribute
All Implemented Interfaces:
ptolemy.kernel.util.Changeable, java.lang.Cloneable, ptolemy.kernel.util.Debuggable, ptolemy.kernel.util.DebugListener, ptolemy.kernel.util.Derivable, ptolemy.data.type.HasTypeConstraints, ptolemy.kernel.util.ModelErrorHandler, ptolemy.kernel.util.MoMLExportable, ptolemy.kernel.util.Nameable, java.io.Serializable, ptolemy.kernel.util.Settable
Direct Known Subclasses:
CommitActionsAttribute, OutputActionsAttribute

public abstract class AbstractActionsAttribute
extends Action
implements ptolemy.data.type.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 1.0
Version:
$Id: AbstractActionsAttribute.java,v 1.43 2004/04/13 05:12:56 cxh Exp $
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
 
Nested classes inherited from class ptolemy.kernel.util.NamedObj
ptolemy.kernel.util.NamedObj.ContainedObjectsIterator
 
Nested classes inherited from class ptolemy.kernel.util.Settable
ptolemy.kernel.util.Settable.Visibility
 
Field Summary
protected  java.util.List _destinationNames
           
protected  java.util.List _destinations
           
protected  long _destinationsListVersion
           
protected  java.util.List _numbers
           
protected  ptolemy.data.expr.ParseTreeEvaluator _parseTreeEvaluator
           
protected  java.util.List _parseTrees
           
protected  ptolemy.data.expr.ParserScope _scope
           
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.kernel.util.Settable
EXPERT, FULL, NONE, NOT_EDITABLE
 
Constructor Summary
AbstractActionsAttribute(Transition transition, java.lang.String name)
          Construct an action with the given name contained by the specified transition.
AbstractActionsAttribute(ptolemy.kernel.util.Workspace workspace)
          Construct an action in the specified workspace with an empty string as a name.
 
Method Summary
protected abstract  ptolemy.kernel.util.NamedObj _getDestination(java.lang.String name)
          Given a destination name, return a NamedObj that matches that destination.
 void execute()
          Execute this action.
 int getChannel(java.lang.String name)
          Return the channel number associated with the given name, assuming that the destination is a port object.
 ptolemy.kernel.util.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.
 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.List typeConstraintList()
          Return the type constraints of this object.
 
Methods inherited from class ptolemy.domains.fsm.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
 
Methods inherited from class ptolemy.kernel.util.Attribute
_getContainedObject, _propagateExistence, clone, getContainer, setName
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, 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.Nameable
description, getContainer, getFullName, getName, getName, setName
 

Field Detail

_numbers

protected java.util.List _numbers

_destinations

protected java.util.List _destinations

_destinationNames

protected java.util.List _destinationNames

_destinationsListVersion

protected long _destinationsListVersion

_parseTrees

protected java.util.List _parseTrees

_parseTreeEvaluator

protected ptolemy.data.expr.ParseTreeEvaluator _parseTreeEvaluator

_scope

protected ptolemy.data.expr.ParserScope _scope
Constructor Detail

AbstractActionsAttribute

public AbstractActionsAttribute(ptolemy.kernel.util.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.

AbstractActionsAttribute

public AbstractActionsAttribute(Transition transition,
                                java.lang.String name)
                         throws ptolemy.kernel.util.IllegalActionException,
                                ptolemy.kernel.util.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:
ptolemy.kernel.util.IllegalActionException - If the action is not of an acceptable class for the container, or if the name contains a period.
ptolemy.kernel.util.NameDuplicationException - If the transition already has an attribute with the name.
Method Detail

execute

public void execute()
             throws ptolemy.kernel.util.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:
ptolemy.kernel.util.IllegalActionException - If a destination is not found.

getChannel

public int getChannel(java.lang.String name)
               throws ptolemy.kernel.util.IllegalActionException
Return the channel number associated with the given name, assuming that the destination is a port object.

Throws:
ptolemy.kernel.util.IllegalActionException - If the name does not refer to a port, or a channel has not been specified for the name.

getDestination

public ptolemy.kernel.util.NamedObj getDestination(java.lang.String name)
                                            throws ptolemy.kernel.util.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.

Throws:
ptolemy.kernel.util.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.


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.


isChannelSpecified

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

Returns:
true If a channel was specified.

setExpression

public void setExpression(java.lang.String expression)
                   throws ptolemy.kernel.util.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 ptolemy.kernel.util.Settable
Parameters:
expression - The action.
Throws:
ptolemy.kernel.util.IllegalActionException - If the change is not acceptable to the container, or if the action is syntactically incorrect.

typeConstraintList

public java.util.List typeConstraintList()
Return the type constraints of this object. The constraints are a list of inequalities.

Specified by:
typeConstraintList in interface ptolemy.data.type.HasTypeConstraints
Returns:
a list of instances of Inequality.
See Also:
Inequality

_getDestination

protected abstract ptolemy.kernel.util.NamedObj _getDestination(java.lang.String name)
                                                         throws ptolemy.kernel.util.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:
ptolemy.kernel.util.IllegalActionException - If the associated FSMActor does not have a destination with the specified name.