1
0
forked from fsfw/fsfw

some more form improvements

This commit is contained in:
2020-10-12 17:42:30 +02:00
parent 06c7919daa
commit 736ce2d5fd
2 changed files with 37 additions and 25 deletions

View File

@ -1,35 +1,42 @@
#ifndef MONITORBASE_H_
#define MONITORBASE_H_
#ifndef FSFW_MONITORING_MONITORBASE_H_
#define FSFW_MONITORING_MONITORBASE_H_
#include "../datapoolglob/GlobalDataSet.h"
#include "../datapoolglob/PIDReader.h"
#include "LimitViolationReporter.h"
#include "MonitoringIF.h"
#include "MonitoringMessageContent.h"
#include "MonitorReporter.h"
#include "../datapoolglob/GlobalDataSet.h"
#include "../datapoolglob/PIDReader.h"
/**
* Base class for monitoring of parameters.
* Can be used anywhere, specializations need to implement checkSample and should override sendTransitionEvent.
* Manages state handling, enabling and disabling of events/reports and forwarding of transition
* reports via MonitorReporter. In addition, it provides default implementations for fetching the parameter sample from
* the data pool and a simple confirmation counter.
* @brief Base class for monitoring of parameters.
* @details
* Can be used anywhere, specializations need to implement checkSample and
* should override sendTransitionEvent.
* Manages state handling, enabling and disabling of events/reports and
* forwarding of transition reports via MonitorReporter.
*
* In addition, it provides default implementations for fetching the
* parameter sample from the data pool and a simple confirmation counter.
*/
template<typename T>
class MonitorBase: public MonitorReporter<T> {
public:
MonitorBase(object_id_t reporterId, uint8_t monitorId,
uint32_t parameterId, uint16_t confirmationLimit) :
MonitorReporter<T>(reporterId, monitorId, parameterId, confirmationLimit) {
MonitorReporter<T>(reporterId, monitorId, parameterId,
confirmationLimit) {
}
virtual ~MonitorBase() {
}
virtual ReturnValue_t check() {
//1. Fetch sample of type T, return validity.
// 1. Fetch sample of type T, return validity.
T sample = 0;
ReturnValue_t validity = fetchSample(&sample);
//2. If returning from fetch != OK, parameter is invalid. Report (if oldState is != invalidity).
// 2. If returning from fetch != OK, parameter is invalid.
// Report (if oldState is != invalidity).
if (validity != HasReturnvaluesIF::RETURN_OK) {
this->monitorStateIs(validity, sample, 0);
//3. Otherwise, check sample.
@ -43,7 +50,8 @@ public:
ReturnValue_t currentState = checkSample(sample, &crossedLimit);
return this->monitorStateIs(currentState,sample, crossedLimit);
}
//Abstract or default.
// Abstract or default.
virtual ReturnValue_t checkSample(T sample, T* crossedLimit) = 0;
protected:
@ -59,4 +67,4 @@ protected:
}
};
#endif /* MONITORBASE_H_ */
#endif /* FSFW_MONITORING_MONITORBASE_H_ */