Package ptolemy.domains.modal.kernel
Class AbstractActionsAttribute
- 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
-
- All Implemented Interfaces:
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 eithername
orname(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$
- 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 Modifier and Type Field Description 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.protected ParseTreeEvaluator
_parseTreeEvaluator
The parse tree evaluator.protected java.util.List
_parseTrees
The list of parse trees.-
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 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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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.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.util.List
getDestinations()
Return the list of destinations of assignments in this action.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.lang.String
toString()
Give a descriptive string.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, _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
-
-
-
-
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.
-
-
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 classStringAttribute
- 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 classAction
- 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
- If thrown while evaluating the channel numbers.
-
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.
-
getDestinations
public java.util.List getDestinations() throws IllegalActionException
Return the list of destinations of assignments in this action.- Specified by:
getDestinations
in classAction
- Returns:
- A list of IOPort for output actions, and a list of parameters for set actions.
- Throws:
IllegalActionException
- If the destination list cannot be constructed.
-
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 interfaceSettable
- Overrides:
setExpression
in classStringAttribute
- 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)
-
toString
public java.lang.String toString()
Give a descriptive 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 interfaceHasTypeConstraints
- 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.
-
-