ptolemy.domains.hde.lib
Class StateSampler
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.domains.de.kernel.DEActor
ptolemy.domains.de.lib.DETransformer
ptolemy.domains.hde.lib.StateSampler
- All Implemented Interfaces:
- Actor, Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Executable, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, SequenceActor, java.io.Serializable, TimedActor, TypedActor
- public class StateSampler
- extends DETransformer
Output the most recent input token when the trigger port receives a
token. If no token has been received on the input port when a
token is received on the trigger port, then no output is
produced. The inputs can be of any token type, and the output
is constrained to be of a type at least that of the input.In the hde domain,
the output is statically dependent on the value of the previous trigger token.
Both the input port and the output port are multiports.
Generally, their widths should match. Otherwise, if the width of the
input is greater than
the width of the output, the extra input tokens will
not appear on any output, although they will be consumed from
the input port. If the width of the output is greater
than that of the input, then the last few
channels of the output will never emit tokens.
Note that an event on the input port does not directly cause an output event.
Hence, this actor can be used to break feedback loops.
Note: If the width of the input changes during execution, then
the most recent inputs are forgotten, as if the execution of the model
were starting over.
This actor is similar to the Inhibit actor in that it modifies a
stream of events based on the presence or absence of events from another
input. This actor reacts to the presence of the other event, whereas
Inhibit reacts to the absence of it.
- Since:
- Ptolemy II 2.0
- Version:
- $Id: StateSampler.java,v 1.16 2004/04/13 03:33:19 cxh Exp $
- Author:
- Jie Liu, Edward A. Lee, Steve Neuendorffer, Jim Armstrong
- See Also:
Inhibit,
Serialized Form
- Accepted Rating:
- Proposed Rating:
| 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 |
StateSampler(CompositeEntity container,
java.lang.String name)
Construct an actor with the given container and name. |
|
Method Summary |
java.lang.Object |
clone(Workspace workspace)
Clone the actor into the specified workspace. |
void |
fire()
If there is a token in the trigger port,
emit the most recent token from the input port. |
boolean |
prefire()
If there is no input on the trigger port, return
false, indicating that this actor does not want to fire.
|
void |
preinitialize()
Clear the cached input tokens. |
| Methods inherited from class ptolemy.domains.de.kernel.DEActor |
newPort |
| Methods inherited from class ptolemy.actor.AtomicActor |
_createReceivers, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, initialize, inputPortList, iterate, newReceiver, outputPortList, postfire, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate, wrapup |
| 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.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 |
trigger
public TypedIOPort trigger
- The trigger port, which has type Token. If this port
receives a token, then the most recent token from the
input port will be emitted on the output port.
StateSampler
public StateSampler(CompositeEntity container,
java.lang.String name)
throws NameDuplicationException,
IllegalActionException
- Construct an actor with the given container and name.
- Parameters:
container - The container.name - The name of this actor.
- Throws:
IllegalActionException - If the actor cannot be contained
by the proposed container.
NameDuplicationException - If the container already has an
actor with this name.
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 ports.
- Overrides:
clone in class AtomicActor
- Parameters:
workspace - The workspace for the new object.
- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException - If a derived class has
has an attribute that cannot be cloned.
fire
public void fire()
throws IllegalActionException
- If there is a token in the trigger port,
emit the most recent token from the input port. If there
has been no input token, or there is no token on the trigger
port, emit nothing.
- Specified by:
fire in interface Executable- Overrides:
fire in class AtomicActor
- Throws:
IllegalActionException - If there is no director.
prefire
public boolean prefire()
throws IllegalActionException
- If there is no input on the trigger port, return
false, indicating that this actor does not want to fire.
This has the effect of leaving input values in the input
ports, if there are any.
- Specified by:
prefire in interface Executable- Overrides:
prefire in class AtomicActor
- Returns:
- True if this actor is ready for firing, false otherwise.
- Throws:
IllegalActionException - If there is no director.
preinitialize
public void preinitialize()
throws IllegalActionException
- Clear the cached input tokens.
- Specified by:
preinitialize in interface Executable- Overrides:
preinitialize in class AtomicActor
- Throws:
IllegalActionException - If there is no director.