Interface BooleanClockedSignalSource

All Superinterfaces:
AbstractClockedSignalSource, AbstractSignalSource, BooleanSignalSource, BooleanSupplier, CompilableControlFlow, CompilableDataFlow, Component, Process
All Known Implementing Classes:
BooleanDelay, BooleanMultiDelay, BooleanStoredSignalSource, CompilableBooleanStoredSignalSource, NextEvent

public interface BooleanClockedSignalSource extends BooleanSignalSource, AbstractClockedSignalSource
Interface of a signal (time-dependent value) source of primitive type boolean 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 = ...;
 BooleanClockedSignalSource c = ...;
 c.setRealtimeContext(rc);
 c.init();
 while (...) {
   c.step();
   boolean v = c.getAsBoolean();
   ...
 }
 

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:
  • Method Details

    • after

      default BooleanClockedSignalSource after(Process... slaves)
    • during

      default BooleanClockedSignalSource during(Register outer)
    • adHoc

      @SafeVarargs static BooleanClockedSignalSource adHoc(boolean... elems)
      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.getAsBoolean() == (n < elems.length ? elems[n] : false) holds.

      Parameters:
      elems - the array of values to produce
    • cycle

      @SafeVarargs static BooleanClockedSignalSource cycle(boolean... elems)
      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.getAsBoolean() == elems[n % elems.length] holds.

      Parameters:
      elems - the array of values to produce
    • compile

      default BooleanClockedSignalSource 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.

      Specified by:
      compile in interface Process
    • initially

      static BooleanClockedSignalSource initially()
      Returns a new signal source that produces the value true at the first clock tick only.

      At clock index n, this.getAsBoolean() == (n == 0) holds.

    • subsequently

      static BooleanClockedSignalSource subsequently()
      Returns a new signal source that produces the value true at any but the first clock tick.

      At clock index n, this.getAsBoolean() == (n > 0) holds.

    • drain

      default void drain(RealtimeContext rc, boolean[] buffer)
      Write elements from this signal source to a buffer.

      Invoking this method as drain(rc, b) is equivalent to invoking drain(rc, b, 0, b.length).

      Parameters:
      rc - the realtime context
      buffer - the buffer to write to
      See Also:
    • drain

      default void drain(RealtimeContext rc, boolean[] buffer, int offset, int length)
      Write elements from this signal source to a buffer.

      This method first invokes Process.setRealtimeContext(RealtimeContext) and Process.init() to put this signal source in a deterministic initial state. Then it iterates Process.step() and BooleanSignalSource.getAsBoolean() in turn to obtain successive values to write into the buffer.

      Invalid uses that would cause write access outside the bounds of the buffer are detected late; all preceding valid effects occur before an exception is thrown.

      Parameters:
      rc - the realtime context
      buffer - the buffer to write to
      offset - the first index to write to
      length - the number of values to write
      Throws:
      NullPointerException - is buffer is null
      IllegalArgumentException - if length is negative
      ArrayIndexOutOfBoundsException - if offset < 0 or offset + length > buffer.length