25 this->m_counterCycle = counterCycle;
29 this->m_timeCycle = timeCycle;
43 this->m_timeAtNegativeInfinity =
true;
47 this->m_counter = counter;
52 this->m_timeAtNegativeInfinity =
false;
66 if (this->m_counterCycle == 0 && this->m_timeCycle == 0) {
71 bool shouldTrigger =
false;
72 if (this->m_counterCycle > 0) {
73 shouldTrigger = shouldTrigger || this->shouldCounterTrigger();
75 if (this->m_timeCycle > 0) {
76 shouldTrigger = shouldTrigger || this->shouldTimeTrigger(time);
80 if (this->m_counterCycle > 0) {
81 this->updateCounter(shouldTrigger);
83 if (this->m_timeCycle > 0) {
84 this->updateTime(shouldTrigger, time);
95 bool RateLimiter ::shouldCounterTrigger() {
99 bool shouldTrigger = (this->m_counter == 0);
101 return shouldTrigger;
104 bool RateLimiter ::shouldTimeTrigger(
Fw::Time time) {
110 bool shouldTrigger = (time >= nextTrigger) || this->m_timeAtNegativeInfinity;
112 return shouldTrigger;
115 void RateLimiter ::updateCounter(
bool triggered) {
124 if (++this->m_counter >= this->m_counterCycle) {
130 void RateLimiter ::updateTime(
bool triggered,
Fw::Time time) {
137 this->m_timeAtNegativeInfinity =
false;
void setTime(Fw::Time time)
static Time zero(TimeBase timeBase=TimeBase::TB_NONE)
void setCounterCycle(U32 counterCycle)
static Time add(const Time &a, const Time &b)
void setTimeCycle(U32 timeCycle)