monitoring changes
This commit is contained in:
parent
434709ca96
commit
cb5fa4a217
@ -48,11 +48,9 @@ class HousekeepingPacketUpdate;
|
||||
* @author R. Mueller
|
||||
*/
|
||||
class LocalDataPoolManager {
|
||||
template<typename T>
|
||||
friend class LocalPoolVar;
|
||||
template<typename T, uint16_t vecSize>
|
||||
friend class LocalPoolVector;
|
||||
friend class LocalPoolDataSetBase;
|
||||
template<typename T> friend class LocalPoolVar;
|
||||
template<typename T, uint16_t vecSize> 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
|
||||
*/
|
||||
|
@ -8,10 +8,11 @@ template<typename T>
|
||||
class AbsLimitMonitor: public MonitorBase<T> {
|
||||
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<T>(reporterId, monitorId, parameterId,
|
||||
MonitorBase<T>(reporterId, monitorId, dataCreatorId, localPoolId,
|
||||
confirmationLimit),
|
||||
limit(limit), violationEvent(violationEvent),
|
||||
aboveIsViolation(aboveIsViolation) {
|
||||
|
@ -12,13 +12,15 @@
|
||||
template<typename T>
|
||||
class LimitMonitor: public MonitorBase<T> {
|
||||
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<T>(reporterId, monitorId, parameterId, confirmationLimit), lowerLimit(
|
||||
lowerLimit), upperLimit(upperLimit), belowLowEvent(
|
||||
belowLowEvent), aboveHighEvent(aboveHighEvent) {
|
||||
MonitorBase<T>(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;
|
||||
|
@ -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<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) {
|
||||
object_id_t dataCreatorId, lp_id_t localPoolId,
|
||||
uint16_t confirmationLimit):
|
||||
MonitorReporter<T>(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<T> 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<T> poolVariable;
|
||||
};
|
||||
|
||||
#endif /* FSFW_MONITORING_MONITORBASE_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),
|
||||
|
Loading…
Reference in New Issue
Block a user