fsfw/housekeeping/HousekeepingSetPacket.h

60 lines
1.9 KiB
C
Raw Normal View History

2020-09-19 01:17:43 +02:00
#ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_
#define FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_
2020-09-19 02:46:29 +02:00
#include "../housekeeping/HousekeepingMessage.h"
2020-09-19 01:17:43 +02:00
#include "../serialize/SerialLinkedListAdapter.h"
2020-09-19 02:46:29 +02:00
#include "../datapoollocal/LocalPoolDataSetBase.h"
2020-09-19 01:17:43 +02:00
class HousekeepingSetPacket: public SerialLinkedListAdapter<SerializeIF> {
2020-09-19 02:46:29 +02:00
public:
HousekeepingSetPacket(sid_t sid, bool reportingEnabled, bool valid,
float collectionInterval, LocalPoolDataSetBase* dataSetPtr):
objectId(sid.objectId), setId(sid.ownerSetId),
reportingEnabled(reportingEnabled), valid(valid),
collectionIntervalSeconds(collectionInterval), dataSet(dataSetPtr) {
2020-09-28 16:56:42 +02:00
setLinks();
2020-09-19 02:46:29 +02:00
}
2020-09-19 01:17:43 +02:00
2020-09-19 02:46:29 +02:00
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
size_t maxSize, Endianness streamEndianness) const override {
ReturnValue_t result = SerialLinkedListAdapter::serialize(buffer, size,
maxSize, streamEndianness);
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return dataSet->serializeLocalPoolIds(buffer, size ,maxSize,
streamEndianness);
}
2020-09-19 01:17:43 +02:00
2020-09-19 02:46:29 +02:00
size_t getSerializedSize() const override {
size_t linkedSize = SerialLinkedListAdapter::getSerializedSize();
2020-09-28 21:09:56 +02:00
linkedSize += dataSet->getLocalPoolIdsSerializedSize();
2020-09-19 02:46:29 +02:00
return linkedSize;
}
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override {
return HasReturnvaluesIF::RETURN_OK;
}
2020-09-19 01:17:43 +02:00
2020-09-19 02:46:29 +02:00
private:
2020-09-19 01:17:43 +02:00
2020-09-19 02:46:29 +02:00
void setLinks() {
setStart(&objectId);
objectId.setNext(&setId);
setId.setNext(&reportingEnabled);
reportingEnabled.setNext(&valid);
valid.setNext(&collectionIntervalSeconds);
collectionIntervalSeconds.setEnd();
}
SerializeElement<object_id_t> objectId;
SerializeElement<uint32_t> setId;
SerializeElement<bool> reportingEnabled;
SerializeElement<bool> valid;
SerializeElement<float> collectionIntervalSeconds;
LocalPoolDataSetBase* dataSet;
};
2020-09-19 01:17:43 +02:00
#endif /* FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_ */