Package frc.lib

Class HighFreqBuffer

java.lang.Object
frc.lib.HighFreqBuffer

public class HighFreqBuffer extends Object
A buffer for storing synchronized high-frequency data points across multiple signals. Handles N signals per timestamp with zero-allocation performance.
  • Constructor Summary

    Constructors
    Constructor
    Description
    HighFreqBuffer(int numSignals)
    Creates a new HighFreqBuffer with a specific number of value signals.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    drain(double[][] outTimestamps, double[][]... outValueWrappers)
    Drains the buffer contents into the provided AdvantageKit array wrappers.
    void
    offer(double timestamp, double v0)
    Offers a new data point for a single signal.
    void
    offer(double timestamp, double[] values)
    Generic offer for N signals.
    void
    offer(double timestamp, double v0, double v1)
    Offers a new data point for two signals.
    void
    offer(double timestamp, double v0, double v1, double v2)
    Offers a new data point for three signals.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HighFreqBuffer

      public HighFreqBuffer(int numSignals)
      Creates a new HighFreqBuffer with a specific number of value signals.
      Parameters:
      numSignals - The number of data streams to associate with the timestamp stream.
  • Method Details

    • offer

      public void offer(double timestamp, double v0)
      Offers a new data point for a single signal. Overloaded to avoid varargs array allocation.
      Parameters:
      timestamp - The timestamp for the data point.
      v0 - The value for the first signal.
    • offer

      public void offer(double timestamp, double v0, double v1)
      Offers a new data point for two signals. Overloaded to avoid varargs array allocation.
      Parameters:
      timestamp - The timestamp for the data point.
      v0 - The value for the first signal.
      v1 - The value for the second signal.
    • offer

      public void offer(double timestamp, double v0, double v1, double v2)
      Offers a new data point for three signals. Overloaded to avoid varargs array allocation.
      Parameters:
      timestamp - The timestamp for the data point.
      v0 - The value for the first signal.
      v1 - The value for the second signal.
      v2 - The value for the third signal.
    • offer

      public void offer(double timestamp, double[] values)
      Generic offer for N signals. Note: Use specific overloads for 2 or 3 signals to remain 100% GC-free.
      Parameters:
      timestamp - The timestamp for the data point.
      values - The values for the signals.
    • drain

      public void drain(double[][] outTimestamps, double[][]... outValueWrappers)
      Drains the buffer contents into the provided AdvantageKit array wrappers.
      Parameters:
      outTimestamps - A wrapper (double[1][N]) for the timestamp array.
      outValueWrappers - An array of wrappers, one for each signal provided in the constructor.