2016-06-15 23:48:41 +02:00
|
|
|
#ifndef MONITORINGMESSAGECONTENT_H_
|
|
|
|
#define MONITORINGMESSAGECONTENT_H_
|
|
|
|
|
2021-01-12 19:58:29 +01:00
|
|
|
#include <fsfw/datapoollocal/localPoolDefinitions.h>
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "HasMonitorsIF.h"
|
|
|
|
#include "MonitoringIF.h"
|
|
|
|
#include "../objectmanager/ObjectManagerIF.h"
|
|
|
|
#include "../serialize/SerialBufferAdapter.h"
|
|
|
|
#include "../serialize/SerialFixedArrayListAdapter.h"
|
|
|
|
#include "../serialize/SerializeElement.h"
|
|
|
|
#include "../serialize/SerialLinkedListAdapter.h"
|
|
|
|
#include "../serviceinterface/ServiceInterfaceStream.h"
|
|
|
|
#include "../timemanager/TimeStamperIF.h"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2018-07-12 16:29:32 +02:00
|
|
|
namespace Factory{
|
|
|
|
void setStaticFrameworkObjectIds();
|
|
|
|
}
|
|
|
|
|
2016-06-15 23:48:41 +02:00
|
|
|
//PID(uint32_t), TYPE, LIMIT_ID, value,limitValue, previous, later, timestamp
|
2020-12-03 18:24:51 +01:00
|
|
|
/**
|
|
|
|
* @brief Does magic.
|
|
|
|
* @tparam T
|
|
|
|
*/
|
2016-06-15 23:48:41 +02:00
|
|
|
template<typename T>
|
|
|
|
class MonitoringReportContent: public SerialLinkedListAdapter<SerializeIF> {
|
2018-07-12 16:29:32 +02:00
|
|
|
friend void (Factory::setStaticFrameworkObjectIds)();
|
2016-06-15 23:48:41 +02:00
|
|
|
public:
|
|
|
|
SerializeElement<uint8_t> monitorId;
|
2020-12-03 18:24:51 +01:00
|
|
|
SerializeElement<uint32_t> parameterObjectId;
|
|
|
|
SerializeElement<lp_id_t> localPoolId;
|
2016-06-15 23:48:41 +02:00
|
|
|
SerializeElement<T> parameterValue;
|
|
|
|
SerializeElement<T> limitValue;
|
|
|
|
SerializeElement<ReturnValue_t> oldState;
|
|
|
|
SerializeElement<ReturnValue_t> newState;
|
|
|
|
uint8_t rawTimestamp[TimeStamperIF::MISSION_TIMESTAMP_SIZE];
|
2018-07-12 16:29:32 +02:00
|
|
|
SerializeElement<SerialBufferAdapter<uint8_t>> timestampSerializer;
|
2016-06-15 23:48:41 +02:00
|
|
|
TimeStamperIF* timeStamper;
|
|
|
|
MonitoringReportContent() :
|
2020-12-03 18:24:51 +01:00
|
|
|
SerialLinkedListAdapter<SerializeIF>(¶meterObjectId),
|
|
|
|
monitorId(0), parameterObjectId(0),
|
|
|
|
localPoolId(0), parameterValue(0),
|
|
|
|
limitValue(0), oldState(0), newState(0),
|
|
|
|
rawTimestamp( { 0 }), timestampSerializer(rawTimestamp,
|
2016-06-15 23:48:41 +02:00
|
|
|
sizeof(rawTimestamp)), timeStamper(NULL) {
|
|
|
|
setAllNext();
|
|
|
|
}
|
2020-12-03 18:24:51 +01:00
|
|
|
MonitoringReportContent(gp_id_t globalPoolId, T value, T limitValue,
|
2016-06-15 23:48:41 +02:00
|
|
|
ReturnValue_t oldState, ReturnValue_t newState) :
|
2020-12-03 18:24:51 +01:00
|
|
|
SerialLinkedListAdapter<SerializeIF>(¶meterObjectId),
|
|
|
|
monitorId(0), parameterObjectId(globalPoolId.objectId),
|
|
|
|
localPoolId(globalPoolId.localPoolId),
|
|
|
|
parameterValue(value), limitValue(limitValue),
|
|
|
|
oldState(oldState), newState(newState),
|
|
|
|
timestampSerializer(rawTimestamp, sizeof(rawTimestamp)),
|
|
|
|
timeStamper(NULL) {
|
2016-06-15 23:48:41 +02:00
|
|
|
setAllNext();
|
|
|
|
if (checkAndSetStamper()) {
|
|
|
|
timeStamper->addTimeStamp(rawTimestamp, sizeof(rawTimestamp));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private:
|
2018-07-12 16:29:32 +02:00
|
|
|
|
|
|
|
static object_id_t timeStamperId;
|
2016-06-15 23:48:41 +02:00
|
|
|
void setAllNext() {
|
2020-12-03 18:24:51 +01:00
|
|
|
parameterObjectId.setNext(¶meterValue);
|
2016-06-15 23:48:41 +02:00
|
|
|
parameterValue.setNext(&limitValue);
|
|
|
|
limitValue.setNext(&oldState);
|
|
|
|
oldState.setNext(&newState);
|
|
|
|
newState.setNext(×tampSerializer);
|
|
|
|
}
|
|
|
|
bool checkAndSetStamper() {
|
2020-12-03 18:24:51 +01:00
|
|
|
if (timeStamper == nullptr) {
|
2018-07-12 16:29:32 +02:00
|
|
|
timeStamper = objectManager->get<TimeStamperIF>( timeStamperId );
|
2020-12-03 18:24:51 +01:00
|
|
|
if ( timeStamper == nullptr ) {
|
2021-01-03 14:16:52 +01:00
|
|
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
2020-04-23 19:13:18 +02:00
|
|
|
sif::error << "MonitoringReportContent::checkAndSetStamper: "
|
|
|
|
"Stamper not found!" << std::endl;
|
2021-01-03 13:58:18 +01:00
|
|
|
#endif
|
2016-06-15 23:48:41 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
template<typename T>
|
2018-07-12 16:29:32 +02:00
|
|
|
object_id_t MonitoringReportContent<T>::timeStamperId = 0;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
#endif /* MONITORINGMESSAGECONTENT_H_ */
|