Package ptolemy.domains.sr.lib
Class Combine
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class Combine extends TypedAtomicActor
Combine actor for combining synchronous signals (ports with a token or no token) using a combine function.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Christian Motika
- Pt.AcceptedRating:
- red (cmot)
- Pt.ProposedRating:
- red (cmot)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected int
_ADD
Add.protected int
_AND
Logical And.protected int
_CONSTANT
Constant.protected int
_MAXIMUM
Maximum.protected int
_MINIMUM
Minimum.protected int
_MULTIPLY
Multiply.protected int
_NONE
Noop.protected int
_OR
Logical Or.StringAttribute
function
The function to compute a combine operation on signals.TypedIOPort
input
This is a multiport for input (known) signals.TypedIOPort
output
Output a signal here iff any connected input signal is known.TypedIOPort
value
Output a resulting value.-
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 Combine(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 int
_updateFunction(int in, int old)
Calculate the function on the given arguments.void
attributeChanged(Attribute attribute)
Override the base class to determine which function is being specified.void
fire()
Collect the integer tokens of all available inputs and combine them using the combine function.void
initialize()
Set the RailwayInterface and open a TCP connection to the Model Railway interface program w/ the given host and port parameters.boolean
isStrict()
This actor must be *NON-strict* because it must not wait for more than one input within an SR director iteration.boolean
postfire()
Return true, unless stop() has been called, in which case, return false.boolean
prefire()
Return true.void
wrapup()
Terminate the TCP connection of the Model Railway interface.-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _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, inputPortList, isFireFunctional, 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, 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
-
function
public StringAttribute function
The function to compute a combine operation on signals. This is a string-valued attribute that defaults to "add".
-
input
public TypedIOPort input
This is a multiport for input (known) signals.
-
output
public TypedIOPort output
Output a signal here iff any connected input signal is known. This is a constant value of "1" indicating the presence, always.
-
value
public TypedIOPort value
Output a resulting value. This is a constant value of "1", always.
-
_NONE
protected final int _NONE
Noop.- See Also:
- Constant Field Values
-
_ADD
protected final int _ADD
Add.- See Also:
- Constant Field Values
-
_MULTIPLY
protected final int _MULTIPLY
Multiply.- See Also:
- Constant Field Values
-
_MAXIMUM
protected final int _MAXIMUM
Maximum.- See Also:
- Constant Field Values
-
_MINIMUM
protected final int _MINIMUM
Minimum.- See Also:
- Constant Field Values
-
_OR
protected final int _OR
Logical Or.- See Also:
- Constant Field Values
-
_AND
protected final int _AND
Logical And.- See Also:
- Constant Field Values
-
_CONSTANT
protected final int _CONSTANT
Constant.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Combine
public Combine(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.
-
-
Method Detail
-
fire
public void fire() throws IllegalActionException
Collect the integer tokens of all available inputs and combine them using the combine function. Do this non-strict to take part in a fixed point iteration process.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If calling send() or super.fire() throws it.
-
isStrict
public boolean isStrict()
This actor must be *NON-strict* because it must not wait for more than one input within an SR director iteration.- Specified by:
isStrict
in interfaceExecutable
- Overrides:
isStrict
in classAtomicActor<TypedIOPort>
- Returns:
- False if this actor does not need to be provided with inputs to fire.
-
prefire
public boolean prefire() throws IllegalActionException
Description copied from class:AtomicActor
Return true. Derived classes override this method to define operations to be performed at the beginning of every iteration of its execution, prior the invocation of the fire() method. Derived classes may also use it to check preconditions for an iteration, if there are any.- Specified by:
prefire
in interfaceExecutable
- Overrides:
prefire
in classAtomicActor<TypedIOPort>
- Returns:
- True if this actor is ready for firing, false otherwise.
- Throws:
IllegalActionException
- Not thrown in this base class.
-
postfire
public boolean postfire() throws IllegalActionException
Description copied from class:AtomicActor
Return true, unless stop() has been called, in which case, return false. Derived classes override this method to define operations to be performed at the end of every iteration of its execution, after one invocation of the prefire() method and any number of invocations of the fire() method. This method typically wraps up an iteration, which may involve updating local state. In derived classes, this method returns false to indicate that this actor should not be fired again.- Specified by:
postfire
in interfaceExecutable
- Overrides:
postfire
in classAtomicActor<TypedIOPort>
- Returns:
- True if execution can continue into the next iteration.
- Throws:
IllegalActionException
- Not thrown in this base class.
-
initialize
public void initialize() throws IllegalActionException
Set the RailwayInterface and open a TCP connection to the Model Railway interface program w/ the given host and port parameters.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If the parent class throws it.
-
wrapup
public void wrapup() throws IllegalActionException
Terminate the TCP connection of the Model Railway interface. Set RI object to null so that for the next execution a new connection will be made.- Specified by:
wrapup
in interfaceInitializable
- Overrides:
wrapup
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- Not thrown in this base class.
-
_updateFunction
protected int _updateFunction(int in, int old) throws IllegalActionException
Calculate the function on the given arguments.- Parameters:
in
- The new input value. Should never be null.old
- The old result value, or null if there is none.- Returns:
- The result of applying the function.
- Throws:
IllegalActionException
- If thrown by BooleanToken operations.
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
Override the base class to determine which function is being specified. Read the value of the function attribute and set the cached value appropriately.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the function is not recognized.
-
-