From cb5fa4a2175bc684e21fb885c94a420b97e680a8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 18 Nov 2020 21:15:14 +0100 Subject: [PATCH] monitoring changes --- datapoollocal/LocalDataPoolManager.h | 10 +++----- monitoring/AbsLimitMonitor.h | 5 ++-- monitoring/LimitMonitor.h | 19 ++++++++------ monitoring/MonitorBase.h | 37 +++++++++++++++++----------- monitoring/MonitorReporter.h | 2 ++ 5 files changed, 44 insertions(+), 29 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index 187ae5d5..38714cc9 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -48,11 +48,9 @@ class HousekeepingPacketUpdate; * @author R. Mueller */ class LocalDataPoolManager { - template - friend class LocalPoolVar; - template - friend class LocalPoolVector; - friend class LocalPoolDataSetBase; + template friend class LocalPoolVar; + template friend class LocalPoolVector; + friend class LocalPoolDataSetBase; friend void (Factory::setStaticFrameworkObjectIds)(); public: static constexpr uint8_t INTERFACE_ID = CLASS_ID::HOUSEKEEPING_MANAGER; @@ -319,7 +317,7 @@ private: StorageManagerIF* ipcStore = nullptr; /** * 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. * @return */ diff --git a/monitoring/AbsLimitMonitor.h b/monitoring/AbsLimitMonitor.h index 5891c36a..d85d5b61 100644 --- a/monitoring/AbsLimitMonitor.h +++ b/monitoring/AbsLimitMonitor.h @@ -8,10 +8,11 @@ template class AbsLimitMonitor: public MonitorBase { public: 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, bool aboveIsViolation = true) : - MonitorBase(reporterId, monitorId, parameterId, + MonitorBase(reporterId, monitorId, dataCreatorId, localPoolId, confirmationLimit), limit(limit), violationEvent(violationEvent), aboveIsViolation(aboveIsViolation) { diff --git a/monitoring/LimitMonitor.h b/monitoring/LimitMonitor.h index abcbe8e8..fdb05018 100644 --- a/monitoring/LimitMonitor.h +++ b/monitoring/LimitMonitor.h @@ -12,13 +12,15 @@ template class LimitMonitor: public MonitorBase { 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, Event belowLowEvent = MonitoringIF::VALUE_BELOW_LOW_LIMIT, Event aboveHighEvent = MonitoringIF::VALUE_ABOVE_HIGH_LIMIT) : - MonitorBase(reporterId, monitorId, parameterId, confirmationLimit), lowerLimit( - lowerLimit), upperLimit(upperLimit), belowLowEvent( - belowLowEvent), aboveHighEvent(aboveHighEvent) { + MonitorBase(reporterId, monitorId, creatorId, localPoolId, + confirmationLimit), + lowerLimit(lowerLimit), upperLimit(upperLimit), + belowLowEvent(belowLowEvent), aboveHighEvent(aboveHighEvent) { } virtual ~LimitMonitor() { } @@ -57,7 +59,8 @@ public: return HasReturnvaluesIF::RETURN_OK; } 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; } else { return false; @@ -76,10 +79,12 @@ protected: void sendTransitionEvent(T currentValue, ReturnValue_t state) { switch (state) { case MonitoringIF::BELOW_LOW_LIMIT: - EventManagerIF::triggerEvent(this->reportingId, belowLowEvent, this->parameterId); + EventManagerIF::triggerEvent(this->reportingId, belowLowEvent, + this->parameterId); break; case MonitoringIF::ABOVE_HIGH_LIMIT: - EventManagerIF::triggerEvent(this->reportingId, aboveHighEvent, this->parameterId); + EventManagerIF::triggerEvent(this->reportingId, aboveHighEvent, + this->parameterId); break; default: break; diff --git a/monitoring/MonitorBase.h b/monitoring/MonitorBase.h index 5f9a2caf..df6f1af8 100644 --- a/monitoring/MonitorBase.h +++ b/monitoring/MonitorBase.h @@ -6,8 +6,8 @@ #include "MonitoringMessageContent.h" #include "MonitorReporter.h" -#include "../datapoolglob/GlobalDataSet.h" -#include "../datapoolglob/PIDReader.h" +#include "../datapoollocal/LocalPoolVariable.h" + /** * @brief Base class for monitoring of parameters. @@ -23,13 +23,18 @@ template class MonitorBase: public MonitorReporter { public: + MonitorBase(object_id_t reporterId, uint8_t monitorId, - uint32_t parameterId, uint16_t confirmationLimit) : - MonitorReporter(reporterId, monitorId, parameterId, - confirmationLimit) { + object_id_t dataCreatorId, lp_id_t localPoolId, + uint16_t confirmationLimit): + MonitorReporter(reporterId, monitorId, dataCreatorId, + confirmationLimit), + poolVariable(dataCreatorId, localPoolId) { } + virtual ~MonitorBase() { } + virtual ReturnValue_t check() { // 1. Fetch sample of type T, return validity. T sample = 0; @@ -39,8 +44,8 @@ public: // Report (if oldState is != invalidity). if (validity != HasReturnvaluesIF::RETURN_OK) { this->monitorStateIs(validity, sample, 0); - //3. Otherwise, check sample. } else { + //3. Otherwise, check sample. this->oldState = doCheck(sample); } return this->oldState; @@ -55,16 +60,20 @@ public: virtual ReturnValue_t checkSample(T sample, T* crossedLimit) = 0; protected: + virtual ReturnValue_t fetchSample(T* sample) { - GlobDataSet mySet; - PIDReader parameter(this->parameterId, &mySet); - mySet.read(); - if (!parameter.isValid()) { - return MonitoringIF::INVALID; - } - *sample = parameter.value; - return HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = poolVariable.read(); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if (not poolVariable.isValid()) { + return MonitoringIF::INVALID; + } + *sample = poolVariable.value; + return HasReturnvaluesIF::RETURN_OK; } + + LocalPoolVar poolVariable; }; #endif /* FSFW_MONITORING_MONITORBASE_H_ */ diff --git a/monitoring/MonitorReporter.h b/monitoring/MonitorReporter.h index 286d82cf..d33f34d5 100644 --- a/monitoring/MonitorReporter.h +++ b/monitoring/MonitorReporter.h @@ -15,6 +15,8 @@ public: static const uint8_t ENABLED = 1; static const uint8_t DISABLED = 0; + // TODO: Adapt to use SID instead of parameter ID. + MonitorReporter(object_id_t reportingId, uint8_t monitorId, uint32_t parameterId, uint16_t confirmationLimit) : monitorId(monitorId), parameterId(parameterId),