Package ptolemy.actor.lib
Class PoissonClock
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TimedActor
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class PoissonClock extends RandomSource implements TimedActor
This actor produces discrete events according to a Poisson process. The time between events is given by independent and identically distributed exponential random variables. The values produced rotate sequentially through those given in the values parameter, which is an array of anything and defaults to {1, 0}. The type of the output can be any token type. This type is inferred from the element type of the values parameter. The mean time between events is given by the meanTime parameter, which defaults to 1.0.In the initialize() method and postfire() methods, the actor uses the fireAt() method of the director to request the next firing. The first firing is always at the start time, unless the parameter fireAtStart is changed to false.
If the trigger input is connected, then any event on it will cause the Poisson process to immediately produce the next event, as if the time for that event had arrived.
If this actor is inactive at the time at which it would have otherwise produced an output, then it will stop producing outputs. This should not happen.
- Since:
- Ptolemy II 1.0
- Version:
- $Id$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Yellow (yuhong)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description Parameter
fireAtStart
If true, then this actor will request a firing at the start time.Parameter
meanTime
The mean time between events, where the output value transitions.Parameter
stopTime
The time at which postfire() should return false.Parameter
values
The values that will be produced at the output.-
Fields inherited from class ptolemy.actor.lib.RandomSource
_generatorSeed, _needNew, _needNewGenerator, _random, privateSeed, resetOnEachRun, seed
-
Fields inherited from class ptolemy.actor.lib.Source
_triggered, output, trigger
-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
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 PoissonClock(CompositeEntity container, java.lang.String name)
Construct an actor with the specified container and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
_generateRandomNumber()
Generate a new random number.void
attributeChanged(Attribute attribute)
If the argument is the meanTime parameter, check that it is positive.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.void
fire()
Output the current value.Time
getModelStopTime()
Get the stop time.double
getStopTime()
Deprecated.As of Ptolemy II 4.1, replaced bygetModelStopTime()
void
initialize()
Request the first firing either at the start time or at a random time, depending on fireAtStart.boolean
postfire()
Generate an exponential random number and schedule the next firing.boolean
prefire()
If the current time matches the expected time for the next output, then return true.void
wrapup()
Override the base class to reset a flag that indicates that the model is executing.-
Methods inherited from class ptolemy.actor.lib.RandomSource
_createGenerator
-
Methods inherited from class ptolemy.actor.lib.Source
_customTypeConstraints
-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, 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, 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.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, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
fireAtStart
public Parameter fireAtStart
If true, then this actor will request a firing at the start time. Otherwise, the first firing will be requested at the first random time. This is a boolean-valued parameter that defaults to true.
-
meanTime
public Parameter meanTime
The mean time between events, where the output value transitions. This parameter must contain a DoubleToken.
-
stopTime
public Parameter stopTime
The time at which postfire() should return false. This is a double that defaults to Infinity, which means that postfire() never returns false (or at least, doesn't do so due to stopTime having been exceeded).
-
values
public Parameter values
The values that will be produced at the output. This parameter can contain any ArrayToken, and it defaults to {1, 0}.
-
-
Constructor Detail
-
PoissonClock
public PoissonClock(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Construct an actor with the specified container and name.- Parameters:
container
- The container.name
- The name of this actor.- Throws:
IllegalActionException
- If the entity cannot be contained by the proposed container.NameDuplicationException
- If the container already has an actor with this name.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
If the argument is the meanTime parameter, check that it is positive.- Overrides:
attributeChanged
in classRandomSource
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the meanTime value is not positive.
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace. This calls the base class and then sets the parameter public members to refer to the parameters of the new actor.- Overrides:
clone
in classRandomSource
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
fire
public void fire() throws IllegalActionException
Output the current value.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classRandomSource
- Throws:
IllegalActionException
- If there is no director.
-
getStopTime
@Deprecated public double getStopTime()
Deprecated.As of Ptolemy II 4.1, replaced bygetModelStopTime()
Get the stop time.- Returns:
- The stop time.
-
getModelStopTime
public Time getModelStopTime()
Get the stop time.- Returns:
- The stop time.
-
initialize
public void initialize() throws IllegalActionException
Request the first firing either at the start time or at a random time, depending on fireAtStart.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classRandomSource
- Throws:
IllegalActionException
- If the fireAt() method of the director throws it, or if the director does not agree to fire the actor at the specified time.
-
postfire
public boolean postfire() throws IllegalActionException
Generate an exponential random number and schedule the next firing.- Specified by:
postfire
in interfaceExecutable
- Overrides:
postfire
in classRandomSource
- Returns:
- True if it is ok to continue.
- Throws:
IllegalActionException
- If the director throws it when scheduling the next firing, or if the director does not agree to fire the actor at the specified time.
-
prefire
public boolean prefire() throws IllegalActionException
If the current time matches the expected time for the next output, then return true. Also return true if the trigger input is connected and has events. Otherwise, return false.- Specified by:
prefire
in interfaceExecutable
- Overrides:
prefire
in classSource
- Returns:
- True, unless the trigger input is connected and has no input.
- Throws:
IllegalActionException
- If there is no director.
-
wrapup
public void wrapup() throws IllegalActionException
Override the base class to reset a flag that indicates that the model is executing. This method is invoked exactly once per execution of an application. None of the other action methods should be be invoked after it.- Specified by:
wrapup
in interfaceInitializable
- Overrides:
wrapup
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- Not thrown in this base class.
-
_generateRandomNumber
protected void _generateRandomNumber() throws IllegalActionException
Generate a new random number.- Specified by:
_generateRandomNumber
in classRandomSource
- Throws:
IllegalActionException
- If parameter values are incorrect.
-
-