ptolemy.actor.lib
Class Source
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.actor.lib.Source
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
- Direct Known Subclasses:
- AudioReader, CSPSource, DatabaseQuery, DatabaseSelect, EventButton, GetCausalityInterface, HadamardCode, ImageReader, ImageSequence, JAIConstant, JAIImageReader, JopReadPort, JopSerialRead, LimitedFiringSource, LineReader, ModelGenerator, MovieReader, RandomSource, RandomSource, Reader, SecretKey, SliderSource, SplitReader, SQLStatement, StreamLoader, TimedSource, Undefined, URLReader, VideoCamera, WallClockTime
public abstract class Source
- extends TypedAtomicActor
Base for simple data sources. This provides an output
port and a trigger input port, both exposed as public variables.
The trigger port is a multiport with undeclared type, meaning that
you can supply it with any data type. The trigger port can also be
left unconnected. The purpose of the trigger input is to
(optionally) supply events that cause the actor to fire. If the
port is connected to something, then this actor will check it
for a token and return false from prefire() if there is no token.
each channel of the trigger input, if any, and then discards the
token.
Some derived classes may attach additional significance to an input
on the trigger port. For example, they might fix the type and attach
some significance to the value. Note that it is not recommend to
use getWidth() on the port to determine whether the port is connected,
since the width may be greater than zero even if there
is no actual source of data. This can occur, for example, if a trigger port
is connected to the inside of a port of an opaque composite actor, and
there is nothing connected to the outside of that port. It is not
recommended to make the behavior of an actor dependent on a global
property such as whether there is ultimately a source of data.
- Since:
- Ptolemy II 0.3
- Version:
- $Id: Source.java 57040 2010-01-27 20:52:32Z cxh $
- Author:
- Edward A. Lee
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Constructor Summary |
Source(CompositeEntity container,
java.lang.String name)
Construct an actor with the given container and name. |
Method Summary |
void |
fire()
Read at most one input token from each channel of the trigger
input and discard it. |
boolean |
prefire()
If the trigger input is connected and it has no input or an unknown
state, then return false. |
Methods inherited from class ptolemy.actor.AtomicActor |
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup |
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 |
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName |
Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, 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 |
output
public TypedIOPort output
- The output port. The type of this port is unspecified.
Derived classes may set it.
trigger
public TypedIOPort trigger
- The trigger port. The type of this port is undeclared, meaning
that it will resolve to any data type.
Source
public Source(CompositeEntity container,
java.lang.String name)
throws NameDuplicationException,
IllegalActionException
- Construct an actor with the given container and name.
The output and trigger ports are also constructed.
- 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.
fire
public void fire()
throws IllegalActionException
- Read at most one input token from each channel of the trigger
input and discard it. If the trigger input is not connected
or has no actual sources (it might be connected to other
inputs, for example, or to an unconnected input port at
a higher level in the hierarchy) then this method does
nothing. Derived classes should be
sure to call super.fire(), or to consume the trigger input
tokens themselves, so that they aren't left unconsumed.
- Specified by:
fire
in interface Executable
- Overrides:
fire
in class AtomicActor
- Throws:
IllegalActionException
- Not thrown in this base class.
prefire
public boolean prefire()
throws IllegalActionException
- If the trigger input is connected and it has no input or an unknown
state, then return false. Otherwise, return true.
- Specified by:
prefire
in interface Executable
- Overrides:
prefire
in class AtomicActor
- Returns:
- True, unless the trigger input is connected
and has no input.
- Throws:
IllegalActionException
- If checking the trigger for
a token throws it or if the super class throws it.