fsfw/tmtcservices/SourceSequenceCounter.h

25 lines
687 B
C
Raw Normal View History

2020-12-14 21:31:50 +01:00
#ifndef FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_
#define FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_
2020-08-28 18:33:29 +02:00
#include "../tmtcpacket/SpacePacketBase.h"
class SourceSequenceCounter {
private:
uint16_t sequenceCount;
public:
SourceSequenceCounter() : sequenceCount(0) {}
void increment() {
sequenceCount = (sequenceCount+1) % (SpacePacketBase::LIMIT_SEQUENCE_COUNT);
}
void decrement() {
sequenceCount = (sequenceCount-1) % (SpacePacketBase::LIMIT_SEQUENCE_COUNT);
}
uint16_t get() { return this->sequenceCount; }
void reset(uint16_t toValue = 0) {
sequenceCount = toValue % (SpacePacketBase::LIMIT_SEQUENCE_COUNT);
}
};
2020-12-14 21:31:50 +01:00
#endif /* FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_ */