Interface BooleanSignalSource
- All Superinterfaces:
AbstractSignalSource,BooleanSupplier,CompilableDataFlow
- All Known Subinterfaces:
BooleanClockedSignalSource
- All Known Implementing Classes:
BooleanDelay,BooleanMultiDelay,BooleanPost,BooleanSequencerColumn,BooleanSignalPort,BooleanSignalSourceChooser,BooleanSignalSourceChooser.OfEnum,BooleanSignalSourceChooser.OfEnumInt,BooleanSignalSourceChooser.OfInt,BooleanStoredSignalSource,CompilableBooleanStoredSignalSource,NextEvent
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
boolean.
This basic interface is neutral with respect to whether values may change at arbitrary times or synchronously with respect to a clock, and to whether values are computed on the fly when demanded, or stored when available and then just retrieved.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault BooleanSignalSourceand(BooleanSignalSource other) Returns a new signal source whose value is the conjunction of the simultaneous values of this and another signal source.default BooleanClockedSignalSourcebecoming(boolean initial) Returns a new clocked signal source whose value, at any clock index, istrueiff the value of this signal source is becomingtrueat that clock index.default BooleanClockedSignalSourceceasing(boolean initial) Returns a new clocked signal source whose value, at any clock index, istrueiff the value of this signal source is ceasing to betrueat that clock index.default BooleanSignalSourcechoose(BooleanSignalSource inTrue, BooleanSignalSource inFalse) Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of this signal source.static BooleanSignalSourcechoose(BooleanSignalSource condition, BooleanSignalSource inTrue, BooleanSignalSource inFalse) Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of a condition signal source.default ByteSignalSourcechoose(ByteSignalSource inTrue, ByteSignalSource inFalse) default DoubleSignalSourcechoose(DoubleSignalSource inTrue, DoubleSignalSource inFalse) Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of this signal source.static <E extends Enum<E>>
BooleanSignalSourcechoose(EnumSignalSource<E> selector, BooleanSignalSource... cases) Returns a new signal source whose value is selected dynamically from a range of cases indexed byenumvalues.default <E extends Enum<E>>
EnumSignalSource<E> choose(EnumSignalSource<E> inTrue, EnumSignalSource<E> inFalse) Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of this signal source.static <E extends Enum<E>>
BooleanSignalSourcechoose(EnumSignalSource<E> selector, EnumMap<E, ? extends BooleanSignalSource> cases) Returns a new signal source whose value is selected dynamically from a range of cases indexed byenumvalues.default FloatSignalSourcechoose(FloatSignalSource inTrue, FloatSignalSource inFalse) Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of this signal source.default IntSignalSourcechoose(IntSignalSource inTrue, IntSignalSource inFalse) Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of this signal source.default LongSignalSourcechoose(LongSignalSource inTrue, LongSignalSource inFalse) Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of this signal source.default Processdefault <A> SignalSource<A> choose(SignalSource<A> inTrue, SignalSource<A> inFalse) Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of this signal source.static <E extends Enum<E>>
BooleanSignalSourcechoose(SignalSource<E> selector, EnumMap<E, ? extends BooleanSignalSource> cases) Returns a new signal source whose value is selected dynamically from a range of cases indexed byenumvalues.static BooleanClockedSignalSourceclock(BooleanSignalSource output, Process... processes) default Consumer<CompilationContext> Returns a code generator for outputting the value of this entity.default voidstatic BooleanSignalSourceconstant(boolean value) Returns a signal source whose value is constant (never changes).default Processdefault BooleanClockedSignalSourcedelayed(boolean initialValue) Returns a new signal source that mirrors the values of this signal source delayed by one clock tick.default BooleanClockedSignalSourcedelayed(boolean... initialValues) Returns a new signal source that mirror the values of this signal source delayed by a given number of clock ticks.static BooleanClockedSignalSourcedelayedFeedback(Function<? super BooleanClockedSignalSource, ? extends BooleanSignalSource> loop, boolean initialValue) Returns a new signal source that receives its own delayed output as input.static BooleanClockedSignalSourcedelayedFeedback(Function<? super BooleanClockedSignalSource, ? extends BooleanSignalSource> loop, boolean... initialValues) static BooleanSignalSourcefromArray(boolean[] data, IntSignalSource index) Returns a new signal source whose value is an element of a given array, whose index is determined by a given signal source.static BooleanSignalSourcefromArrayCyclic(boolean[] data, IntSignalSource index) Returns a new signal source whose value is an element of a given array, whose index is determined by a given signal source.booleanReturns the current value of this signal source.Returns the constant value of this signal source, if applicable.default Class<?> Returns the type of values produced by this entity.default BooleanSignalSourceguard(BooleanPredicate pred) Returns a boolean signal source whose values are derived from the values of this signal source by applying a unary predicate.default booleanChecks whether this signal source has a constant value.default BooleanClockedSignalSourcedefault BooleanSignalSourceReturns a signal source whose values are derived from the values of this signal source by applying a unary function.default BooleanSignalSourcenot()Returns a new signal source whose value is the negation of the value of this signal source.default BooleanSignalSourceor(BooleanSignalSource other) Returns a new signal source whose value is the disjunction of the simultaneous values of this and another signal source.default BooleanClockedSignalSourcepower(BinaryOperator<BooleanSignalSource> op, long n) default ProcessReturns a realtime event that, when fired, notifies the concerned observer of the current value of this signal source.default voiddefault BooleanSignalSourcerelateWith(BooleanBiPredicate pred, BooleanSignalSource other) Returns a boolean signal source whose values are derived from the simultaneous values of this and another signal source by applying a binary predicate.default BooleanClockedSignalSourcesampleAndHold(BooleanSignalSource hold, boolean initialValue) Returns a new clocked signal source whose value at each clock tick is either the current value of this signal source (sample mode), or its own value at the previous clock tick (hold mode), depending on the current value of a given boolean signal source.default BooleanClockedSignalSourcestored()Returns a new signal source that stores snapshot values of this signal source driven by a clock.default BooleanSignalSourcexor(BooleanSignalSource other) Returns a new signal source whose value is the difference of the simultaneous values of this and another signal source.default BooleanSignalSourcezipWith(BooleanBinaryOperator op, BooleanSignalSource other) Returns a signal source whose values are derived from the simultaneous values of this and another signal source by applying a binary function.Methods inherited from interface eu.bandm.sig.adlib2.compile.CompilableDataFlow
compileDataFlowTo, hasDataFlowIO
-
Method Details
-
getAsBoolean
boolean getAsBoolean()Returns the current value of this signal source.The value may be either computed on demand, or retrieved from storage.
Implementations of this method should have no side effect.
- Specified by:
getAsBooleanin interfaceBooleanSupplier- Returns:
- the current value of this signal source
-
getValueClass
Returns the type of values produced by this entity.For signals of primitive value type, the result will be the corresponding pseudoclass.
This implementation returns the primitive pseudoclass
boolean.class.- Specified by:
getValueClassin interfaceCompilableDataFlow- Returns:
- the type of signal values that this entity produces
- See Also:
-
getConstantAsBoolean
Returns the constant value of this signal source, if applicable.- Returns:
- an
Optionalcontaining the value of this signal source if it is constant, orOptional.empty()otherwise.
-
hasConstantAsBoolean
default boolean hasConstantAsBoolean()Checks whether this signal source has a constant value.- Returns:
trueiff the value of this signal source does not change over time
-
compileDataFlow
Returns a code generator for outputting the value of this entity.This implementation generates code to invoke
this.getAsBoolean().- Specified by:
compileDataFlowin interfaceCompilableDataFlow
-
constant
Returns a signal source whose value is constant (never changes).- Parameters:
value- the value of the new signal source- Returns:
- a signal source that always has the given value
-
map
Returns a signal source whose values are derived from the values of this signal source by applying a unary function.The implementation yields a signal source that computes the derived value by applying the given function every time its
getAsBoolean()method is invoked. If the computation is costly and the value reused often, it may be convenient to compute and store the value proactively driven by a clock.- Parameters:
op- the function to apply to each value- See Also:
-
zipWith
Returns a signal source whose values are derived from the simultaneous values of this and another signal source by applying a binary function.The implementation yields a signal source that computes the derived value by applying the given function every time its
getAsBoolean()method is invoked. If the computation is costly and the value reused often, it may be convenient to compute the value proactively driven by a clock.- Parameters:
op- the function to apply to each pair of valuesother- the other signal source to consider- See Also:
-
guard
Returns a boolean signal source whose values are derived from the values of this signal source by applying a unary predicate.The implementation yields a signal source that computes the derived value by applying the given predicate every time its
getAsBoolean()method is invoked. If the computation is costly and the value reused often, it may be convenient to compute the value proactively driven by a clock.- Parameters:
pred- the predicate to apply to each value- See Also:
-
relateWith
Returns a boolean signal source whose values are derived from the simultaneous values of this and another signal source by applying a binary predicate.The implementation yields a signal source that computes the derived value by applying the given predicate every time its
getAsBoolean()method is invoked. If the computation is costly and the value reused often, it may be convenient to compute the value proactively driven by a clock.- Parameters:
pred- the predicate to apply to each valueother- the other signal source to consider- See Also:
-
clock
@Undocumented static BooleanClockedSignalSource clock(BooleanSignalSource output, Process... processes) -
invariant
-
stored
Returns a new signal source that stores snapshot values of this signal source driven by a clock.The
getAsBoolean()method of the returned signal source is guaranteed to be extremely fast, both in interpreted and compiled mode. The computational effort of the underlying signal source is instead spent on theProcess.step()method of the returned signal source, to be invoked at each clock tick.If the underlying signal source is constant, the value is forwarded when the
Process.init()method of the returned signal source is invoked, where as its implementation ofProcess.step()does nothing.- Returns:
- a new signal source that takes value snapshots of this signal source.
-
delayed
Returns a new signal source that mirrors the values of this signal source delayed by one clock tick.- Parameters:
initialValue- the initial value to output for the first clock tick
-
delayed
Returns a new signal source that mirror the values of this signal source delayed by a given number of clock ticks.The length of the delay in clock ticks is specified implicitly by the number of initial values.
- Parameters:
initialValues- the initial values to output for the first clock ticks
-
delayedFeedback
static BooleanClockedSignalSource delayedFeedback(Function<? super BooleanClockedSignalSource, ? extends BooleanSignalSource> loop, boolean initialValue) Returns a new signal source that receives its own delayed output as input.The circular data flow is constructed by specifying a function that receives as its argument a delayed signal source that will be fed back from the source that it returns. The passed function is applied exactly once.
The output signal source is used both internally for the delayed feedback, and possibly externally by a consumer. Hence its value is stored implicitly in an intermediate variable in order to avoid duplicate computations.
- Parameters:
loop- the function that creates the output signal source, given its delayed feedbackinitialValue- the initial value of the delayed feedback
-
delayedFeedback
@SafeVarargs static BooleanClockedSignalSource delayedFeedback(Function<? super BooleanClockedSignalSource, ? extends BooleanSignalSource> loop, boolean... initialValues) -
probe
Returns a realtime event that, when fired, notifies the concerned observer of the current value of this signal source.- Parameters:
key- the key to associate the value of this signal source with- See Also:
-
not
Returns a new signal source whose value is the negation of the value of this signal source.At any point in time,
this.negate().getAsBoolean() == !this.getAsBoolean()holds. -
or
Returns a new signal source whose value is the disjunction of the simultaneous values of this and another signal source.At any point in time,
this.add(other).getAsBoolean() == this.getAsBoolean() | other.getAsBoolean()holds.- Parameters:
other- the other signal source to consider
-
and
Returns a new signal source whose value is the conjunction of the simultaneous values of this and another signal source.At any point in time,
this.add(other).getAsBoolean() == this.getAsBoolean() & other.getAsBoolean()holds.- Parameters:
other- the other signal source to consider
-
xor
Returns a new signal source whose value is the difference of the simultaneous values of this and another signal source.At any point in time,
this.add(other).getAsBoolean() == this.getAsBoolean() ^ other.getAsBoolean()holds.- Parameters:
other- the other signal source to consider
-
becoming
Returns a new clocked signal source whose value, at any clock index, istrueiff the value of this signal source is becomingtrueat that clock index. That is, if the pair of values of this signal source at the previous and the current clock index arefalse, true, respectively. The virtual initial value before the first clock index is specified separately.- Parameters:
initial- the virtual initial value; iffalsethen the output can becometrueat the first clock tick
-
ceasing
Returns a new clocked signal source whose value, at any clock index, istrueiff the value of this signal source is ceasing to betrueat that clock index. That is, if the pair of values of this signal source at the previous and the current clock index aretrue, false, respectively. The virtual initial value before the first clock index is specified separately.- Parameters:
initial- the virtual initial value; iftruethen the output can becometrueat the first clock tick
-
choose
Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of this signal source.At any point in time,
this.choose(x, y).get() == (this.getAsBoolean() ? x : y).get()holds.- Parameters:
inTrue- the signal source to consider when the value of this signal source istrueinFalse- the signal source to consider when the value of this signal source isfalse
-
choose
Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of this signal source.At any point in time,
this.choose(x, y).getAsFloat() == (this.getAsBoolean() ? x : y).getAsFloat()holds.- Parameters:
inTrue- the signal source to consider when the value of this signal source istrueinFalse- the signal source to consider when the value of this signal source isfalse
-
choose
Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of this signal source.At any point in time,
this.choose(x, y).getAsDouble() == (this.getAsBoolean() ? x : y).getAsDouble()holds.- Parameters:
inTrue- the signal source to consider when the value of this signal source istrueinFalse- the signal source to consider when the value of this signal source isfalse
-
choose
Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of this signal source.At any point in time,
this.choose(x, y).getAsInt() == (this.getAsBoolean() ? x : y).getAsInt()holds.- Parameters:
inTrue- the signal source to consider when the value of this signal source istrueinFalse- the signal source to consider when the value of this signal source isfalse
-
choose
-
choose
Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of this signal source.At any point in time,
this.choose(x, y).getAsBoolean() == (this.getAsBoolean() ? x : y).getAsBoolean()holds.- Parameters:
inTrue- the signal source to consider when the value of this signal source istrueinFalse- the signal source to consider when the value of this signal source isfalse
-
choose
Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of this signal source.At any point in time,
this.choose(x, y).getAsLong() == (this.getAsBoolean() ? x : y).getAsLong()holds.- Parameters:
inTrue- the signal source to consider when the value of this signal source istrueinFalse- the signal source to consider when the value of this signal source isfalse
-
choose
default <E extends Enum<E>> EnumSignalSource<E> choose(EnumSignalSource<E> inTrue, EnumSignalSource<E> inFalse) Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of this signal source.At any point in time,
this.choose(x, y).getAsInt() == (this.getAsBoolean() ? x : y).getAsInt()holds.- Parameters:
inTrue- the signal source to consider when the value of this signal source istrueinFalse- the signal source to consider when the value of this signal source isfalse
-
choose
-
choose
static BooleanSignalSource choose(BooleanSignalSource condition, BooleanSignalSource inTrue, BooleanSignalSource inFalse) Returns a new signal source whose value is that of either of two given type-compatible signal sources, depending on the current value of a condition signal source.At any point in time,
choose(condition, x, y).getAsInt() == (this.getAsBoolean() ? x : y).getAsInt()holds.- Parameters:
condition- the condition signal sourceinTrue- the signal source to consider when the value of the condition signal source istrueinFalse- the signal source to consider when the value of the condition signal source isfalse
-
choose
static <E extends Enum<E>> BooleanSignalSource choose(SignalSource<E> selector, EnumMap<E, ? extends BooleanSignalSource> cases) Returns a new signal source whose value is selected dynamically from a range of cases indexed byenumvalues.At any point in time,
choose(s, m).getAsBoolean() == m.get(s.get()).getAsBoolean()holds.The given map
casesis assumed to be immutable and to contain an entry for every possible value of theenumtypeE.- Type Parameters:
E- the type ofenumvalues- Parameters:
selector- the signal source that provides theenumvaluecases- a map ofenumvalues to signal sources to select from
-
choose
static <E extends Enum<E>> BooleanSignalSource choose(EnumSignalSource<E> selector, EnumMap<E, ? extends BooleanSignalSource> cases) Returns a new signal source whose value is selected dynamically from a range of cases indexed byenumvalues.At any point in time,
choose(s, m).getAsBoolean() == m.get(E.values()[s.getAsInt()]).getAsBoolean()holds.The given map
casesis assumed to be immutable and to contain an entry for every possible value of theenumtypeE.- Type Parameters:
E- the type ofenumvalues- Parameters:
selector- the signal source that provides the ordinal number of theenumvaluecases- a map ofenumvalues to signal sources to select from
-
choose
@SafeVarargs static <E extends Enum<E>> BooleanSignalSource choose(EnumSignalSource<E> selector, BooleanSignalSource... cases) Returns a new signal source whose value is selected dynamically from a range of cases indexed byenumvalues.At any point in time,
choose(s, a).getAsBoolean() == m[s.getAsInt()].getAsBoolean()holds.The given array
casesis assumed to be immutable and to contain an element for every possible value of theenumtypeE.- Type Parameters:
E- the type ofenumvalues- Parameters:
selector- the signal source that provides theenumvaluecases- an array signal sources to select from, in the definition order ofenumelements
-
sampleAndHold
Returns a new clocked signal source whose value at each clock tick is either the current value of this signal source (sample mode), or its own value at the previous clock tick (hold mode), depending on the current value of a given boolean signal source.- Parameters:
hold- a boolean signal source that, at each clock tick, selects hold mode if its value istrue, or sample mode if its value isfalseinitialValue- the initial value to use if in hold mode at the first clock tick
-
power
@Undocumented default BooleanClockedSignalSource power(BinaryOperator<BooleanSignalSource> op, long n) -
compileMainSignalSource
-
publishStoredValueVariable
-
fromArray
Returns a new signal source whose value is an element of a given array, whose index is determined by a given signal source. At execution time, the value of the index signal source must be a valid index in the array, or an exception occurs. (This implies that using an empty array as backing store results in a signal source that cannot be executed.)- Parameters:
data- the array to read fromindex- the signal source that determines the index
-
fromArrayCyclic
Returns a new signal source whose value is an element of a given array, whose index is determined by a given signal source. The value of the index signal source is normalized cyclically (modulo the array length) to a valid index.- Parameters:
data- the array to read fromindex- the signal source that determines the index
-
DEBUG
-