ptolemy.actor.lib
Class Stop

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.InstantiableNamedObj
          extended byptolemy.kernel.Entity
              extended byptolemy.kernel.ComponentEntity
                  extended byptolemy.actor.AtomicActor
                      extended byptolemy.actor.TypedAtomicActor
                          extended byptolemy.actor.lib.Sink
                              extended byptolemy.actor.lib.Stop
All Implemented Interfaces:
ptolemy.actor.Actor, ptolemy.kernel.util.Changeable, java.lang.Cloneable, ptolemy.kernel.util.Debuggable, ptolemy.kernel.util.DebugListener, ptolemy.kernel.util.Derivable, ptolemy.actor.Executable, ptolemy.kernel.util.Instantiable, ptolemy.kernel.util.ModelErrorHandler, ptolemy.kernel.util.MoMLExportable, ptolemy.kernel.util.Nameable, java.io.Serializable, ptolemy.actor.TypedActor

public class Stop
extends Sink

An actor that stops execution of a model when it receives a true token on any input channel. This is accomplished by calling finish() on the manager, which requests that the current iteration be completed and then the model execution be halted. If the input is not connected to anything, then this actor requests a stop whenever it fires.

When exactly this stops the execution depends on the domain. For example, in DE, if an event with time stamp T and value true arrives at this actor, then the current iteration will be concluded, and then the model will halt. Concluding the current iteration means processing all events in the event queue with time stamp T. Thus, it is possible for actors to be invoked after this one is invoked with a true input.

In SDF, if this actor receives true, then the current iteration is concluded and then execution is stopped. Similarly in SR.

In PN, where each actor has its own thread, there is no well-defined notion of an iteration. The finish() method of the manager calls stopFire() on all actors, which for threaded actors results in halting them upon their next attempt to read an input or write an output. When all actor threads have stopped, the iteration concludes and the model halts. NOTE: This is not the best way to stop a PN model! This mechanism is nondeterministic in the sense that there is no way to control exactly what data is produced or consumed on the connections before the model stops. To stop a PN model, it is better to design the model so that all actors are starved of data when the model is to stop. The director will detect this starvation, and halt the model. Nonetheless, if the nondeterminism is acceptable, this actor can be used.

Since:
Ptolemy II 2.1
Version:
$Id: Stop.java,v 1.22 2004/05/06 03:43:28 eal Exp $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Green (neuendor)
Proposed Rating:
Green (eal)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.Entity
ptolemy.kernel.Entity.ContainedObjectsIterator
 
Field Summary
 
Fields inherited from class ptolemy.actor.lib.Sink
input
 
Fields inherited from class ptolemy.actor.AtomicActor
_stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
Stop(ptolemy.kernel.CompositeEntity container, java.lang.String name)
          Construct an actor in the specified container with the specified name.
 
Method Summary
 boolean postfire()
          Read one token from each input channel that has a token, and if any token is true, call finish() on the manager.
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, attributeTypeChanged, clone, newPort, typeConstraintList
 
Methods inherited from class ptolemy.actor.AtomicActor
_createReceivers, clone, connectionsChanged, fire, getDirector, getExecutiveDirector, getFunctionDependency, getManager, initialize, inputPortList, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate, wrapup
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_description, _exportMoMLContents, _removePort, connectedPortList, connectedPorts, 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, attributeChanged, attributeList, attributeList, 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.actor.Actor
getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
fire, initialize, iterate, prefire, preinitialize, stop, stopFire, terminate, wrapup
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getFullName, getName, getName
 

Constructor Detail

Stop

public Stop(ptolemy.kernel.CompositeEntity container,
            java.lang.String name)
     throws ptolemy.kernel.util.IllegalActionException,
            ptolemy.kernel.util.NameDuplicationException
Construct an actor in the specified container with the specified name.

Parameters:
container - The container.
name - The name of this actor within the container.
Throws:
ptolemy.kernel.util.IllegalActionException - If the actor cannot be contained by the proposed container.
ptolemy.kernel.util.NameDuplicationException - If the name coincides with an actor already in the container.
Method Detail

postfire

public boolean postfire()
                 throws ptolemy.kernel.util.IllegalActionException
Read one token from each input channel that has a token, and if any token is true, call finish() on the manager. If nothing at all is connected to the input port, then call finish() unconditionally.

Returns:
False if a stop is requested, and true otherwise.
Throws:
ptolemy.kernel.util.IllegalActionException - If there is no director or if there is no manager, or if the container is not a CompositeActor.