Merge pull request 'updates for source sequence counter' (#714) from eive/fsfw:source_seq_counter_update into development
Reviewed-on: fsfw/fsfw#714
This commit is contained in:
commit
8589f4d63a
@ -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); }
|
||||||
|
uint16_t get() const { return this->sequenceCount; }
|
||||||
|
void reset(uint16_t toValue = 0) { sequenceCount = toValue % (ccsds::LIMIT_SEQUENCE_COUNT); }
|
||||||
|
SourceSequenceCounter& operator++(int) {
|
||||||
|
this->increment();
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
void decrement() {
|
SourceSequenceCounter& operator--(int) {
|
||||||
sequenceCount = (sequenceCount - 1) % (SpacePacketBase::LIMIT_SEQUENCE_COUNT);
|
this->decrement();
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
uint16_t get() { return this->sequenceCount; }
|
SourceSequenceCounter& operator=(const uint16_t& newCount) {
|
||||||
void reset(uint16_t toValue = 0) {
|
sequenceCount = newCount;
|
||||||
sequenceCount = toValue % (SpacePacketBase::LIMIT_SEQUENCE_COUNT);
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operator uint16_t() { return this->get(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_ */
|
#endif /* FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user