Package com.reduxrobotics.frames
Class DoubleFrame<T>
java.lang.Object
com.reduxrobotics.frames.Frame<T>
com.reduxrobotics.frames.DoubleFrame<T>
Implements an object-holding Frame backed by a double.
This avoids creation of new objects by only converting to objects when the value is requested
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional interface for a function mapping a double data value to the final frame type.Nested classes/interfaces inherited from class com.reduxrobotics.frames.Frame
Frame.FrameCallback<FC> -
Constructor Summary
ConstructorsConstructorDescriptionDoubleFrame(double initialData, double timestamp, T defaultData, DoubleFrame.DoubleToType<T> conversion) Instantiates a new DoubleFrame. -
Method Summary
Modifier and TypeMethodDescriptionvoidFlag that this frame's data is not valid.doublegetData()Gets the underlying double data.getValue()Returns the value of the data frame.booleanhasData()Returns if this frame has data.voidupdateData(double data, double timestamp) Update the DoubleFrame with new double-backed data.Methods inherited from class com.reduxrobotics.frames.Frame
addCallback, getFrameData, getTimestamp, maxTimestamp, removeCallback, update, waitForFrames
-
Constructor Details
-
DoubleFrame
public DoubleFrame(double initialData, double timestamp, T defaultData, DoubleFrame.DoubleToType<T> conversion) Instantiates a new DoubleFrame.- Parameters:
initialData- The initial double data for the frame to hold.timestamp- The timestamp the update happened at.defaultData- An instance of the object to return before the first update happens.conversion- A function that takes in a double and converts it to the final datatype.
-
-
Method Details
-
getValue
Description copied from class:FrameReturns the value of the data frame. -
hasData
public boolean hasData()Returns if this frame has data. -
clearData
public void clearData()Flag that this frame's data is not valid. -
getData
public double getData()Gets the underlying double data.- Returns:
- the double data as a type.
-
updateData
public void updateData(double data, double timestamp) Update the DoubleFrame with new double-backed data.- Parameters:
data- the new data to update withtimestamp- the timestamp at which it occured
-