Merge pull request 'Default Time Stamper' (#199) from KSat/fsfw:mueller/feature/timeStamper into master
Reviewed-on: fsfw/fsfw#199
This commit is contained in:
commit
1791b5af57
23
timemanager/TimeStamper.cpp
Normal file
23
timemanager/TimeStamper.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include "TimeStamper.h"
|
||||
#include "Clock.h"
|
||||
#include <cstring>
|
||||
|
||||
TimeStamper::TimeStamper(object_id_t objectId): SystemObject(objectId) {}
|
||||
|
||||
|
||||
ReturnValue_t TimeStamper::addTimeStamp(uint8_t* buffer,
|
||||
const uint8_t maxSize) {
|
||||
if(maxSize < TimeStamperIF::MISSION_TIMESTAMP_SIZE){
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
timeval now;
|
||||
Clock::getClock_timeval(&now);
|
||||
CCSDSTime::CDS_short cds;
|
||||
ReturnValue_t result = CCSDSTime::convertToCcsds(&cds,&now);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
std::memcpy(buffer,&cds,sizeof(cds));
|
||||
return result;
|
||||
}
|
36
timemanager/TimeStamper.h
Normal file
36
timemanager/TimeStamper.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef FSFW_TIMEMANAGER_TIMESTAMPER_H_
|
||||
#define FSFW_TIMEMANAGER_TIMESTAMPER_H_
|
||||
|
||||
#include "TimeStamperIF.h"
|
||||
#include "CCSDSTime.h"
|
||||
#include "../objectmanager/SystemObject.h"
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
class TimeStamper: public TimeStamperIF, public SystemObject {
|
||||
public:
|
||||
/**
|
||||
* @brief Default constructor which also registers the time stamper as a
|
||||
* system object so it can be found with the #objectManager.
|
||||
* @param objectId
|
||||
*/
|
||||
TimeStamper(object_id_t objectId);
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
virtual ReturnValue_t addTimeStamp(uint8_t* buffer, const uint8_t maxSize);
|
||||
};
|
||||
|
||||
#endif /* FSFW_TIMEMANAGER_TIMESTAMPER_H_ */
|
Loading…
Reference in New Issue
Block a user