fsfw/src/fsfw/fdir/EventCorrelation.cpp

43 lines
918 B
C++
Raw Normal View History

2021-07-13 20:22:54 +02:00
#include "fsfw/fdir/EventCorrelation.h"
2022-02-02 10:29:30 +01:00
EventCorrelation::EventCorrelation(uint32_t timeout) : eventPending(false) {
correlationTimer.setTimeout(timeout);
}
2022-02-02 10:29:30 +01:00
EventCorrelation::~EventCorrelation() {}
EventCorrelation::State EventCorrelation::doesEventCorrelate() {
2022-02-02 10:29:30 +01:00
if (correlationTimer.isBusy()) {
eventPending = false;
return CORRELATED;
} else {
if (eventPending) {
return ALREADY_STARTED;
} else {
eventPending = true;
correlationTimer.resetTimer();
return CORRELATION_STARTED;
}
}
}
bool EventCorrelation::isEventPending() {
2022-02-02 10:29:30 +01:00
if (eventPending) {
eventPending = false;
return true;
} else {
correlationTimer.resetTimer();
return false;
}
}
bool EventCorrelation::hasPendingEventTimedOut() {
2022-02-02 10:29:30 +01:00
if (correlationTimer.hasTimedOut()) {
bool temp = eventPending;
eventPending = false;
return temp;
} else {
return false;
}
}