Package ptolemy.domains.sequence.lib
Class SequencedSharedMemoryActor
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity<T>
-
- ptolemy.actor.AtomicActor<TypedIOPort>
-
- ptolemy.actor.TypedAtomicActor
-
- ptolemy.actor.lib.SetVariable
-
- ptolemy.domains.sequence.lib.SequencedSharedMemoryActor
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,ExplicitChangeContext
,Changeable
,ChangeListener
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
BaseMultipleMethodsActor
,SequencedVariable
public abstract class SequencedSharedMemoryActor extends SetVariable
A base class for shared memory actors in the sequence domain. This class should not itself be instantiated, so it is an abstract class. This class builds on SetVariable in the following ways: - Supports an additional parameter to store the initial value - Calculates the name of the variable, and the initial value parameter, according to the name of the actor - Additional features for creating the variables in the proper scope- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Elizabeth Latronico
- Pt.AcceptedRating:
- Red (beth)
- Pt.ProposedRating:
- Red (beth)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected ptolemy.domains.sequence.lib.SequencedSharedMemoryActor.Scope
_scope
The scope of the actor.protected java.lang.String
_sharedName
The name shared by a set of messages.StringAttribute
initialVariableName
The name of the initial value variable in the container to set.-
Fields inherited from class ptolemy.actor.lib.SetVariable
delayed, input, output, variableName
-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
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.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description SequencedSharedMemoryActor(CompositeEntity container, java.lang.String name)
Create a new SequencedSharedMemoryActor with the given name and container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Token
_getDefaultValue()
Supplies a default value for the variable, in the case that there is no initial value.protected void
_setValue(Attribute variable, java.lang.String value)
Set the value of the associated container's variable.protected void
_setValue(Attribute variable, Token value)
Set the value of the associated container's variable.void
checkForAttributes()
Check to see if the parameters exist in the workspace.void
checkForAttributes(Token value1, Token value2)
Check to see if both the variable and initial value variable exist.void
fire()
Fire the SequencedSharedMemoryActor.Variable
getInitialVariable()
Return the initial variable.java.lang.String
getInitialVariableName()
Returns the initial variable's name.Attribute
getModifiedVariable()
From superclass.Variable
getModifiedVariable(java.lang.String name)
Similar to superclass getModifiedVariable(), but takes a name as an argument and does not used cached variables, and checks only in the proper scope.java.lang.String
getSharedName()
Return the sharedName.Variable
getVariable()
Return the modified variable.java.lang.String
getVariableName()
Returns the variable's name.void
preinitialize()
Set up the type constraint between the output and the variable and the output and the initial value variable.void
setName(java.lang.String name)
When the actor name is changed, update the referenced variables to point to the new parameters and check to see if these parameters exist.-
Methods inherited from class ptolemy.actor.lib.SetVariable
_customTypeConstraints, changeExecuted, changeFailed, clone, getContext, getModifiedVariables, postfire
-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, prefire, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, initialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName
-
-
-
-
Field Detail
-
initialVariableName
public StringAttribute initialVariableName
The name of the initial value variable in the container to set.
-
_sharedName
protected java.lang.String _sharedName
The name shared by a set of messages. This is not directly settable by the user; rather, it is derived from the actor name.
-
_scope
protected ptolemy.domains.sequence.lib.SequencedSharedMemoryActor.Scope _scope
The scope of the actor. See enumeration above. Global by default.
-
-
Constructor Detail
-
SequencedSharedMemoryActor
public SequencedSharedMemoryActor(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Create a new SequencedSharedMemoryActor with the given name and container.- Parameters:
container
- The container for the new actor.name
- The name of the new actor.- Throws:
NameDuplicationException
- Thrown if the chosen name matches the name of an already existing actor in the model.IllegalActionException
- Thrown if there is a problem instantiating the actor.
-
-
Method Detail
-
checkForAttributes
public void checkForAttributes() throws IllegalActionException
Check to see if the parameters exist in the workspace. Similar to SetVariable getAttribute(). If not, create them, and assign them a null token. This is needed for (for example) when the actor is dragged and dropped from the menu, since the parameters will be created but do not have any user defined values. Subclasses can override this method, or can use checkForVariables(Token) FIXME Any way to get these to display to the user?- Throws:
IllegalActionException
- If there is a problem with the attributes.
-
checkForAttributes
public void checkForAttributes(Token value1, Token value2) throws IllegalActionException
Check to see if both the variable and initial value variable exist. If not, create them, and set their tokens to the arguments.- Parameters:
value1
- The value to assign to the variable.value2
- The value to assign to the initial value variable.- Throws:
IllegalActionException
- If the attributes cannot be created.
-
fire
public void fire() throws IllegalActionException
Fire the SequencedSharedMemoryActor. If the input is not connected, do not try to read a value from it. It is OK not to read any value, since SequencedSharedMemoryActors always have an initial value.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classSetVariable
- Throws:
IllegalActionException
- If the actor cannot be fired.
-
getInitialVariable
public Variable getInitialVariable() throws IllegalActionException
Return the initial variable. Create it if it's not present.- Returns:
- The initial variable. Returns null if the variable name is not assigned or is the empty string.
- Throws:
IllegalActionException
- If the variable cannot be found.
-
getInitialVariableName
public java.lang.String getInitialVariableName()
Returns the initial variable's name.- Returns:
- The initial variable name.
-
getModifiedVariable
public Attribute getModifiedVariable() throws IllegalActionException
From superclass. Overridden to return checkSingleVariable for the variable (i.e. not the initial value variable). This will create the variable if not present.- Overrides:
getModifiedVariable
in classSetVariable
- Returns:
- The attribute that was found or created.
- Throws:
IllegalActionException
- If the container is null, or the name is invalid (from checkSingleAttribute).
-
getModifiedVariable
public Variable getModifiedVariable(java.lang.String name) throws IllegalActionException
Similar to superclass getModifiedVariable(), but takes a name as an argument and does not used cached variables, and checks only in the proper scope. Also, it returns a variable (not an attribute). This makes more sense but is inconsistent with superclass function. Subclasses should use this function. Also, uses the default value if the variable is created.- Parameters:
name
- The name of the variable to get.- Returns:
- The attribute that was found or created
- Throws:
IllegalActionException
- If the container is null, or the name is invalid (from checkSingleAttribute)
-
getSharedName
public java.lang.String getSharedName()
Return the sharedName.- Returns:
- Name shared by set of messages
-
getVariable
public Variable getVariable() throws IllegalActionException
Return the modified variable. Create it if it's not present. Different from getModifiedVariable, in that it returns a Variable, not an attribute.- Returns:
- The modified variable. Returns null if the variable name is not assigned or is the empty string.
- Throws:
IllegalActionException
- If there is a problem with the variable referenced by this actor.
-
getVariableName
public java.lang.String getVariableName()
Returns the variable's name.- Returns:
- The variable name.
-
preinitialize
public void preinitialize() throws IllegalActionException
Set up the type constraint between the output and the variable and the output and the initial value variable.- Specified by:
preinitialize
in interfaceInitializable
- Overrides:
preinitialize
in classSetVariable
- Throws:
IllegalActionException
- If the actor cannot be preinitialized.
-
setName
public void setName(java.lang.String name) throws IllegalActionException, NameDuplicationException
When the actor name is changed, update the referenced variables to point to the new parameters and check to see if these parameters exist. This is also called when the actor is created, so don't need it in constructor. Previously, the code for the ASCETArray would allow direct changes in the variable name, in attributeChanged(). This is no longer allowed. The user should change the name of the actor; then, the variable name change will follow.- Specified by:
setName
in interfaceNameable
- Overrides:
setName
in classComponentEntity<TypedIOPort>
- Parameters:
name
- The new name of the actor- Throws:
IllegalActionException
- If the name cannot be changed.NameDuplicationException
- If there is another actor with the same name in the actor's container- See Also:
NamedObj.getName()
,NamedObj.getName(NamedObj)
-
_getDefaultValue
protected Token _getDefaultValue() throws IllegalActionException
Supplies a default value for the variable, in the case that there is no initial value. Subclasses should override getDefaultValue() to return an appropriate token. If there is no appropriate token, the actor should throw an exception stating that a default value is required.- Returns:
- A token containing the default value
- Throws:
IllegalActionException
- Subclasses should throw an exception if an explicit initial value is required.
-
_setValue
protected void _setValue(Attribute variable, java.lang.String value) throws IllegalActionException
Set the value of the associated container's variable. Added a name here, to set the variable with this name. Override base class function, since the base class function does not set the value if the tokens are equal. This causes problems for the token solver.- Parameters:
variable
- The variable whose value will be set.value
- The new value as a string.- Throws:
IllegalActionException
- If the variable cannot be set.
-
_setValue
protected void _setValue(Attribute variable, Token value) throws IllegalActionException
Set the value of the associated container's variable. Added a name here, to set the variable with this name. Override base class function, since the base class function does not set the value if the tokens are equal. This causes problems for the token solver.- Parameters:
variable
- The variable whose value will be set.value
- The new value as a token.- Throws:
IllegalActionException
- If the variable cannot be set.
-
-