Package frc.lib
Class HighFreqBuffer
java.lang.Object
frc.lib.HighFreqBuffer
A buffer for storing synchronized high-frequency data points across multiple signals. Handles N
signals per timestamp with zero-allocation performance.
-
Constructor Summary
ConstructorsConstructorDescriptionHighFreqBuffer(int numSignals) Creates a new HighFreqBuffer with a specific number of value signals. -
Method Summary
Modifier and TypeMethodDescriptionvoiddrain(double[][] outTimestamps, double[][]... outValueWrappers) Drains the buffer contents into the provided AdvantageKit array wrappers.voidoffer(double timestamp, double v0) Offers a new data point for a single signal.voidoffer(double timestamp, double[] values) Generic offer for N signals.voidoffer(double timestamp, double v0, double v1) Offers a new data point for two signals.voidoffer(double timestamp, double v0, double v1, double v2) Offers a new data point for three signals.
-
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.
-