ptolemy.domains.fsm.modal
Class ModalController

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.InstantiableNamedObj
          extended by ptolemy.kernel.Entity
              extended by ptolemy.kernel.ComponentEntity
                  extended by ptolemy.kernel.CompositeEntity
                      extended by ptolemy.domains.fsm.kernel.FSMActor
                          extended by ptolemy.domains.fsm.modal.ModalController
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, Initializable, TypedActor, ExplicitChangeContext, RefinementActor, Changeable, Debuggable, DebugListener, Derivable, DropTargetHandler, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class ModalController
extends FSMActor
implements DropTargetHandler, RefinementActor

This FSM actor supports mirroring of its ports in its container (which is required to be a ModalModel), which in turn assures mirroring of ports in each of the refinements.

Note that this actor has no attributes of its own. Requests for attributes are delegated to the container.

Since:
Ptolemy II 2.0
Version:
$Id: ModalController.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Red (reviewmoderator)
Proposed Rating:
Red (eal)

Nested Class Summary
private static class ModalController.ClassComparator
          A comparator to compare classes, which is used to sort the map returned by _getRefinementClasses().
 
Nested classes/interfaces inherited from class ptolemy.domains.fsm.kernel.FSMActor
FSMActor.PortScope
 
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
 
Field Summary
protected  boolean _mirrorDisable
          Indicator that we are processing a newPort request.
 
Fields inherited from class ptolemy.domains.fsm.kernel.FSMActor
_currentState, _identifierToPort, _initializables, _inputTokenMap, _lastChosenTransition, _stopRequested, finalStateNames, initialStateName, stateDependentCausality
 
Fields inherited from class ptolemy.kernel.CompositeEntity
_levelCrossingLinks
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _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
ModalController(CompositeEntity container, java.lang.String name)
          Construct a modal controller with a name and a container.
ModalController(Workspace workspace)
          Construct a modal controller in the specified workspace with no container and an empty string as a name.
 
Method Summary
protected  void _checkContainer(Entity container)
          Override the base class to ensure that the proposed container is a ModalModel or null.
protected  java.util.TreeMap<java.lang.Class<? extends Entity>,java.lang.String> _getRefinementClasses()
          Return a map from the classes of the entities to be dropped into a state and the class names of the refinements that can be used to contain those entities.
 void addRefinement(State state, java.lang.String name, Entity template, java.lang.String className, Configuration configuration)
          Create a refinement for the given state.
 void dropObject(NamedObj target, java.util.List dropObjects, java.lang.String moml)
          React to a list of objects being dropped onto a target.
 State getRefinedState()
          Get the state in any ModalController within this ModalModel that has this ModalController as its refinement, if any.
 Port newPort(java.lang.String name)
          Create a new port with the specified name in the container of this controller, which in turn creates a port in this controller and all the refinements.
 void setMirrorDisable(boolean disable)
          Control whether adding a port should be mirrored in the modal model and refinements.
 
Methods inherited from class ptolemy.domains.fsm.kernel.FSMActor
_addEntity, _addRelation, _commitLastChosenTransition, _isRefinementOutput, _readInputs, _setCurrentConnectionMap, addInitializable, attributeChanged, chooseTransition, clone, createReceivers, currentState, enabledTransitions, exportSubmodel, fire, getCausalityInterface, getContext, getDirector, getExecutiveDirector, getInitialState, getManager, getModifiedVariables, getPortScope, hasInput, hasInput, initialize, inputPortList, isFireFunctional, isOpaque, isStrict, iterate, newReceiver, newRelation, outputPortList, postfire, prefire, preinitialize, readInputs, readOutputsFromRefinement, removeInitializable, reset, setLastChosenTransition, setNewIteration, setSupportMultirate, stop, stopFire, terminate, typeConstraints, wrapup
 
Methods inherited from class ptolemy.kernel.CompositeEntity
_adjustDeferrals, _deepOpaqueEntityList, _description, _exportMoMLContents, _finishedAddEntity, _recordDecoratedAttributes, _removeEntity, _removeRelation, _validateSettables, allAtomicEntityList, allCompositeEntityList, allowLevelCrossingConnect, classDefinitionList, connect, connect, containedObjectsIterator, deepEntityList, deepGetEntities, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportLinks, exportMoML, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyClassDefinitionList, lazyDeepEntityList, lazyEntityList, lazyRelationList, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, setClassDefinition, setContainer, statistics, uniqueName
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_addPort, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_removePort, connectedPortList, connectedPorts, connectionsChanged, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _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, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, 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.actor.Executable
fire, isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, initialize, preinitialize, removeInitializable, wrapup
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 

Field Detail

_mirrorDisable

protected boolean _mirrorDisable
Indicator that we are processing a newPort request.

Constructor Detail

ModalController

public ModalController(CompositeEntity container,
                       java.lang.String name)
                throws IllegalActionException,
                       NameDuplicationException
Construct a modal controller with a name and a container. The container argument must not be null, or a NullPointerException will be thrown.

Parameters:
container - The container.
name - The name of this actor.
Throws:
IllegalActionException - If the container is incompatible with this actor.
NameDuplicationException - If the name coincides with an actor already in the container.

ModalController

public ModalController(Workspace workspace)
Construct a modal controller in the specified workspace with no container and an empty string as a name. You can then change the name with setName(). If the workspace argument is null, then use the default workspace.

Parameters:
workspace - The workspace that will list the actor.
Method Detail

dropObject

public void dropObject(NamedObj target,
                       java.util.List dropObjects,
                       java.lang.String moml)
                throws IllegalActionException
React to a list of objects being dropped onto a target.

Specified by:
dropObject in interface DropTargetHandler
Parameters:
target - The target on which the objects are dropped.
dropObjects - The list of objects dropped onto the target.
moml - The moml string generated for the dropped objects.
Throws:
IllegalActionException - If the handling is unsuccessful.

getRefinedState

public State getRefinedState()
                      throws IllegalActionException
Get the state in any ModalController within this ModalModel that has this ModalController as its refinement, if any. Return null if no such state is found.

Specified by:
getRefinedState in interface RefinementActor
Returns:
The state with this ModalController as its refinement, or null.
Throws:
IllegalActionException - If the specified refinement cannot be found in a state, or if a comma-separated list is malformed.

newPort

public Port newPort(java.lang.String name)
             throws NameDuplicationException
Create a new port with the specified name in the container of this controller, which in turn creates a port in this controller and all the refinements. This method is write-synchronized on the workspace.

Overrides:
newPort in class FSMActor
Parameters:
name - The name to assign to the newly created port.
Returns:
The new port.
Throws:
NameDuplicationException - If the entity already has a port with the specified name.

setMirrorDisable

public void setMirrorDisable(boolean disable)
Control whether adding a port should be mirrored in the modal model and refinements. This is added to allow control by the UI.

Parameters:
disable - True if mirroring should not occur.

_checkContainer

protected void _checkContainer(Entity container)
                        throws IllegalActionException
Override the base class to ensure that the proposed container is a ModalModel or null.

Parameters:
container - The proposed container.
Throws:
IllegalActionException - If the proposed container is not a TypedActor, or if the base class throws it.

_getRefinementClasses

protected java.util.TreeMap<java.lang.Class<? extends Entity>,java.lang.String> _getRefinementClasses()
Return a map from the classes of the entities to be dropped into a state and the class names of the refinements that can be used to contain those entities.

Returns:
The map.

addRefinement

public void addRefinement(State state,
                          java.lang.String name,
                          Entity template,
                          java.lang.String className,
                          Configuration configuration)
                   throws IllegalActionException
Create a refinement for the given state.

Specified by:
addRefinement in interface RefinementActor
Parameters:
state - The state that will contain the new refinement.
name - The name of the composite entity that stores the refinement.
template - The template used to create the refinement, or null if template is not used.
className - The class name for the refinement, which is used when template is null.
configuration - The configuration that is used to open the refinement (as a look-inside action) after it is created, or null if it is not needed to open the refinement.
Throws:
IllegalActionException - If error occurs while creating the refinement.