Package com.reduxrobotics.frames
Class ByteArrayFrame<T>
java.lang.Object
com.reduxrobotics.frames.Frame<T>
com.reduxrobotics.frames.ByteArrayFrame<T>
Implements an object-holding Frame backed by a byte array.
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
ConstructorsConstructorDescriptionByteArrayFrame(int capacity, double timestamp, T defaultData, ByteArrayFrame.ByteArrayToType<T> conversion) Instantiates a new ByteArrayFrame. -
Method Summary
Modifier and TypeMethodDescriptionvoidFlag that this frame's data is not valid.byte[]getData()Gets the underlying byte array data.getValue()Returns the value of the data frame.booleanhasData()Returns if this frame has data.voidupdateData(byte[] data, double timestamp) Update the ByteArrayFrame with new byte array data.Methods inherited from class com.reduxrobotics.frames.Frame
addCallback, getFrameData, getTimestamp, maxTimestamp, removeCallback, update, waitForFrames
-
Constructor Details
-
ByteArrayFrame
public ByteArrayFrame(int capacity, double timestamp, T defaultData, ByteArrayFrame.ByteArrayToType<T> conversion) Instantiates a new ByteArrayFrame.- Parameters:
capacity- The capacity of the byte array value held.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 byte[] getData()Gets the underlying byte array data.- Returns:
- the byte array data as a type.
-
updateData
public void updateData(byte[] data, double timestamp) Update the ByteArrayFrame with new byte array data.- Parameters:
data- the new data to update withtimestamp- the timestamp at which it occured
-