updates for source sequence counter

This commit is contained in:
Robin Müller 2022-11-28 08:30:45 +01:00
parent d6ee2ed400
commit ecde164f68
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
1 changed files with 18 additions and 10 deletions

View File

@ -5,20 +5,28 @@
class SourceSequenceCounter { class SourceSequenceCounter {
private: private:
uint16_t sequenceCount; uint16_t sequenceCount = 0;
public: public:
SourceSequenceCounter() : sequenceCount(0) {} SourceSequenceCounter(uint16_t initialSequenceCount = 0) : sequenceCount(initialSequenceCount) {}
void increment() { void increment() { sequenceCount = (sequenceCount + 1) % (ccsds::LIMIT_SEQUENCE_COUNT); }
sequenceCount = (sequenceCount + 1) % (SpacePacketBase::LIMIT_SEQUENCE_COUNT); void decrement() { sequenceCount = (sequenceCount - 1) % (ccsds::LIMIT_SEQUENCE_COUNT); }
}
void decrement() {
sequenceCount = (sequenceCount - 1) % (SpacePacketBase::LIMIT_SEQUENCE_COUNT);
}
uint16_t get() { return this->sequenceCount; } uint16_t get() { return this->sequenceCount; }
void reset(uint16_t toValue = 0) { void reset(uint16_t toValue = 0) { sequenceCount = toValue % (ccsds::LIMIT_SEQUENCE_COUNT); }
sequenceCount = toValue % (SpacePacketBase::LIMIT_SEQUENCE_COUNT); SourceSequenceCounter& operator++(int) {
this->increment();
return *this;
} }
SourceSequenceCounter& operator--(int) {
this->decrement();
return *this;
}
SourceSequenceCounter& operator=(const uint16_t& newCount) {
sequenceCount = newCount;
return *this;
}
operator uint16_t() { return this->get(); }
}; };
#endif /* FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_ */ #endif /* FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_ */