Interface ByteClockedSignalSource
- All Superinterfaces:
AbstractClockedSignalSource
,AbstractSignalSource
,ByteSignalSource
,ByteSupplier
,CompilableControlFlow
,CompilableDataFlow
,Component
,Process
- All Known Implementing Classes:
ByteClockedSignalSource.AbstractRandom
,ByteDelay
,ByteMultiDelay
,ByteProcessMux
,ByteSaH
,ByteStoredSignalSource
,CompilableByteStoredSignalSource
byte
whose observable state is
driven by a clock.
This interface excludes signal sources whose state changes asynchronously, but is neutral with respect to whether values are computed on the fly when demanded, or stored when available and then just retrieved.
The operation of the driving clock works as specified by the Process
superinterface. For example, a main loop may use the following
pattern:
RealtimeContext rc = ...; ByteClockedSignalSource c = ...; c.setRealtimeContext(rc); c.init(); while (...) { c.step(); byte v = c.getAsByte(); ... }
Every iteration of the main loop increases the clock index of the
component c
. The behavior of instances of this interface is
typically specified in terms of the current clock index.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface eu.bandm.sig.adlib2.Process
Process.Proxy
-
Field Summary
Fields inherited from interface eu.bandm.sig.adlib2.AbstractClockedSignalSource
STREAM_CHARACTERISTICS, STREAM_SIZE
-
Method Summary
Modifier and TypeMethodDescriptionstatic ByteClockedSignalSource
adHoc
(byte... elems) Returns a new signal source that produces the given values, one per clock tick.default ByteClockedSignalSource
default ByteClockedSignalSource
compile()
Returns a new signal source that realizes the same behavior as this signal source with specialized code.static ByteClockedSignalSource
count
(byte from) Returns a new signal source whose value increases by one at every clock tick.static ByteClockedSignalSource
countdown
(byte from) Returns a new signal source whose value decreases by one at every clock tick.static ByteClockedSignalSource
cycle
(byte... elems) Returns a new signal source that produces the given values repeatedly, one per clock tick.default ByteClockedSignalSource
static ByteClockedSignalSource
random()
static ByteClockedSignalSource
random
(long seed) static ByteClockedSignalSource
random
(OptionalLong seed) Methods inherited from interface eu.bandm.sig.adlib2.ByteSignalSource
abs, add, asInt, compileDataFlow, compileMainSignalSource, DEBUG, delayed, delayed, divide, equal, getAsByte, getConstantAsByte, getValueClass, greaterOrEqual, greaterThan, guard, hasConstantAsByte, invariant, lessOrEqual, lessThan, map, max, min, modulo, multiply, negate, negative, nonEqual, nonnegative, nonpositive, nonzero, positive, power, probe, publishStoredValueVariable, relateWith, sampleAndHold, stored, subtract, zero, zipWith
Methods inherited from interface eu.bandm.sig.adlib2.compile.CompilableDataFlow
compileDataFlowTo, hasDataFlowIO
Methods inherited from interface eu.bandm.sig.adlib2.Process
afterEvery, andThen, compileAsMainProcess, compileControlFlow, compileInitialization, every, every, getProcess, hasControlFlowIO, hasInitializationIO, init, setRealtimeContext, step
-
Method Details
-
after
-
during
-
adHoc
Returns a new signal source that produces the given values, one per clock tick.After the given values are exhausted, that is after as many clock ticks as there are elements in the array, the default value of the element type is held indefinitely.
At clock index
n
,this.getAsByte() == (n < elems.length ? elems[n] : 0)
holds.- Parameters:
elems
- the array of values to produce
-
cycle
Returns a new signal source that produces the given values repeatedly, one per clock tick.When the given values are exhausted the iteration starts over.
At clock index
n
,this.getAsByte() == elems[n % elems.length]
holds.- Parameters:
elems
- the array of values to produce
-
compile
Returns a new signal source that realizes the same behavior as this signal source with specialized code.The resulting object displays the same long-term behavior (reaction with output values to realtime events) as this signal source. Its internal state is undefined phase until initialized properly.
Specialized JVM byte code is generated, and a new class is loaded for the implementation. It can be expected to execute more efficiently than the original after a warm-up phase, subject to the usual conditions of JVM just-in-time compilation. Hence compilation is recommended for components to be used in tight long-running loops, but not for one-off or infrequent computations.
The original and the compiled instance do not share state phase or memory; their life cycles are independent except for shared non-compilable components. For the latter reason, it is recommended not to use both instances concurrently.
-
count
Returns a new signal source whose value increases by one at every clock tick.Initialization resets the value to the given initial value.
At clock index
n
,this.getAsByte() == from + n
holds.- Parameters:
from
- the value at the first clock tick after initialization
-
countdown
Returns a new signal source whose value decreases by one at every clock tick. The value stops at zero, and does not decrease further to become negative.Initialization resets the value to the given initial value.
At clock index
n
,this.getAsByte() == Math.max(from - n, 0)
holds.- Parameters:
from
- the value at the first clock tick after initialization- Throws:
IllegalArgumentException
- iffrom
is negative
-
dt
-
random
-
random
-
random
-