Package ptolemy.actor.lib.hoc
Class Case
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class Case extends MultiCompositeActor
An actor that executes one of several refinements depending on the value provided by the control port-parameter. To use this, drag the Case icon onto the canvas, right click and select Open Actor. To add a refinement, go to the Case menu in the menu bar and select Add Case, then populate populate the refinement with computations. Each refinement is a composite that is required to have its own director. The name of the refinement is value that the control must have to execute this refinement. This actor always provides one case called "default". This is the refinement that is executed if no other refinement matches the control input. All refinements have the same ports, and adding ports to any one refinement or to the case actor itself results in identical ports being added to all refinements.- Since:
- Ptolemy II 5.2
- Version:
- $Id$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Red (reviewmoderator)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected Refinement
_current
The current refinement.protected Refinement
_default
The default refinement.protected CaseDirector
_director
The director.PortParameter
control
The input port-parameter on which the control token is provided.-
Fields inherited from class ptolemy.actor.CompositeActor
_actorFiringListeners, _causalityInterface, _derivedPiggybacks, _initializables, _notifyingActorFiring, _piggybacks, _publishedPorts, _publisherRelations, _stopRequested, _subscribedPorts
-
Fields inherited from class ptolemy.kernel.CompositeEntity
_levelCrossingLinks
-
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 Case(CompositeEntity container, java.lang.String name)
Construct a modal model with a name and a container.Case(Workspace workspace)
Construct a Case in the specified workspace with no container and an empty string as a name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_addEntity(ComponentEntity entity)
Override the base class to ensure that the default refinement remains last.protected CaseDirector
_createDirector()
Create a director.java.lang.Object
clone(Workspace workspace)
Override the base class to ensure that the _default member points to the default refinement.void
fire()
Override the base class to not read inputs, since this has been done in prefire().Refinement
getCurrentRefinement()
Return the current refinement, or null if prefire() has not yet been invoked.Refinement
newRefinement(java.lang.String name)
Create a new refinement with the specified name.java.lang.String
refinementClassName()
Return the class name for refinements that this Case actor expects to contain.-
Methods inherited from class ptolemy.actor.lib.hoc.MultiCompositeActor
mirrorContainerPortsInRefinement, newPort
-
Methods inherited from class ptolemy.actor.TypedCompositeActor
_addPort, _addRelation, _checkTypesFromTo, _destinationTypeConstraints, attributeChanged, attributeTypeChanged, isBackwardTypeInferenceEnabled, newRelation, resolveTypes, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.CompositeActor
_actorFiring, _actorFiring, _finishedAddEntity, _setDirector, _transferPortParameterInputs, addActorFiringListener, addInitializable, addPiggyback, connectionsChanged, createReceivers, createSchedule, getCausalityInterface, getDirector, getExecutiveDirector, getManager, getPublishedPort, getPublishedPortChannel, getPublishedPorts, getSubscribedPortChannel, inferringWidths, inferWidths, initialize, inputPortList, isFireFunctional, isOpaque, isPublishedPort, isStrict, iterate, linkToPublishedPort, linkToPublishedPort, linkToPublishedPort, linkToPublishedPort, needsWidthInference, newInsideReceiver, newReceiver, notifyConnectivityChange, outputPortList, postfire, prefire, preinitialize, recordFiring, registerPublisherPort, registerPublisherPort, removeActorFiringListener, removeInitializable, removePiggyback, requestChange, setContainer, setDirector, setManager, stop, stopFire, terminate, unlinkToPublishedPort, unlinkToPublishedPort, unlinkToPublishedPort, unlinkToPublishedPort, unregisterPublisherPort, unregisterPublisherPort, wrapup
-
Methods inherited from class ptolemy.kernel.CompositeEntity
_adjustDeferrals, _containedDecorators, _deepOpaqueEntityList, _description, _exportMoMLContents, _removeEntity, _removeRelation, _validateSettables, allAtomicEntityList, allowLevelCrossingConnect, classDefinitionList, connect, connect, containedObjectsIterator, deepCompositeEntityList, deepEntityList, deepGetEntities, deepNamedObjList, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportLinks, exportMoML, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyAllCompositeTransparentAndOpaqueEntityList, lazyClassDefinitionList, lazyDeepEntityList, lazyEntityList, lazyRelationList, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, setClassDefinition, statistics, uniqueName
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_removePort, connectedPortList, connectedPorts, 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, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, 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, 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, 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
-
-
-
-
Field Detail
-
control
public PortParameter control
The input port-parameter on which the control token is provided. This can have any type, and is initialized with a default value of true.
-
_current
protected Refinement _current
The current refinement.
-
_default
protected Refinement _default
The default refinement.
-
_director
protected CaseDirector _director
The director.
-
-
Constructor Detail
-
Case
public Case(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct a modal model 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.
-
Case
public Case(Workspace workspace) throws IllegalActionException, NameDuplicationException
Construct a Case 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.- Throws:
IllegalActionException
- If the name has a period in it, or the director is not compatible with the specified container.NameDuplicationException
- If the container already contains an entity with the specified name.
-
-
Method Detail
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Override the base class to ensure that the _default member points to the default refinement.- Overrides:
clone
in classCompositeActor
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new Case.
- Throws:
java.lang.CloneNotSupportedException
- If any of the attributes cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
getCurrentRefinement
public Refinement getCurrentRefinement()
Return the current refinement, or null if prefire() has not yet been invoked.- Returns:
- The current refinement.
-
fire
public void fire() throws IllegalActionException
Override the base class to not read inputs, since this has been done in prefire(). Fire the current refinement, and then send any output data created by calling the local director's transferOutputs method.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classCompositeActor
- Throws:
IllegalActionException
- If there is no director, or if the director's fire() method throws it, or if the actor is not opaque.
-
newRefinement
public Refinement newRefinement(java.lang.String name) throws IllegalActionException, NameDuplicationException
Create a new refinement with the specified name.- Parameters:
name
- The name of the refinement.- Returns:
- The new refinement.
- Throws:
IllegalActionException
- If the refinement cannot be created.NameDuplicationException
- If a refinement already exists with this name.
-
refinementClassName
public java.lang.String refinementClassName()
Return the class name for refinements that this Case actor expects to contain.- Returns:
- The string "ptolemy.actor.lib.hoc.Refinement".
-
_addEntity
protected void _addEntity(ComponentEntity entity) throws IllegalActionException, NameDuplicationException
Override the base class to ensure that the default refinement remains last.- Overrides:
_addEntity
in classTypedCompositeActor
- Parameters:
entity
- TypedActor to contain.- Throws:
IllegalActionException
- If the entity has no name, or the action would result in a recursive containment structure.NameDuplicationException
- If the name collides with a name already in the entity.
-
_createDirector
protected CaseDirector _createDirector() throws IllegalActionException, NameDuplicationException
Create a director. This base class creates an instance of CaseDirector.- Returns:
- The created director.
- Throws:
IllegalActionException
- If the director cannot be created.NameDuplicationException
- If there is already an attribute with the name "_director".
-
-