public class DoubleSignalPort extends Object implements DoubleSignalSource
An instance of this class, when used directly, acts as a dynamic proxy
that delegates all method invocations to a pluggable input signal source.
The currently plugged input is looked up via getInput() at every
delegation event, such that re-plugging via setInput(DoubleSignalSource) has immediate effect.
If an instance of this class is compiled, usually as a subcomponent of a
complex signal network, then the compiled code shares the pluggable state of
the original orig, and will dynamically delegate to the input signal
source returned by orig.getInput(). Thus even complex network
modules with multiple inputs and outputs can be compiled to monolithic code,
but configured dynamically, by
DoubleSignalSource and its companion classes,The pluggable input signal source can be set to null, which will
cause the getAsDouble() method of this object to fail at runtime
with NullPointerException.
| Constructor and Description |
|---|
DoubleSignalPort()
Creates a new instance with no specified initial input.
|
DoubleSignalPort(DoubleSignalSource input)
Creates a new instance with the specified initial input.
|
| Modifier and Type | Method and Description |
|---|---|
Consumer<CompilationContext> |
compileDataFlow()
Returns a code generator for outputting the value of this entity.
|
double |
getAsDouble()
Returns the current value of this signal source.
|
DoubleSignalSource |
getInput()
Returns the current input signal source.
|
void |
setInput(DoubleSignalSource input)
Sets the current input signal source.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitabs, add, choose, choose, choose, choose, clock, compileMainSignalSource, constant, defined, delayed, delayed, delayedFeedback, delayedFeedback, divide, equal, getConstantAsDouble, getValueClass, glidingAverage, glidingStandardDeviation, glidingSum, glidingVariance, greaterOrEqual, greaterThan, guard, hasConstantAsDouble, invariant, lessOrEqual, lessThan, map, max, min, modulo, multiply, negate, negative, nonEqual, nonnegative, nonpositive, nonzero, notANumber, positive, power, probe, publishStoredValueVariable, relateWith, sampleAndHold, selectAffine, series, sqrt, stored, subtract, zero, zeroCrossing, zipWithcompileDataFlowTo, hasDataFlowIOpublic DoubleSignalPort()
public DoubleSignalPort(DoubleSignalSource input)
input - the input signal sourcepublic DoubleSignalSource getInput()
public void setInput(DoubleSignalSource input)
public double getAsDouble()
The value may be either computed on demand, or retrieved from storage.
Implementations of this method should have no side effect.
This implementation always delegates to getInput().getAsDouble().
getAsDouble in interface DoubleSignalSourcegetAsDouble in interface DoubleSupplierpublic Consumer<CompilationContext> compileDataFlow()
DoubleSignalSourceThis implementation generates code to invoke this.getAsDouble().
compileDataFlow in interface CompilableDataFlowcompileDataFlow in interface DoubleSignalSource