monitoring changes

This commit is contained in:
Robin Müller 2020-11-18 21:15:14 +01:00
parent 434709ca96
commit cb5fa4a217
5 changed files with 44 additions and 29 deletions

View File

@ -48,10 +48,8 @@ class HousekeepingPacketUpdate;
* @author R. Mueller * @author R. Mueller
*/ */
class LocalDataPoolManager { class LocalDataPoolManager {
template<typename T> template<typename T> friend class LocalPoolVar;
friend class LocalPoolVar; template<typename T, uint16_t vecSize> friend class LocalPoolVector;
template<typename T, uint16_t vecSize>
friend class LocalPoolVector;
friend class LocalPoolDataSetBase; friend class LocalPoolDataSetBase;
friend void (Factory::setStaticFrameworkObjectIds)(); friend void (Factory::setStaticFrameworkObjectIds)();
public: public:
@ -319,7 +317,7 @@ private:
StorageManagerIF* ipcStore = nullptr; StorageManagerIF* ipcStore = nullptr;
/** /**
* Get the pointer to the mutex. Can be used to lock the data pool * Get the pointer to the mutex. Can be used to lock the data pool
* eternally. Use with care and don't forget to unlock locked mutexes! * externally. Use with care and don't forget to unlock locked mutexes!
* For now, only friend classes can accss this function. * For now, only friend classes can accss this function.
* @return * @return
*/ */

View File

@ -8,10 +8,11 @@ template<typename T>
class AbsLimitMonitor: public MonitorBase<T> { class AbsLimitMonitor: public MonitorBase<T> {
public: public:
AbsLimitMonitor(object_id_t reporterId, uint8_t monitorId, AbsLimitMonitor(object_id_t reporterId, uint8_t monitorId,
uint32_t parameterId, uint16_t confirmationLimit, T limit, object_id_t dataCreatorId, lp_id_t localPoolId,
uint16_t confirmationLimit, T limit,
Event violationEvent = MonitoringIF::VALUE_OUT_OF_RANGE, Event violationEvent = MonitoringIF::VALUE_OUT_OF_RANGE,
bool aboveIsViolation = true) : bool aboveIsViolation = true) :
MonitorBase<T>(reporterId, monitorId, parameterId, MonitorBase<T>(reporterId, monitorId, dataCreatorId, localPoolId,
confirmationLimit), confirmationLimit),
limit(limit), violationEvent(violationEvent), limit(limit), violationEvent(violationEvent),
aboveIsViolation(aboveIsViolation) { aboveIsViolation(aboveIsViolation) {

View File

@ -12,13 +12,15 @@
template<typename T> template<typename T>
class LimitMonitor: public MonitorBase<T> { class LimitMonitor: public MonitorBase<T> {
public: public:
LimitMonitor(object_id_t reporterId, uint8_t monitorId, uint32_t parameterId, LimitMonitor(object_id_t reporterId, uint8_t monitorId,
object_id_t creatorId, lp_id_t localPoolId,
uint16_t confirmationLimit, T lowerLimit, T upperLimit, uint16_t confirmationLimit, T lowerLimit, T upperLimit,
Event belowLowEvent = MonitoringIF::VALUE_BELOW_LOW_LIMIT, Event belowLowEvent = MonitoringIF::VALUE_BELOW_LOW_LIMIT,
Event aboveHighEvent = MonitoringIF::VALUE_ABOVE_HIGH_LIMIT) : Event aboveHighEvent = MonitoringIF::VALUE_ABOVE_HIGH_LIMIT) :
MonitorBase<T>(reporterId, monitorId, parameterId, confirmationLimit), lowerLimit( MonitorBase<T>(reporterId, monitorId, creatorId, localPoolId,
lowerLimit), upperLimit(upperLimit), belowLowEvent( confirmationLimit),
belowLowEvent), aboveHighEvent(aboveHighEvent) { lowerLimit(lowerLimit), upperLimit(upperLimit),
belowLowEvent(belowLowEvent), aboveHighEvent(aboveHighEvent) {
} }
virtual ~LimitMonitor() { virtual ~LimitMonitor() {
} }
@ -57,7 +59,8 @@ public:
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
bool isOutOfLimits() { bool isOutOfLimits() {
if (this->oldState == MonitoringIF::ABOVE_HIGH_LIMIT || this->oldState == MonitoringIF::BELOW_LOW_LIMIT) { if (this->oldState == MonitoringIF::ABOVE_HIGH_LIMIT or
this->oldState == MonitoringIF::BELOW_LOW_LIMIT) {
return true; return true;
} else { } else {
return false; return false;
@ -76,10 +79,12 @@ protected:
void sendTransitionEvent(T currentValue, ReturnValue_t state) { void sendTransitionEvent(T currentValue, ReturnValue_t state) {
switch (state) { switch (state) {
case MonitoringIF::BELOW_LOW_LIMIT: case MonitoringIF::BELOW_LOW_LIMIT:
EventManagerIF::triggerEvent(this->reportingId, belowLowEvent, this->parameterId); EventManagerIF::triggerEvent(this->reportingId, belowLowEvent,
this->parameterId);
break; break;
case MonitoringIF::ABOVE_HIGH_LIMIT: case MonitoringIF::ABOVE_HIGH_LIMIT:
EventManagerIF::triggerEvent(this->reportingId, aboveHighEvent, this->parameterId); EventManagerIF::triggerEvent(this->reportingId, aboveHighEvent,
this->parameterId);
break; break;
default: default:
break; break;

View File

@ -6,8 +6,8 @@
#include "MonitoringMessageContent.h" #include "MonitoringMessageContent.h"
#include "MonitorReporter.h" #include "MonitorReporter.h"
#include "../datapoolglob/GlobalDataSet.h" #include "../datapoollocal/LocalPoolVariable.h"
#include "../datapoolglob/PIDReader.h"
/** /**
* @brief Base class for monitoring of parameters. * @brief Base class for monitoring of parameters.
@ -23,13 +23,18 @@
template<typename T> template<typename T>
class MonitorBase: public MonitorReporter<T> { class MonitorBase: public MonitorReporter<T> {
public: public:
MonitorBase(object_id_t reporterId, uint8_t monitorId, MonitorBase(object_id_t reporterId, uint8_t monitorId,
uint32_t parameterId, uint16_t confirmationLimit) : object_id_t dataCreatorId, lp_id_t localPoolId,
MonitorReporter<T>(reporterId, monitorId, parameterId, uint16_t confirmationLimit):
confirmationLimit) { MonitorReporter<T>(reporterId, monitorId, dataCreatorId,
confirmationLimit),
poolVariable(dataCreatorId, localPoolId) {
} }
virtual ~MonitorBase() { virtual ~MonitorBase() {
} }
virtual ReturnValue_t check() { virtual ReturnValue_t check() {
// 1. Fetch sample of type T, return validity. // 1. Fetch sample of type T, return validity.
T sample = 0; T sample = 0;
@ -39,8 +44,8 @@ public:
// Report (if oldState is != invalidity). // Report (if oldState is != invalidity).
if (validity != HasReturnvaluesIF::RETURN_OK) { if (validity != HasReturnvaluesIF::RETURN_OK) {
this->monitorStateIs(validity, sample, 0); this->monitorStateIs(validity, sample, 0);
//3. Otherwise, check sample.
} else { } else {
//3. Otherwise, check sample.
this->oldState = doCheck(sample); this->oldState = doCheck(sample);
} }
return this->oldState; return this->oldState;
@ -55,16 +60,20 @@ public:
virtual ReturnValue_t checkSample(T sample, T* crossedLimit) = 0; virtual ReturnValue_t checkSample(T sample, T* crossedLimit) = 0;
protected: protected:
virtual ReturnValue_t fetchSample(T* sample) { virtual ReturnValue_t fetchSample(T* sample) {
GlobDataSet mySet; ReturnValue_t result = poolVariable.read();
PIDReader<T> parameter(this->parameterId, &mySet); if(result != HasReturnvaluesIF::RETURN_OK) {
mySet.read(); return result;
if (!parameter.isValid()) { }
if (not poolVariable.isValid()) {
return MonitoringIF::INVALID; return MonitoringIF::INVALID;
} }
*sample = parameter.value; *sample = poolVariable.value;
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
LocalPoolVar<T> poolVariable;
}; };
#endif /* FSFW_MONITORING_MONITORBASE_H_ */ #endif /* FSFW_MONITORING_MONITORBASE_H_ */

View File

@ -15,6 +15,8 @@ public:
static const uint8_t ENABLED = 1; static const uint8_t ENABLED = 1;
static const uint8_t DISABLED = 0; static const uint8_t DISABLED = 0;
// TODO: Adapt to use SID instead of parameter ID.
MonitorReporter(object_id_t reportingId, uint8_t monitorId, MonitorReporter(object_id_t reportingId, uint8_t monitorId,
uint32_t parameterId, uint16_t confirmationLimit) : uint32_t parameterId, uint16_t confirmationLimit) :
monitorId(monitorId), parameterId(parameterId), monitorId(monitorId), parameterId(parameterId),