F´ Flight Software - C/C++ Documentation
devel
A framework for building embedded system applications to NASA flight quality standards.
|
RateLimiter
is a pure utility class used for throttling actions, such as components that want to throttle events.
It is mainly used for managing counter state, and providing a simple interface for both updating and evaluating if the action should be performed. The two criteria it supports is simple iteration counter and time-based throttling.
RateLimiter is a class that can be included and instantiated with the initial thresholds ("cycle"):
Either throttling methods (counter or time) can be disabled by giving a value of 0.
Updating and testing if an action should trigger is done in one method:
If you use time-throttling, your component must provide it the current Fw::Time
in the trigger. It will then update its internal state, and return true if the threshold is reached.
The semantics of using both criteria is as follows: once it triggers, it should not trigger again until counterThreshold (from 0) is reached or timeThreshold (from last trigger) is reached, whichever happens first.
In other words, it is either or, rather than both and.