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_ADDAdd.protected int_ANDLogical And.protected int_CONSTANTConstant.protected int_MAXIMUMMaximum.protected int_MINIMUMMinimum.protected int_MULTIPLYMultiply.protected int_NONENoop.protected int_ORLogical Or.StringAttributefunctionThe function to compute a combine operation on signals.TypedIOPortinputThis is a multiport for input (known) signals.TypedIOPortoutputOutput a signal here iff any connected input signal is known.TypedIOPortvalueOutput 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.voidattributeChanged(Attribute attribute)Override the base class to determine which function is being specified.voidfire()Collect the integer tokens of all available inputs and combine them using the combine function.voidinitialize()Set the RailwayInterface and open a TCP connection to the Model Railway interface program w/ the given host and port parameters.booleanisStrict()This actor must be *NON-strict* because it must not wait for more than one input within an SR director iteration.booleanpostfire()Return true, unless stop() has been called, in which case, return false.booleanprefire()Return true.voidwrapup()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 IllegalActionExceptionCollect 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:
firein interfaceExecutable- Overrides:
firein 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:
isStrictin interfaceExecutable- Overrides:
isStrictin classAtomicActor<TypedIOPort>- Returns:
- False if this actor does not need to be provided with inputs to fire.
-
prefire
public boolean prefire() throws IllegalActionExceptionDescription copied from class:AtomicActorReturn 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:
prefirein interfaceExecutable- Overrides:
prefirein 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 IllegalActionExceptionDescription copied from class:AtomicActorReturn 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:
postfirein interfaceExecutable- Overrides:
postfirein 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 IllegalActionExceptionSet the RailwayInterface and open a TCP connection to the Model Railway interface program w/ the given host and port parameters.- Specified by:
initializein interfaceInitializable- Overrides:
initializein classAtomicActor<TypedIOPort>- Throws:
IllegalActionException- If the parent class throws it.
-
wrapup
public void wrapup() throws IllegalActionExceptionTerminate 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:
wrapupin interfaceInitializable- Overrides:
wrapupin classAtomicActor<TypedIOPort>- Throws:
IllegalActionException- Not thrown in this base class.
-
_updateFunction
protected int _updateFunction(int in, int old) throws IllegalActionExceptionCalculate 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:
attributeChangedin classNamedObj- Parameters:
attribute- The attribute that changed.- Throws:
IllegalActionException- If the function is not recognized.
-
-