Class Source
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
ActorWithPrivateParameter
,AudioReader
,CSPSource
,DatabaseQuery
,DatabaseSelect
,DummySource
,EventButton
,GetCausalityInterface
,HadamardCode
,ImageReader
,ImageSequence
,JAIConstant
,JAIImageReader
,JopReadPort
,JopSerialRead
,LimitedFiringSource
,LineReader
,ModelGenerator
,MovieReader
,ObjectTokenSource
,PGMReader
,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.
Any type of data on is accepted on the trigger port, therefore no type is declared. Instead, the type resolution algorithm finds the least fixed point. If backward type inference is enabled, and no type has been declared for the trigger, it is constrained to be equal to
BaseType.GENERAL
. This will result in upstream ports resolving to the most general type rather than the most specific.- Since:
- Ptolemy II 0.3
- Version:
- $Id$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Green (bilung)
- Pt.ProposedRating:
- Green (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
_triggered
Indicator of whether trigger inputs have arrived since the last output.TypedIOPort
output
The output port.TypedIOPort
trigger
The trigger port.-
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 Source(CompositeEntity container, java.lang.String name)
Construct an actor with the given container and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Set<Inequality>
_customTypeConstraints()
Set the input port greater than or equal toBaseType.GENERAL
in case backward type inference is enabled and the input port has no type declared.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.TypedAtomicActor
_containedTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, 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
_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, attributeChanged, 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, postfire, 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
-
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.
-
_triggered
protected transient boolean _triggered
Indicator of whether trigger inputs have arrived since the last output.
-
-
Constructor Detail
-
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.
-
-
Method Detail
-
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 interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- 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 interfaceExecutable
- Overrides:
prefire
in classAtomicActor<TypedIOPort>
- 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.
-
_customTypeConstraints
protected java.util.Set<Inequality> _customTypeConstraints()
Set the input port greater than or equal toBaseType.GENERAL
in case backward type inference is enabled and the input port has no type declared.- Overrides:
_customTypeConstraints
in classTypedAtomicActor
- Returns:
- A set of inequalities.
-
-