2016-06-15 23:48:41 +02:00
|
|
|
/**
|
|
|
|
* @file SourceSequenceCounter.h
|
|
|
|
* @brief This file defines the SourceSequenceCounter class.
|
|
|
|
* @date 04.02.2013
|
|
|
|
* @author baetz
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SOURCESEQUENCECOUNTER_H_
|
|
|
|
#define SOURCESEQUENCECOUNTER_H_
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "../tmtcpacket/SpacePacketBase.h"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
class SourceSequenceCounter {
|
|
|
|
private:
|
|
|
|
uint16_t sequenceCount;
|
|
|
|
public:
|
|
|
|
SourceSequenceCounter() : sequenceCount(0) {}
|
|
|
|
void increment() {
|
2018-07-13 18:28:26 +02:00
|
|
|
sequenceCount = (sequenceCount+1) % (SpacePacketBase::LIMIT_SEQUENCE_COUNT);
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
void decrement() {
|
2018-07-13 18:28:26 +02:00
|
|
|
sequenceCount = (sequenceCount-1) % (SpacePacketBase::LIMIT_SEQUENCE_COUNT);
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
uint16_t get() { return this->sequenceCount; }
|
|
|
|
void reset(uint16_t toValue = 0) {
|
|
|
|
sequenceCount = toValue % (SpacePacketBase::LIMIT_SEQUENCE_COUNT);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* SOURCESEQUENCECOUNTER_H_ */
|