ReduxLib C++ 2024.3.2
|
#include <Frame.h>
Public Member Functions | |
Frame (T value, units::second_t timestamp) | |
void | Update (T value, units::second_t timestamp) |
FrameData< T > | GetFrameData () |
T | GetValue () |
units::second_t | GetTimestamp () |
uint32_t | AddCallback (std::function< void(FrameData< T >)> callback) |
bool | RemoveCallback (uint32_t key) |
void | AddListener (FrameListener< T > *listener) |
void | RemoveListener (FrameListener< T > *listener) |
Class representing periodic timestamped data received from CAN or other sources.
For applications like latency compensation, we often need both sensor/device data and a timestamp of when the data was received. Frames provide this by holding the most recently received raw data and the timestamps they were received at and allowing retrieval of both data and timestamps in one FrameData object via Frame.GetFrameData(), avoiding race conditions involving reading data and timestamp separately. Additionally, they allow for synchronous reads through WaitForFrames by notifying when new data has been received.
|
inline |
Constructs a new Frame object.
value | The initial value to hold. |
timestamp | The initial timestamp at which the value was received in seconds. |
|
inline |
Add a callback that will be run whenever this Frame gets updated. Example application (may not be applicable)
callback | the callback |
|
inline |
Internal use function (for WaitForFrames)
listener | listener pointer to add |
|
inline |
|
inline |
Gets the timestamp in seconds of when this frame was last updated.
|
inline |
Returns the current frame's value.
|
inline |
Unregister a callback run whenever this Frame gets updated.
key | the key returned by AddCallback |
|
inline |
Internal use function (for WaitForFrames)
listener | listener pointer to remove. you must remove your listener before the end of its life or you will cause memory corruption |
|
inline |
Updates the Frame's value, notifying any listeners of new data.
value | the new value |
timestamp | the new timestamp of the received data |