Package ptolemy.actor.gt
Class StateMatcher
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity
-
- ptolemy.domains.modal.kernel.State
-
- ptolemy.actor.gt.StateMatcher
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,GTEntity
,Initializable
,TypedActor
,ConfigurableEntity
,Changeable
,Configurable
,Debuggable
,DebugListener
,Derivable
,DropTargetHandler
,Flowable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
,ValueListener
public class StateMatcher extends State implements GTEntity, TypedActor, ValueListener
A matcher to match a state in an FSM controller or an event in a Ptera controller.- Since:
- Ptolemy II 6.1
- Version:
- $Id$
- Author:
- Thomas Huining Feng
- Pt.AcceptedRating:
- Red (tfeng)
- Pt.ProposedRating:
- Yellow (tfeng)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description GTIngredientsAttribute
criteria
The attribute containing all the criteria in a list (GTIngredientList
).GTIngredientsEditor.Factory
editorFactory
The editor factory for ingredients in this matcher.GTIngredientsAttribute
operations
The attribute containing all the operations in a list (GTIngredientList
).PatternObjectAttribute
patternObject
The attribute that specifies the name of the corresponding entity in the pattern.-
Fields inherited from class ptolemy.domains.modal.kernel.State
incomingPort, isFinalState, isInitialState, outgoingPort, refinementName, saveRefinementsInConfigurer
-
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 StateMatcher(CompositeEntity container, java.lang.String name)
Construct a state with the given name contained by the specified composite entity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addInitializable(Initializable initializable)
Do nothing because a state matcher is not supposed to contain any initializable.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.void
createReceivers()
Create receivers for all necessary ports.void
fire()
Do nothing.CausalityInterface
getCausalityInterface()
Return a causality interface for this actor.GTIngredientsAttribute
getCriteriaAttribute()
Return the attribute that stores all the criteria for this matcher.java.lang.String
getDefaultIconDescription()
Return null.Director
getDirector()
Return null.Director
getExecutiveDirector()
Return null.Manager
getManager()
Return null.GTIngredientsAttribute
getOperationsAttribute()
Return the attribute that stores all the operations for this matcher.PatternObjectAttribute
getPatternObjectAttribute()
Return the attribute that stores the name of the corresponding entity in the pattern of the sameTransformationRule
, if this entity is in the replacement, or null otherwise.void
initialize()
Do nothing.java.util.List<?>
inputPortList()
Return an empty list.boolean
isBackwardTypeInferenceEnabled()
Return false because backward type inference is not implemented for this actor.boolean
isFireFunctional()
Return true because prefire and fire do nothing.boolean
isStrict()
Return false.int
iterate(int count)
Do nothing and return 0.java.util.Set<java.lang.String>
labelSet()
Return the set of names of ingredients contained in this entity that can be resolved.boolean
match(NamedObj object)
Return true if the given object is an instance of State (either the one in the deprecated FSM domain or the one in modal model since Ptolemy 8.0).Receiver
newReceiver()
Return null.java.util.List<?>
outputPortList()
Return an empty list.boolean
postfire()
Do nothing and return false.boolean
prefire()
Do nothing and return false.void
preinitialize()
Do nothing.void
removeInitializable(Initializable initializable)
Do nothing.void
setContainer(CompositeEntity container)
Specify the container, adding the entity to the list of entities in the container.void
stop()
Do nothing.void
stopFire()
Do nothing.void
terminate()
Do nothing.java.util.Set<Inequality>
typeConstraints()
Return an empty list.void
updateAppearance(GTIngredientsAttribute attribute)
Update appearance of this entity.void
valueChanged(Settable settable)
React to the fact that the specified Settable has changed.void
wrapup()
Do nothing.-
Methods inherited from class ptolemy.domains.modal.kernel.State
_exportMoMLContents, attributeChanged, configure, dropObject, errorTransitionList, getConfigurer, getConfigureSource, getConfigureText, getIncomingPort, getObjectInRefinement, getOutgoingPort, getRefinement, nonErrorNonTerminationTransitionList, nonpreemptiveTransitionList, preemptiveTransitionList, terminationTransitionList
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, newPort, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _description, _removePort, _validateSettables, connectedPortList, connectedPorts, connectionsChanged, 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, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, 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.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
criteria
public GTIngredientsAttribute criteria
The attribute containing all the criteria in a list (GTIngredientList
).
-
editorFactory
public GTIngredientsEditor.Factory editorFactory
The editor factory for ingredients in this matcher.
-
operations
public GTIngredientsAttribute operations
The attribute containing all the operations in a list (GTIngredientList
).
-
patternObject
public PatternObjectAttribute patternObject
The attribute that specifies the name of the corresponding entity in the pattern.
-
-
Constructor Detail
-
StateMatcher
public StateMatcher(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct a state with the given name contained by the specified composite entity. The container argument must not be null, or a NullPointerException will be thrown. This state 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. Increment the version of the workspace. This constructor write-synchronizes on the workspace.- Parameters:
container
- The container.name
- The name of the state.- Throws:
IllegalActionException
- If the state cannot be contained by the proposed container.NameDuplicationException
- If the name coincides with that of an entity already in the container.
-
-
Method Detail
-
addInitializable
public void addInitializable(Initializable initializable)
Do nothing because a state matcher is not supposed to contain any initializable.- Specified by:
addInitializable
in interfaceInitializable
- Parameters:
initializable
- The initializable.- See Also:
Initializable.removeInitializable(Initializable)
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace. Set a type constraint that the output type is the same as the that of input.- Overrides:
clone
in classState
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class has has an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
createReceivers
public void createReceivers() throws IllegalActionException
Create receivers for all necessary ports. In this implementation no receivers will be created- Specified by:
createReceivers
in interfaceActor
- Throws:
IllegalActionException
- If any port throws it.- See Also:
AtomicActor.createReceivers()
,CompositeActor.createReceivers()
-
fire
public void fire() throws IllegalActionException
Do nothing.- Specified by:
fire
in interfaceExecutable
- Throws:
IllegalActionException
- Not thrown in this class.
-
getCausalityInterface
public CausalityInterface getCausalityInterface()
Return a causality interface for this actor. In this base class, if there is a director, we delegate to the director to return a default causality interface. Otherwise, we return an instance of CausalityInterface with BooleanDependency.OTIMES_IDENTITY as its default. This declares the dependency between input ports and output ports of an actor to be true, the multiplicative identity. If this is called multiple times, the same object is returned each time unless the director has changed since the last call, in which case a new object is returned.- Specified by:
getCausalityInterface
in interfaceActor
- Returns:
- A representation of the dependencies between input ports and output ports.
-
getCriteriaAttribute
public GTIngredientsAttribute getCriteriaAttribute()
Return the attribute that stores all the criteria for this matcher.- Specified by:
getCriteriaAttribute
in interfaceGTEntity
- Returns:
- The attribute that stores all the criteria.
-
getDefaultIconDescription
public java.lang.String getDefaultIconDescription()
Return null.- Specified by:
getDefaultIconDescription
in interfaceGTEntity
- Returns:
- null.
-
getDirector
public Director getDirector()
Return null.- Specified by:
getDirector
in interfaceActor
- Returns:
- null.
-
getExecutiveDirector
public Director getExecutiveDirector()
Return null.- Specified by:
getExecutiveDirector
in interfaceActor
- Returns:
- null.
-
getManager
public Manager getManager()
Return null.- Specified by:
getManager
in interfaceActor
- Returns:
- null.
-
getOperationsAttribute
public GTIngredientsAttribute getOperationsAttribute()
Return the attribute that stores all the operations for this matcher.- Specified by:
getOperationsAttribute
in interfaceGTEntity
- Returns:
- The attribute that stores all the operations.
-
getPatternObjectAttribute
public PatternObjectAttribute getPatternObjectAttribute()
Return the attribute that stores the name of the corresponding entity in the pattern of the sameTransformationRule
, if this entity is in the replacement, or null otherwise.- Specified by:
getPatternObjectAttribute
in interfaceGTEntity
- Returns:
- The attribute that stores the name of the corresponding entity.
- See Also:
labelSet()
-
initialize
public void initialize() throws IllegalActionException
Do nothing.- Specified by:
initialize
in interfaceInitializable
- Throws:
IllegalActionException
- Not thrown in this class.
-
inputPortList
public java.util.List<?> inputPortList()
Return an empty list.- Specified by:
inputPortList
in interfaceActor
- Returns:
- An empty list.
-
isBackwardTypeInferenceEnabled
public boolean isBackwardTypeInferenceEnabled()
Return false because backward type inference is not implemented for this actor.- Specified by:
isBackwardTypeInferenceEnabled
in interfaceTypedActor
- Returns:
- false
-
isFireFunctional
public boolean isFireFunctional()
Return true because prefire and fire do nothing.- Specified by:
isFireFunctional
in interfaceExecutable
- Returns:
- true.
-
isStrict
public boolean isStrict()
Return false.- Specified by:
isStrict
in interfaceExecutable
- Returns:
- false.
-
iterate
public int iterate(int count) throws IllegalActionException
Do nothing and return 0.- Specified by:
iterate
in interfaceExecutable
- Parameters:
count
- The number of iteration.- Returns:
- 0
- Throws:
IllegalActionException
- Not thrown in this class.
-
labelSet
public java.util.Set<java.lang.String> labelSet()
Return the set of names of ingredients contained in this entity that can be resolved.
-
match
public boolean match(NamedObj object)
Return true if the given object is an instance of State (either the one in the deprecated FSM domain or the one in modal model since Ptolemy 8.0).
-
newReceiver
public Receiver newReceiver() throws IllegalActionException
Return null.- Specified by:
newReceiver
in interfaceActor
- Returns:
- null.
- Throws:
IllegalActionException
- Not thrown in this class.
-
outputPortList
public java.util.List<?> outputPortList()
Return an empty list.- Specified by:
outputPortList
in interfaceActor
- Returns:
- An empty list.
-
postfire
public boolean postfire() throws IllegalActionException
Do nothing and return false.- Specified by:
postfire
in interfaceExecutable
- Returns:
- false
- Throws:
IllegalActionException
- Not thrown in this class.
-
prefire
public boolean prefire() throws IllegalActionException
Do nothing and return false.- Specified by:
prefire
in interfaceExecutable
- Returns:
- false
- Throws:
IllegalActionException
- Not thrown in this class.
-
preinitialize
public void preinitialize() throws IllegalActionException
Do nothing.- Specified by:
preinitialize
in interfaceInitializable
- Throws:
IllegalActionException
- Not thrown in this class.
-
removeInitializable
public void removeInitializable(Initializable initializable)
Do nothing.- Specified by:
removeInitializable
in interfaceInitializable
- Parameters:
initializable
- The initializable.- See Also:
Initializable.addInitializable(Initializable)
-
setContainer
public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
Specify the container, adding the entity to the list of entities in the container. If the container already contains an entity with the same name, then throw an exception and do not make any changes. Similarly, if the container is not in the same workspace as this entity, throw an exception. If this entity is a class element and the proposed container does not match the current container, then also throw an exception. If the entity is already contained by the container, do nothing. If this entity already has a container, remove it from that container first. Otherwise, remove it from the directory of the workspace, if it is present. If the argument is null, then unlink the ports of the entity from any relations and remove it from its container. It is not added to the workspace directory, so this could result in this entity being garbage collected. Derived classes may further constrain the container to subclasses of CompositeEntity by overriding the protected method _checkContainer(). This method validates all deeply contained instances of Settable, since they may no longer be valid in the new context. This method is write-synchronized to the workspace and increments its version number.- Overrides:
setContainer
in classComponentEntity
- Parameters:
container
- The proposed container.- Throws:
IllegalActionException
- If the action would result in a recursive containment structure, or if this entity and container are not in the same workspace, or if the protected method _checkContainer() throws it, or if a contained Settable becomes invalid and the error handler throws it.NameDuplicationException
- If the name of this entity collides with a name already in the container.- See Also:
ComponentEntity.getContainer()
-
stop
public void stop()
Do nothing.- Specified by:
stop
in interfaceExecutable
-
stopFire
public void stopFire()
Do nothing.- Specified by:
stopFire
in interfaceExecutable
-
terminate
public void terminate()
Do nothing.- Specified by:
terminate
in interfaceExecutable
-
typeConstraints
public java.util.Set<Inequality> typeConstraints() throws IllegalActionException
Return an empty list.- Specified by:
typeConstraints
in interfaceTypedActor
- Returns:
- An empty list.
- Throws:
IllegalActionException
- Not thrown in this class.- See Also:
Inequality
-
updateAppearance
public void updateAppearance(GTIngredientsAttribute attribute)
Update appearance of this entity.- Specified by:
updateAppearance
in interfaceGTEntity
- Parameters:
attribute
- The attribute containing ingredients of this entity.- See Also:
GTEntityUtils.updateAppearance(GTEntity, GTIngredientsAttribute)
-
valueChanged
public void valueChanged(Settable settable)
React to the fact that the specified Settable has changed.- Specified by:
valueChanged
in interfaceValueListener
- Parameters:
settable
- The object that has changed value.- See Also:
GTEntityUtils.valueChanged(GTEntity, Settable)
-
wrapup
public void wrapup() throws IllegalActionException
Do nothing.- Specified by:
wrapup
in interfaceInitializable
- Throws:
IllegalActionException
- Not thrown in this class.
-
-