ptolemy.domains.fsm.kernel
Class State

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.InstantiableNamedObj
          extended byptolemy.kernel.Entity
              extended byptolemy.kernel.ComponentEntity
                  extended byptolemy.domains.fsm.kernel.State
All Implemented Interfaces:
Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable

public class State
extends ComponentEntity

A State has two ports: one for linking incoming transitions, the other for outgoing transitions. When the FSMActor containing a state is the mode controller of a modal model, the state can be refined by one or more instances of TypedActor. The refinements must have the same container as the FSMActor. During execution of a modal model, only the mode controller and the refinements of the current state of the mode controller react to input to the modal model and produce output. The outgoing transitions from a state are either preemptive or non-preemptive. When a modal model is fired, if a preemptive transition from the current state of the mode controller is chosen, the refinements of the current state are not fired. Otherwise the refinements are fired before choosing a non-preemptive transition.

Since:
Ptolemy II 0.4
Version:
$Id: State.java,v 1.46 2004/04/13 05:12:55 cxh Exp $
Author:
Xiaojun Liu
See Also:
Transition, FSMActor, FSMDirector, Serialized Form
Accepted Rating:
Yellow (kienhuis)
Proposed Rating:
Yellow (liuxj)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
 ComponentPort incomingPort
          The port linking incoming transitions.
 ComponentPort outgoingPort
          The port linking outgoing transitions.
 StringAttribute refinementName
          Attribute specifying one or more names of refinements.
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
State(CompositeEntity container, java.lang.String name)
          Construct a state with the given name contained by the specified composite entity.
 
Method Summary
 void attributeChanged(Attribute attribute)
          React to a change in an attribute.
 java.lang.Object clone(Workspace workspace)
          Clone the state into the specified workspace.
 TypedActor[] getRefinement()
          Return the refinements of this state.
 java.util.List nonpreemptiveTransitionList()
          Return the list of non-preemptive outgoing transitions from this state.
 java.util.List preemptiveTransitionList()
          Return the list of preemptive outgoing transitions from this state.
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_addPort, _adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, newPort, propagateExistence, setContainer, setName
 
Methods inherited from class ptolemy.kernel.Entity
_description, _exportMoMLContents, _removePort, connectedPortList, connectedPorts, connectionsChanged, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName, validateSettables
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, attributeTypeChanged, clone, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, 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, getFullName, getName, getName
 

Field Detail

incomingPort

public ComponentPort incomingPort
The port linking incoming transitions.


outgoingPort

public ComponentPort outgoingPort
The port linking outgoing transitions.


refinementName

public StringAttribute refinementName
Attribute specifying one or more names of refinements. The refinements must be instances of TypedActor and have the same container as the FSMActor containing this state, otherwise an exception will be thrown when getRefinement() is called. Usually, the refinement is a single name. However, if a comma-separated list of names is provided, then all the specified refinements will be executed. This attribute has a null expression or a null string as expression when the state is not refined.

Constructor Detail

State

public State(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

attributeChanged

public void attributeChanged(Attribute attribute)
                      throws IllegalActionException
React to a change in an attribute. If the changed attribute is the refinementName attribute, record the change but do not check whether there is a TypedActor with the specified name and having the same container as the FSMActor containing this state.

Overrides:
attributeChanged in class NamedObj
Parameters:
attribute - The attribute that changed.
Throws:
IllegalActionException - If thrown by the superclass attributeChanged() method.

clone

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

Overrides:
clone in class ComponentEntity
Parameters:
workspace - The workspace for the new state.
Returns:
A new state.
Throws:
java.lang.CloneNotSupportedException - If a derived class contains an attribute that cannot be cloned.

getRefinement

public TypedActor[] getRefinement()
                           throws IllegalActionException
Return the refinements of this state. The names of the refinements are specified by the refinementName attribute. The refinements must be instances of TypedActor and have the same container as the FSMActor containing this state, otherwise an exception is thrown. This method can also return null if there is no refinement. This method is read-synchronized on the workspace.

Returns:
The refinements of this state, or null if there are none.
Throws:
IllegalActionException - If the specified refinement cannot be found, or if a comma-separated list is malformed.

nonpreemptiveTransitionList

public java.util.List nonpreemptiveTransitionList()
Return the list of non-preemptive outgoing transitions from this state.

Returns:
The list of non-preemptive outgoing transitions from this state.

preemptiveTransitionList

public java.util.List preemptiveTransitionList()
Return the list of preemptive outgoing transitions from this state.

Returns:
The list of preemptive outgoing transitions from this state.