2020-09-16 19:36:15 +02:00
|
|
|
#ifndef FSFW_TIMEMANAGER_TIMESTAMPER_H_
|
|
|
|
#define FSFW_TIMEMANAGER_TIMESTAMPER_H_
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
#include "CCSDSTime.h"
|
2022-07-27 17:33:39 +02:00
|
|
|
#include "TimeReaderIF.h"
|
2022-02-02 10:29:30 +01:00
|
|
|
#include "TimeStamperIF.h"
|
2022-07-21 11:34:11 +02:00
|
|
|
#include "fsfw/objectmanager/SystemObject.h"
|
2020-09-16 19:36:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Time stamper which can be used to add any timestamp to a
|
|
|
|
* given buffer.
|
|
|
|
* @details
|
|
|
|
* This time stamper uses the CCSDS CDC short timestamp as a fault timestamp.
|
|
|
|
* This timestamp has a size of 8 bytes. A custom timestamp can be used by
|
|
|
|
* overriding the #addTimeStamp function.
|
|
|
|
* @ingroup utility
|
|
|
|
*/
|
2022-07-27 17:33:39 +02:00
|
|
|
class CdsShortTimeStamper : public TimeStamperIF, public TimeReaderIF, public SystemObject {
|
2022-02-02 10:29:30 +01:00
|
|
|
public:
|
2022-07-20 22:21:15 +02:00
|
|
|
static constexpr size_t TIMESTAMP_LEN = 7;
|
2022-02-02 10:29:30 +01:00
|
|
|
/**
|
|
|
|
* @brief Default constructor which also registers the time stamper as a
|
|
|
|
* system object so it can be found with the #objectManager.
|
|
|
|
* @param objectId
|
|
|
|
*/
|
2022-07-20 22:21:15 +02:00
|
|
|
explicit CdsShortTimeStamper(object_id_t objectId);
|
2020-09-16 19:36:15 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
/**
|
|
|
|
* Adds a CCSDS CDC short 8 byte timestamp to the given buffer.
|
|
|
|
* This function can be overriden to use a custom timestamp.
|
|
|
|
* @param buffer
|
|
|
|
* @param maxSize
|
|
|
|
* @return
|
|
|
|
*/
|
2022-07-20 22:21:15 +02:00
|
|
|
ReturnValue_t addTimeStamp(uint8_t *buffer, uint8_t maxSize) override;
|
|
|
|
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
|
|
|
Endianness streamEndianness) const override;
|
2022-07-21 11:34:11 +02:00
|
|
|
[[nodiscard]] size_t getSerializedSize() const override;
|
2022-07-20 22:21:15 +02:00
|
|
|
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
|
|
|
Endianness streamEndianness) override;
|
2022-07-27 17:33:39 +02:00
|
|
|
ReturnValue_t readTimeStamp(const uint8_t *buffer, size_t maxSize) override;
|
|
|
|
timeval &getTime() override;
|
2022-07-21 11:34:11 +02:00
|
|
|
[[nodiscard]] size_t getTimestampSize() const override;
|
2022-07-27 17:33:39 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
timeval readTime{};
|
2020-09-16 19:36:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* FSFW_TIMEMANAGER_TIMESTAMPER_H_ */
|