renormalized line endings
This commit is contained in:
@ -1,73 +1,73 @@
|
||||
#ifndef FRAMEWORK_MONITORING_ABSLIMITMONITOR_H_
|
||||
#define FRAMEWORK_MONITORING_ABSLIMITMONITOR_H_
|
||||
|
||||
#include "../monitoring/MonitorBase.h"
|
||||
#include <cmath>
|
||||
|
||||
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, Event violationEvent = MonitoringIF::VALUE_OUT_OF_RANGE, bool aboveIsViolation = true) :
|
||||
MonitorBase<T>(reporterId, monitorId, parameterId, confirmationLimit), limit(limit), violationEvent(violationEvent), aboveIsViolation(aboveIsViolation) {
|
||||
}
|
||||
virtual ~AbsLimitMonitor() {
|
||||
}
|
||||
virtual ReturnValue_t checkSample(T sample, T* crossedLimit) {
|
||||
*crossedLimit = limit;
|
||||
if (aboveIsViolation) {
|
||||
if ((std::abs(sample) > limit)) {
|
||||
return MonitoringIF::OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
if ((std::abs(sample) < limit)) {
|
||||
return MonitoringIF::OUT_OF_RANGE;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK; //We're not out of range.
|
||||
}
|
||||
|
||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
|
||||
ParameterWrapper *parameterWrapper,
|
||||
const ParameterWrapper *newValues, uint16_t startAtIndex) {
|
||||
ReturnValue_t result = this->MonitorBase<T>::getParameter(domainId,
|
||||
parameterId, parameterWrapper, newValues, startAtIndex);
|
||||
//We'll reuse the DOMAIN_ID of MonitorReporter, as we know the parameterIds used there.
|
||||
if (result != this->INVALID_MATRIX_ID) {
|
||||
return result;
|
||||
}
|
||||
switch (parameterId) {
|
||||
case 10:
|
||||
parameterWrapper->set(this->limit);
|
||||
break;
|
||||
default:
|
||||
return this->INVALID_MATRIX_ID;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
bool isOutOfLimits() {
|
||||
if (this->oldState == MonitoringIF::OUT_OF_RANGE) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
void setLimit(T value) {
|
||||
limit = value;
|
||||
}
|
||||
protected:
|
||||
void sendTransitionEvent(T currentValue, ReturnValue_t state) {
|
||||
switch (state) {
|
||||
case MonitoringIF::OUT_OF_RANGE:
|
||||
EventManagerIF::triggerEvent(this->reportingId, violationEvent, this->parameterId);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
T limit;
|
||||
const Event violationEvent;
|
||||
const bool aboveIsViolation;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_MONITORING_ABSLIMITMONITOR_H_ */
|
||||
#ifndef FRAMEWORK_MONITORING_ABSLIMITMONITOR_H_
|
||||
#define FRAMEWORK_MONITORING_ABSLIMITMONITOR_H_
|
||||
|
||||
#include "../monitoring/MonitorBase.h"
|
||||
#include <cmath>
|
||||
|
||||
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, Event violationEvent = MonitoringIF::VALUE_OUT_OF_RANGE, bool aboveIsViolation = true) :
|
||||
MonitorBase<T>(reporterId, monitorId, parameterId, confirmationLimit), limit(limit), violationEvent(violationEvent), aboveIsViolation(aboveIsViolation) {
|
||||
}
|
||||
virtual ~AbsLimitMonitor() {
|
||||
}
|
||||
virtual ReturnValue_t checkSample(T sample, T* crossedLimit) {
|
||||
*crossedLimit = limit;
|
||||
if (aboveIsViolation) {
|
||||
if ((std::abs(sample) > limit)) {
|
||||
return MonitoringIF::OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
if ((std::abs(sample) < limit)) {
|
||||
return MonitoringIF::OUT_OF_RANGE;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK; //We're not out of range.
|
||||
}
|
||||
|
||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
|
||||
ParameterWrapper *parameterWrapper,
|
||||
const ParameterWrapper *newValues, uint16_t startAtIndex) {
|
||||
ReturnValue_t result = this->MonitorBase<T>::getParameter(domainId,
|
||||
parameterId, parameterWrapper, newValues, startAtIndex);
|
||||
//We'll reuse the DOMAIN_ID of MonitorReporter, as we know the parameterIds used there.
|
||||
if (result != this->INVALID_MATRIX_ID) {
|
||||
return result;
|
||||
}
|
||||
switch (parameterId) {
|
||||
case 10:
|
||||
parameterWrapper->set(this->limit);
|
||||
break;
|
||||
default:
|
||||
return this->INVALID_MATRIX_ID;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
bool isOutOfLimits() {
|
||||
if (this->oldState == MonitoringIF::OUT_OF_RANGE) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
void setLimit(T value) {
|
||||
limit = value;
|
||||
}
|
||||
protected:
|
||||
void sendTransitionEvent(T currentValue, ReturnValue_t state) {
|
||||
switch (state) {
|
||||
case MonitoringIF::OUT_OF_RANGE:
|
||||
EventManagerIF::triggerEvent(this->reportingId, violationEvent, this->parameterId);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
T limit;
|
||||
const Event violationEvent;
|
||||
const bool aboveIsViolation;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_MONITORING_ABSLIMITMONITOR_H_ */
|
||||
|
@ -1,30 +1,30 @@
|
||||
/**
|
||||
* @file HasMonitorsIF.h
|
||||
* @brief This file defines the HasMonitorsIF class.
|
||||
* @date 28.07.2014
|
||||
* @author baetz
|
||||
*/
|
||||
#ifndef HASMONITORSIF_H_
|
||||
#define HASMONITORSIF_H_
|
||||
|
||||
#include "../events/EventReportingProxyIF.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
|
||||
class HasMonitorsIF {
|
||||
public:
|
||||
static const uint8_t MAX_N_PARAMETER = 10;
|
||||
// static const uint8_t MAX_N_LIMIT_ID = 10;
|
||||
virtual ReturnValue_t setCheckingOfParameters(uint8_t checkingStrategy,
|
||||
bool forOnePid = false, uint32_t parameterId = 0) = 0;
|
||||
virtual ReturnValue_t modifyParameterMonitor(uint8_t limitType,
|
||||
uint32_t parameterId, const uint8_t* data, uint32_t size) = 0;
|
||||
virtual ReturnValue_t modifyObjectMonitor(uint32_t objectId,
|
||||
const uint8_t* data, const uint32_t size) = 0;
|
||||
virtual void setAllMonitorsToUnchecked() = 0;
|
||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||
virtual ~HasMonitorsIF() {
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* HASMONITORSIF_H_ */
|
||||
/**
|
||||
* @file HasMonitorsIF.h
|
||||
* @brief This file defines the HasMonitorsIF class.
|
||||
* @date 28.07.2014
|
||||
* @author baetz
|
||||
*/
|
||||
#ifndef HASMONITORSIF_H_
|
||||
#define HASMONITORSIF_H_
|
||||
|
||||
#include "../events/EventReportingProxyIF.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
|
||||
class HasMonitorsIF {
|
||||
public:
|
||||
static const uint8_t MAX_N_PARAMETER = 10;
|
||||
// static const uint8_t MAX_N_LIMIT_ID = 10;
|
||||
virtual ReturnValue_t setCheckingOfParameters(uint8_t checkingStrategy,
|
||||
bool forOnePid = false, uint32_t parameterId = 0) = 0;
|
||||
virtual ReturnValue_t modifyParameterMonitor(uint8_t limitType,
|
||||
uint32_t parameterId, const uint8_t* data, uint32_t size) = 0;
|
||||
virtual ReturnValue_t modifyObjectMonitor(uint32_t objectId,
|
||||
const uint8_t* data, const uint32_t size) = 0;
|
||||
virtual void setAllMonitorsToUnchecked() = 0;
|
||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||
virtual ~HasMonitorsIF() {
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* HASMONITORSIF_H_ */
|
||||
|
@ -1,95 +1,95 @@
|
||||
#ifndef FRAMEWORK_MONITORING_LIMITMONITOR_H_
|
||||
#define FRAMEWORK_MONITORING_LIMITMONITOR_H_
|
||||
|
||||
#include "../monitoring/MonitorBase.h"
|
||||
|
||||
/**
|
||||
* Variant of a limit checking class.
|
||||
* Newer version as compared to LimitCheckMonitor.
|
||||
* Functionality is more or less the same, but does not use
|
||||
* heavy weight MonitoringIF.
|
||||
*/
|
||||
template<typename T>
|
||||
class LimitMonitor: public MonitorBase<T> {
|
||||
public:
|
||||
LimitMonitor(object_id_t reporterId, uint8_t monitorId, uint32_t parameterId,
|
||||
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) {
|
||||
}
|
||||
|
||||
virtual ~LimitMonitor() {}
|
||||
|
||||
virtual ReturnValue_t checkSample(T sample, T* crossedLimit) {
|
||||
*crossedLimit = 0.0;
|
||||
if (sample > upperLimit) {
|
||||
*crossedLimit = upperLimit;
|
||||
return MonitoringIF::ABOVE_HIGH_LIMIT;
|
||||
} else if (sample < lowerLimit) {
|
||||
*crossedLimit = lowerLimit;
|
||||
return MonitoringIF::BELOW_LOW_LIMIT;
|
||||
} else {
|
||||
return HasReturnvaluesIF::RETURN_OK; //Within limits.
|
||||
}
|
||||
}
|
||||
|
||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
|
||||
ParameterWrapper *parameterWrapper,
|
||||
const ParameterWrapper *newValues, uint16_t startAtIndex) {
|
||||
ReturnValue_t result = this->MonitorBase<T>::getParameter(domainId,
|
||||
parameterId, parameterWrapper, newValues, startAtIndex);
|
||||
//We'll reuse the DOMAIN_ID of MonitorReporter, as we know the parameterIds used there.
|
||||
if (result != this->INVALID_MATRIX_ID) {
|
||||
return result;
|
||||
}
|
||||
switch (parameterId) {
|
||||
case 10:
|
||||
parameterWrapper->set(this->lowerLimit);
|
||||
break;
|
||||
case 11:
|
||||
parameterWrapper->set(this->upperLimit);
|
||||
break;
|
||||
default:
|
||||
return this->INVALID_MATRIX_ID;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
bool isOutOfLimits() {
|
||||
if (this->oldState == MonitoringIF::ABOVE_HIGH_LIMIT || this->oldState == MonitoringIF::BELOW_LOW_LIMIT) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
T getLowerLimit() const {
|
||||
return lowerLimit;
|
||||
}
|
||||
|
||||
T getUpperLimit() const {
|
||||
return upperLimit;
|
||||
}
|
||||
|
||||
protected:
|
||||
void sendTransitionEvent(T currentValue, ReturnValue_t state) {
|
||||
switch (state) {
|
||||
case MonitoringIF::BELOW_LOW_LIMIT:
|
||||
EventManagerIF::triggerEvent(this->reportingId, belowLowEvent, this->parameterId);
|
||||
break;
|
||||
case MonitoringIF::ABOVE_HIGH_LIMIT:
|
||||
EventManagerIF::triggerEvent(this->reportingId, aboveHighEvent, this->parameterId);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
T lowerLimit;
|
||||
T upperLimit;
|
||||
const Event belowLowEvent;
|
||||
const Event aboveHighEvent;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_MONITORING_LIMITMONITOR_H_ */
|
||||
#ifndef FRAMEWORK_MONITORING_LIMITMONITOR_H_
|
||||
#define FRAMEWORK_MONITORING_LIMITMONITOR_H_
|
||||
|
||||
#include "../monitoring/MonitorBase.h"
|
||||
|
||||
/**
|
||||
* Variant of a limit checking class.
|
||||
* Newer version as compared to LimitCheckMonitor.
|
||||
* Functionality is more or less the same, but does not use
|
||||
* heavy weight MonitoringIF.
|
||||
*/
|
||||
template<typename T>
|
||||
class LimitMonitor: public MonitorBase<T> {
|
||||
public:
|
||||
LimitMonitor(object_id_t reporterId, uint8_t monitorId, uint32_t parameterId,
|
||||
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) {
|
||||
}
|
||||
|
||||
virtual ~LimitMonitor() {}
|
||||
|
||||
virtual ReturnValue_t checkSample(T sample, T* crossedLimit) {
|
||||
*crossedLimit = 0.0;
|
||||
if (sample > upperLimit) {
|
||||
*crossedLimit = upperLimit;
|
||||
return MonitoringIF::ABOVE_HIGH_LIMIT;
|
||||
} else if (sample < lowerLimit) {
|
||||
*crossedLimit = lowerLimit;
|
||||
return MonitoringIF::BELOW_LOW_LIMIT;
|
||||
} else {
|
||||
return HasReturnvaluesIF::RETURN_OK; //Within limits.
|
||||
}
|
||||
}
|
||||
|
||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
|
||||
ParameterWrapper *parameterWrapper,
|
||||
const ParameterWrapper *newValues, uint16_t startAtIndex) {
|
||||
ReturnValue_t result = this->MonitorBase<T>::getParameter(domainId,
|
||||
parameterId, parameterWrapper, newValues, startAtIndex);
|
||||
//We'll reuse the DOMAIN_ID of MonitorReporter, as we know the parameterIds used there.
|
||||
if (result != this->INVALID_MATRIX_ID) {
|
||||
return result;
|
||||
}
|
||||
switch (parameterId) {
|
||||
case 10:
|
||||
parameterWrapper->set(this->lowerLimit);
|
||||
break;
|
||||
case 11:
|
||||
parameterWrapper->set(this->upperLimit);
|
||||
break;
|
||||
default:
|
||||
return this->INVALID_MATRIX_ID;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
bool isOutOfLimits() {
|
||||
if (this->oldState == MonitoringIF::ABOVE_HIGH_LIMIT || this->oldState == MonitoringIF::BELOW_LOW_LIMIT) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
T getLowerLimit() const {
|
||||
return lowerLimit;
|
||||
}
|
||||
|
||||
T getUpperLimit() const {
|
||||
return upperLimit;
|
||||
}
|
||||
|
||||
protected:
|
||||
void sendTransitionEvent(T currentValue, ReturnValue_t state) {
|
||||
switch (state) {
|
||||
case MonitoringIF::BELOW_LOW_LIMIT:
|
||||
EventManagerIF::triggerEvent(this->reportingId, belowLowEvent, this->parameterId);
|
||||
break;
|
||||
case MonitoringIF::ABOVE_HIGH_LIMIT:
|
||||
EventManagerIF::triggerEvent(this->reportingId, aboveHighEvent, this->parameterId);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
T lowerLimit;
|
||||
T upperLimit;
|
||||
const Event belowLowEvent;
|
||||
const Event aboveHighEvent;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_MONITORING_LIMITMONITOR_H_ */
|
||||
|
@ -1,60 +1,60 @@
|
||||
/**
|
||||
* @file LimitViolationReporter.cpp
|
||||
* @brief This file defines the LimitViolationReporter class.
|
||||
* @date 17.07.2014
|
||||
* @author baetz
|
||||
*/
|
||||
#include "../monitoring/LimitViolationReporter.h"
|
||||
#include "../monitoring/MonitoringIF.h"
|
||||
#include "../monitoring/ReceivesMonitoringReportsIF.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../serialize/SerializeAdapter.h"
|
||||
|
||||
ReturnValue_t LimitViolationReporter::sendLimitViolationReport(const SerializeIF* data) {
|
||||
ReturnValue_t result = checkClassLoaded();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
store_address_t storeId;
|
||||
uint8_t* dataTarget = NULL;
|
||||
size_t maxSize = data->getSerializedSize();
|
||||
if (maxSize > MonitoringIF::VIOLATION_REPORT_MAX_SIZE) {
|
||||
return MonitoringIF::INVALID_SIZE;
|
||||
}
|
||||
result = ipcStore->getFreeElement(&storeId, maxSize,
|
||||
&dataTarget);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
size_t size = 0;
|
||||
result = data->serialize(&dataTarget, &size, maxSize, SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
CommandMessage report;
|
||||
MonitoringMessage::setLimitViolationReport(&report, storeId);
|
||||
return MessageQueueSenderIF::sendMessage(reportQueue, &report);
|
||||
}
|
||||
|
||||
ReturnValue_t LimitViolationReporter::checkClassLoaded() {
|
||||
if (reportQueue == 0) {
|
||||
ReceivesMonitoringReportsIF* receiver = objectManager->get<
|
||||
ReceivesMonitoringReportsIF>(reportingTarget);
|
||||
if (receiver == NULL) {
|
||||
return ObjectManagerIF::NOT_FOUND;
|
||||
}
|
||||
reportQueue = receiver->getCommandQueue();
|
||||
}
|
||||
if (ipcStore == NULL) {
|
||||
ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (ipcStore == NULL) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
//Lazy initialization.
|
||||
MessageQueueId_t LimitViolationReporter::reportQueue = 0;
|
||||
StorageManagerIF* LimitViolationReporter::ipcStore = NULL;
|
||||
object_id_t LimitViolationReporter::reportingTarget = 0;
|
||||
/**
|
||||
* @file LimitViolationReporter.cpp
|
||||
* @brief This file defines the LimitViolationReporter class.
|
||||
* @date 17.07.2014
|
||||
* @author baetz
|
||||
*/
|
||||
#include "../monitoring/LimitViolationReporter.h"
|
||||
#include "../monitoring/MonitoringIF.h"
|
||||
#include "../monitoring/ReceivesMonitoringReportsIF.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../serialize/SerializeAdapter.h"
|
||||
|
||||
ReturnValue_t LimitViolationReporter::sendLimitViolationReport(const SerializeIF* data) {
|
||||
ReturnValue_t result = checkClassLoaded();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
store_address_t storeId;
|
||||
uint8_t* dataTarget = NULL;
|
||||
size_t maxSize = data->getSerializedSize();
|
||||
if (maxSize > MonitoringIF::VIOLATION_REPORT_MAX_SIZE) {
|
||||
return MonitoringIF::INVALID_SIZE;
|
||||
}
|
||||
result = ipcStore->getFreeElement(&storeId, maxSize,
|
||||
&dataTarget);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
size_t size = 0;
|
||||
result = data->serialize(&dataTarget, &size, maxSize, SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
CommandMessage report;
|
||||
MonitoringMessage::setLimitViolationReport(&report, storeId);
|
||||
return MessageQueueSenderIF::sendMessage(reportQueue, &report);
|
||||
}
|
||||
|
||||
ReturnValue_t LimitViolationReporter::checkClassLoaded() {
|
||||
if (reportQueue == 0) {
|
||||
ReceivesMonitoringReportsIF* receiver = objectManager->get<
|
||||
ReceivesMonitoringReportsIF>(reportingTarget);
|
||||
if (receiver == NULL) {
|
||||
return ObjectManagerIF::NOT_FOUND;
|
||||
}
|
||||
reportQueue = receiver->getCommandQueue();
|
||||
}
|
||||
if (ipcStore == NULL) {
|
||||
ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (ipcStore == NULL) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
//Lazy initialization.
|
||||
MessageQueueId_t LimitViolationReporter::reportQueue = 0;
|
||||
StorageManagerIF* LimitViolationReporter::ipcStore = NULL;
|
||||
object_id_t LimitViolationReporter::reportingTarget = 0;
|
||||
|
@ -1,31 +1,31 @@
|
||||
/**
|
||||
* @file LimitViolationReporter.h
|
||||
* @brief This file defines the LimitViolationReporter class.
|
||||
* @date 17.07.2014
|
||||
* @author baetz
|
||||
*/
|
||||
#ifndef LIMITVIOLATIONREPORTER_H_
|
||||
#define LIMITVIOLATIONREPORTER_H_
|
||||
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../serialize/SerializeIF.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
|
||||
namespace Factory{
|
||||
void setStaticFrameworkObjectIds();
|
||||
}
|
||||
|
||||
class LimitViolationReporter {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
public:
|
||||
static ReturnValue_t sendLimitViolationReport(const SerializeIF* data);
|
||||
private:
|
||||
static object_id_t reportingTarget;
|
||||
static MessageQueueId_t reportQueue;
|
||||
static StorageManagerIF* ipcStore;
|
||||
static ReturnValue_t checkClassLoaded();
|
||||
LimitViolationReporter();
|
||||
};
|
||||
|
||||
#endif /* LIMITVIOLATIONREPORTER_H_ */
|
||||
/**
|
||||
* @file LimitViolationReporter.h
|
||||
* @brief This file defines the LimitViolationReporter class.
|
||||
* @date 17.07.2014
|
||||
* @author baetz
|
||||
*/
|
||||
#ifndef LIMITVIOLATIONREPORTER_H_
|
||||
#define LIMITVIOLATIONREPORTER_H_
|
||||
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../serialize/SerializeIF.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
|
||||
namespace Factory{
|
||||
void setStaticFrameworkObjectIds();
|
||||
}
|
||||
|
||||
class LimitViolationReporter {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
public:
|
||||
static ReturnValue_t sendLimitViolationReport(const SerializeIF* data);
|
||||
private:
|
||||
static object_id_t reportingTarget;
|
||||
static MessageQueueId_t reportQueue;
|
||||
static StorageManagerIF* ipcStore;
|
||||
static ReturnValue_t checkClassLoaded();
|
||||
LimitViolationReporter();
|
||||
};
|
||||
|
||||
#endif /* LIMITVIOLATIONREPORTER_H_ */
|
||||
|
@ -1,62 +1,62 @@
|
||||
#ifndef MONITORBASE_H_
|
||||
#define MONITORBASE_H_
|
||||
|
||||
#include "../datapoolglob/GlobalDataSet.h"
|
||||
#include "../datapoolglob/PIDReader.h"
|
||||
#include "../monitoring/LimitViolationReporter.h"
|
||||
#include "../monitoring/MonitoringIF.h"
|
||||
#include "../monitoring/MonitoringMessageContent.h"
|
||||
#include "../monitoring/MonitorReporter.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.
|
||||
*/
|
||||
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) {
|
||||
}
|
||||
virtual ~MonitorBase() {
|
||||
}
|
||||
virtual ReturnValue_t check() {
|
||||
//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).
|
||||
if (validity != HasReturnvaluesIF::RETURN_OK) {
|
||||
this->monitorStateIs(validity, sample, 0);
|
||||
//3. Otherwise, check sample.
|
||||
} else {
|
||||
this->oldState = doCheck(sample);
|
||||
}
|
||||
return this->oldState;
|
||||
}
|
||||
virtual ReturnValue_t doCheck(T sample) {
|
||||
T crossedLimit = 0.0;
|
||||
ReturnValue_t currentState = checkSample(sample, &crossedLimit);
|
||||
return this->monitorStateIs(currentState,sample, crossedLimit);
|
||||
}
|
||||
//Abstract or default.
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* MONITORBASE_H_ */
|
||||
#ifndef MONITORBASE_H_
|
||||
#define MONITORBASE_H_
|
||||
|
||||
#include "../datapoolglob/GlobalDataSet.h"
|
||||
#include "../datapoolglob/PIDReader.h"
|
||||
#include "../monitoring/LimitViolationReporter.h"
|
||||
#include "../monitoring/MonitoringIF.h"
|
||||
#include "../monitoring/MonitoringMessageContent.h"
|
||||
#include "../monitoring/MonitorReporter.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.
|
||||
*/
|
||||
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) {
|
||||
}
|
||||
virtual ~MonitorBase() {
|
||||
}
|
||||
virtual ReturnValue_t check() {
|
||||
//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).
|
||||
if (validity != HasReturnvaluesIF::RETURN_OK) {
|
||||
this->monitorStateIs(validity, sample, 0);
|
||||
//3. Otherwise, check sample.
|
||||
} else {
|
||||
this->oldState = doCheck(sample);
|
||||
}
|
||||
return this->oldState;
|
||||
}
|
||||
virtual ReturnValue_t doCheck(T sample) {
|
||||
T crossedLimit = 0.0;
|
||||
ReturnValue_t currentState = checkSample(sample, &crossedLimit);
|
||||
return this->monitorStateIs(currentState,sample, crossedLimit);
|
||||
}
|
||||
//Abstract or default.
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* MONITORBASE_H_ */
|
||||
|
@ -1,178 +1,178 @@
|
||||
#ifndef FRAMEWORK_MONITORING_MONITORREPORTER_H_
|
||||
#define FRAMEWORK_MONITORING_MONITORREPORTER_H_
|
||||
|
||||
#include "../events/EventManagerIF.h"
|
||||
#include "../monitoring/LimitViolationReporter.h"
|
||||
#include "../monitoring/MonitoringIF.h"
|
||||
#include "../monitoring/MonitoringMessageContent.h"
|
||||
#include "../parameters/HasParametersIF.h"
|
||||
|
||||
template<typename T>
|
||||
class MonitorReporter: public HasParametersIF {
|
||||
public:
|
||||
|
||||
static const uint8_t ENABLED = 1;
|
||||
static const uint8_t DISABLED = 0;
|
||||
|
||||
MonitorReporter(object_id_t reportingId, uint8_t monitorId, uint32_t parameterId, uint16_t confirmationLimit) :
|
||||
monitorId(monitorId), parameterId(parameterId), reportingId(
|
||||
reportingId), oldState(MonitoringIF::UNCHECKED), reportingEnabled(
|
||||
ENABLED), eventEnabled(ENABLED), currentCounter(0), confirmationLimit(
|
||||
confirmationLimit) {
|
||||
}
|
||||
|
||||
virtual ~MonitorReporter() {
|
||||
}
|
||||
|
||||
ReturnValue_t monitorStateIs(ReturnValue_t state, T parameterValue = 0,
|
||||
T crossedLimit = 0) {
|
||||
if (state != oldState) {
|
||||
if (isConfirmed(state)) {
|
||||
if (eventEnabled == ENABLED) {
|
||||
sendTransitionEvent(parameterValue, state);
|
||||
}
|
||||
if (reportingEnabled == ENABLED) {
|
||||
sendTransitionReport(parameterValue, crossedLimit, state);
|
||||
}
|
||||
oldState = state;
|
||||
} else {
|
||||
//This is to ensure confirmation works.
|
||||
//Needs to be reset to be able to confirm against oldState again next time.
|
||||
return oldState;
|
||||
}
|
||||
} else {
|
||||
resetConfirmation();
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
|
||||
ParameterWrapper *parameterWrapper,
|
||||
const ParameterWrapper *newValues, uint16_t startAtIndex) {
|
||||
if (domainId != monitorId) {
|
||||
return INVALID_DOMAIN_ID;
|
||||
}
|
||||
switch (parameterId) {
|
||||
case 0:
|
||||
parameterWrapper->set(this->confirmationLimit);
|
||||
break;
|
||||
case 1:
|
||||
parameterWrapper->set(this->reportingEnabled);
|
||||
break;
|
||||
case 2:
|
||||
parameterWrapper->set(this->eventEnabled);
|
||||
break;
|
||||
default:
|
||||
return INVALID_MATRIX_ID;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
virtual ReturnValue_t setToUnchecked() {
|
||||
return setToState(MonitoringIF::UNCHECKED);
|
||||
}
|
||||
virtual ReturnValue_t setToInvalid() {
|
||||
return setToState(MonitoringIF::INVALID);
|
||||
}
|
||||
object_id_t getReporterId() const {
|
||||
return reportingId;
|
||||
}
|
||||
|
||||
void setEventEnabled(uint8_t eventEnabled) {
|
||||
this->eventEnabled = eventEnabled;
|
||||
}
|
||||
|
||||
void setReportingEnabled(uint8_t reportingEnabled) {
|
||||
this->reportingEnabled = reportingEnabled;
|
||||
}
|
||||
|
||||
bool isEventEnabled() const {
|
||||
return (eventEnabled == ENABLED);
|
||||
}
|
||||
|
||||
protected:
|
||||
const uint8_t monitorId;
|
||||
const uint32_t parameterId;
|
||||
object_id_t reportingId;
|
||||
ReturnValue_t oldState;
|
||||
|
||||
uint8_t reportingEnabled;
|
||||
|
||||
uint8_t eventEnabled;
|
||||
|
||||
uint16_t currentCounter;
|
||||
uint16_t confirmationLimit;
|
||||
|
||||
bool isConfirmed(ReturnValue_t state) {
|
||||
//Confirm INVALID and UNCHECKED immediately.
|
||||
if (state == MonitoringIF::INVALID
|
||||
|| state == MonitoringIF::UNCHECKED) {
|
||||
currentCounter = 0;
|
||||
return true;
|
||||
}
|
||||
return doesChildConfirm(state);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the most simple form of confirmation.
|
||||
* A counter counts any violation and compares the number to maxCounter.
|
||||
* @param state The state, indicating the type of violation. Not used here.
|
||||
* @return true if counter > maxCounter, else false.
|
||||
*/
|
||||
virtual bool doesChildConfirm(ReturnValue_t state) {
|
||||
currentCounter += 1;
|
||||
if (currentCounter > confirmationLimit) {
|
||||
currentCounter = 0;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This method needs to reset the confirmation in case a valid sample was found.
|
||||
* Here, simply resets the current counter.
|
||||
*/
|
||||
virtual void resetConfirmation() {
|
||||
currentCounter = 0;
|
||||
}
|
||||
/**
|
||||
* Default version of sending transitional events.
|
||||
* Should be overridden from specialized monitors.
|
||||
* @param currentValue The current value which was monitored.
|
||||
* @param state The state the monitor changed to.
|
||||
*/
|
||||
virtual void sendTransitionEvent(T currentValue, ReturnValue_t state) {
|
||||
switch(state) {
|
||||
case MonitoringIF::UNCHECKED:
|
||||
case MonitoringIF::UNSELECTED:
|
||||
case MonitoringIF::INVALID:
|
||||
case HasReturnvaluesIF::RETURN_OK:
|
||||
break;
|
||||
default:
|
||||
EventManagerIF::triggerEvent(reportingId, MonitoringIF::MONITOR_CHANGED_STATE, state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Default implementation for sending transition report.
|
||||
* May be overridden, but is seldom necessary.
|
||||
* @param parameterValue Current value of the parameter
|
||||
* @param crossedLimit The limit crossed (if applicable).
|
||||
* @param state Current state the monitor is in.
|
||||
*/
|
||||
virtual void sendTransitionReport(T parameterValue, T crossedLimit, ReturnValue_t state) {
|
||||
MonitoringReportContent<T> report(parameterId,
|
||||
parameterValue, crossedLimit, oldState, state);
|
||||
LimitViolationReporter::sendLimitViolationReport(&report);
|
||||
}
|
||||
ReturnValue_t setToState(ReturnValue_t state) {
|
||||
if (oldState != state && reportingEnabled) {
|
||||
MonitoringReportContent<T> report(parameterId, 0, 0, oldState,
|
||||
state);
|
||||
LimitViolationReporter::sendLimitViolationReport(&report);
|
||||
oldState = state;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_MONITORING_MONITORREPORTER_H_ */
|
||||
#ifndef FRAMEWORK_MONITORING_MONITORREPORTER_H_
|
||||
#define FRAMEWORK_MONITORING_MONITORREPORTER_H_
|
||||
|
||||
#include "../events/EventManagerIF.h"
|
||||
#include "../monitoring/LimitViolationReporter.h"
|
||||
#include "../monitoring/MonitoringIF.h"
|
||||
#include "../monitoring/MonitoringMessageContent.h"
|
||||
#include "../parameters/HasParametersIF.h"
|
||||
|
||||
template<typename T>
|
||||
class MonitorReporter: public HasParametersIF {
|
||||
public:
|
||||
|
||||
static const uint8_t ENABLED = 1;
|
||||
static const uint8_t DISABLED = 0;
|
||||
|
||||
MonitorReporter(object_id_t reportingId, uint8_t monitorId, uint32_t parameterId, uint16_t confirmationLimit) :
|
||||
monitorId(monitorId), parameterId(parameterId), reportingId(
|
||||
reportingId), oldState(MonitoringIF::UNCHECKED), reportingEnabled(
|
||||
ENABLED), eventEnabled(ENABLED), currentCounter(0), confirmationLimit(
|
||||
confirmationLimit) {
|
||||
}
|
||||
|
||||
virtual ~MonitorReporter() {
|
||||
}
|
||||
|
||||
ReturnValue_t monitorStateIs(ReturnValue_t state, T parameterValue = 0,
|
||||
T crossedLimit = 0) {
|
||||
if (state != oldState) {
|
||||
if (isConfirmed(state)) {
|
||||
if (eventEnabled == ENABLED) {
|
||||
sendTransitionEvent(parameterValue, state);
|
||||
}
|
||||
if (reportingEnabled == ENABLED) {
|
||||
sendTransitionReport(parameterValue, crossedLimit, state);
|
||||
}
|
||||
oldState = state;
|
||||
} else {
|
||||
//This is to ensure confirmation works.
|
||||
//Needs to be reset to be able to confirm against oldState again next time.
|
||||
return oldState;
|
||||
}
|
||||
} else {
|
||||
resetConfirmation();
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
|
||||
ParameterWrapper *parameterWrapper,
|
||||
const ParameterWrapper *newValues, uint16_t startAtIndex) {
|
||||
if (domainId != monitorId) {
|
||||
return INVALID_DOMAIN_ID;
|
||||
}
|
||||
switch (parameterId) {
|
||||
case 0:
|
||||
parameterWrapper->set(this->confirmationLimit);
|
||||
break;
|
||||
case 1:
|
||||
parameterWrapper->set(this->reportingEnabled);
|
||||
break;
|
||||
case 2:
|
||||
parameterWrapper->set(this->eventEnabled);
|
||||
break;
|
||||
default:
|
||||
return INVALID_MATRIX_ID;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
virtual ReturnValue_t setToUnchecked() {
|
||||
return setToState(MonitoringIF::UNCHECKED);
|
||||
}
|
||||
virtual ReturnValue_t setToInvalid() {
|
||||
return setToState(MonitoringIF::INVALID);
|
||||
}
|
||||
object_id_t getReporterId() const {
|
||||
return reportingId;
|
||||
}
|
||||
|
||||
void setEventEnabled(uint8_t eventEnabled) {
|
||||
this->eventEnabled = eventEnabled;
|
||||
}
|
||||
|
||||
void setReportingEnabled(uint8_t reportingEnabled) {
|
||||
this->reportingEnabled = reportingEnabled;
|
||||
}
|
||||
|
||||
bool isEventEnabled() const {
|
||||
return (eventEnabled == ENABLED);
|
||||
}
|
||||
|
||||
protected:
|
||||
const uint8_t monitorId;
|
||||
const uint32_t parameterId;
|
||||
object_id_t reportingId;
|
||||
ReturnValue_t oldState;
|
||||
|
||||
uint8_t reportingEnabled;
|
||||
|
||||
uint8_t eventEnabled;
|
||||
|
||||
uint16_t currentCounter;
|
||||
uint16_t confirmationLimit;
|
||||
|
||||
bool isConfirmed(ReturnValue_t state) {
|
||||
//Confirm INVALID and UNCHECKED immediately.
|
||||
if (state == MonitoringIF::INVALID
|
||||
|| state == MonitoringIF::UNCHECKED) {
|
||||
currentCounter = 0;
|
||||
return true;
|
||||
}
|
||||
return doesChildConfirm(state);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the most simple form of confirmation.
|
||||
* A counter counts any violation and compares the number to maxCounter.
|
||||
* @param state The state, indicating the type of violation. Not used here.
|
||||
* @return true if counter > maxCounter, else false.
|
||||
*/
|
||||
virtual bool doesChildConfirm(ReturnValue_t state) {
|
||||
currentCounter += 1;
|
||||
if (currentCounter > confirmationLimit) {
|
||||
currentCounter = 0;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This method needs to reset the confirmation in case a valid sample was found.
|
||||
* Here, simply resets the current counter.
|
||||
*/
|
||||
virtual void resetConfirmation() {
|
||||
currentCounter = 0;
|
||||
}
|
||||
/**
|
||||
* Default version of sending transitional events.
|
||||
* Should be overridden from specialized monitors.
|
||||
* @param currentValue The current value which was monitored.
|
||||
* @param state The state the monitor changed to.
|
||||
*/
|
||||
virtual void sendTransitionEvent(T currentValue, ReturnValue_t state) {
|
||||
switch(state) {
|
||||
case MonitoringIF::UNCHECKED:
|
||||
case MonitoringIF::UNSELECTED:
|
||||
case MonitoringIF::INVALID:
|
||||
case HasReturnvaluesIF::RETURN_OK:
|
||||
break;
|
||||
default:
|
||||
EventManagerIF::triggerEvent(reportingId, MonitoringIF::MONITOR_CHANGED_STATE, state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Default implementation for sending transition report.
|
||||
* May be overridden, but is seldom necessary.
|
||||
* @param parameterValue Current value of the parameter
|
||||
* @param crossedLimit The limit crossed (if applicable).
|
||||
* @param state Current state the monitor is in.
|
||||
*/
|
||||
virtual void sendTransitionReport(T parameterValue, T crossedLimit, ReturnValue_t state) {
|
||||
MonitoringReportContent<T> report(parameterId,
|
||||
parameterValue, crossedLimit, oldState, state);
|
||||
LimitViolationReporter::sendLimitViolationReport(&report);
|
||||
}
|
||||
ReturnValue_t setToState(ReturnValue_t state) {
|
||||
if (oldState != state && reportingEnabled) {
|
||||
MonitoringReportContent<T> report(parameterId, 0, 0, oldState,
|
||||
state);
|
||||
LimitViolationReporter::sendLimitViolationReport(&report);
|
||||
oldState = state;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_MONITORING_MONITORREPORTER_H_ */
|
||||
|
@ -1,67 +1,67 @@
|
||||
#ifndef MONITORINGIF_H_
|
||||
#define MONITORINGIF_H_
|
||||
|
||||
#include "../memory/HasMemoryIF.h"
|
||||
#include "../monitoring/MonitoringMessage.h"
|
||||
#include "../serialize/SerializeIF.h"
|
||||
|
||||
class MonitoringIF : public SerializeIF {
|
||||
public:
|
||||
static const uint8_t VIOLATION_REPORT_MAX_SIZE = 32;
|
||||
static const uint8_t LIMIT_TYPE_NO_TYPE = 0xFF;
|
||||
static const uint8_t LIMIT_TYPE_LIMIT_CHECK = 0;
|
||||
static const uint8_t LIMIT_TYPE_DELTA_CHECK = 1;
|
||||
static const uint8_t LIMIT_TYPE_ABSOLUTE_CHECK = 2;
|
||||
static const uint8_t LIMIT_TYPE_OBJECT = 128;
|
||||
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FDIR_2;
|
||||
static const Event MONITOR_CHANGED_STATE = MAKE_EVENT(1, SEVERITY::LOW);
|
||||
static const Event VALUE_BELOW_LOW_LIMIT = MAKE_EVENT(2, SEVERITY::LOW);
|
||||
static const Event VALUE_ABOVE_HIGH_LIMIT = MAKE_EVENT(3, SEVERITY::LOW);
|
||||
static const Event VALUE_OUT_OF_RANGE = MAKE_EVENT(4, SEVERITY::LOW);
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::LIMITS_IF;
|
||||
static const ReturnValue_t UNCHECKED = MAKE_RETURN_CODE(1);
|
||||
static const ReturnValue_t INVALID = MAKE_RETURN_CODE(2);
|
||||
static const ReturnValue_t UNSELECTED = MAKE_RETURN_CODE(3);
|
||||
static const ReturnValue_t BELOW_LOW_LIMIT = MAKE_RETURN_CODE(4);
|
||||
// static const ReturnValue_t CHECKING_STATUS_BELOW_LOW_THRESHOLD = MAKE_RETURN_CODE(4);
|
||||
// static const ReturnValue_t CHECKING_STATUS_ABOVE_HIGH_THRESHOLD = MAKE_RETURN_CODE(5);
|
||||
static const ReturnValue_t ABOVE_HIGH_LIMIT = MAKE_RETURN_CODE(5);
|
||||
static const ReturnValue_t UNEXPECTED_VALUE = MAKE_RETURN_CODE(6);
|
||||
static const ReturnValue_t OUT_OF_RANGE = MAKE_RETURN_CODE(7);
|
||||
|
||||
|
||||
static const ReturnValue_t FIRST_SAMPLE = MAKE_RETURN_CODE(0xA0);
|
||||
static const ReturnValue_t INVALID_SIZE = MAKE_RETURN_CODE(0xE0);
|
||||
static const ReturnValue_t WRONG_TYPE = MAKE_RETURN_CODE(0xE1);
|
||||
static const ReturnValue_t WRONG_PID = MAKE_RETURN_CODE(0xE2);
|
||||
static const ReturnValue_t WRONG_LIMIT_ID = MAKE_RETURN_CODE(0xE3);
|
||||
static const ReturnValue_t MONITOR_NOT_FOUND = MAKE_RETURN_CODE(0xEE);
|
||||
|
||||
static const uint8_t REPORT_NONE = 0;
|
||||
static const uint8_t REPORT_EVENTS_ONLY = 1;
|
||||
static const uint8_t REPORT_REPORTS_ONLY = 2;
|
||||
static const uint8_t REPORT_ALL = 3;
|
||||
|
||||
// static const ReturnValue_t STILL_IN_LOW_WARNING = MAKE_RETURN_CODE(0x11);
|
||||
// static const ReturnValue_t STILL_IN_LOW_LIMIT = MAKE_RETURN_CODE(0x12);
|
||||
// static const ReturnValue_t STILL_IN_HIGH_WARNING = MAKE_RETURN_CODE(0x13);
|
||||
// static const ReturnValue_t STILL_IN_HIGH_LIMIT = MAKE_RETURN_CODE(0x14);
|
||||
// static const ReturnValue_t VARIABLE_IS_INVALID = MAKE_RETURN_CODE(0xE0);
|
||||
// static const ReturnValue_t INVALID_SIZE = MAKE_RETURN_CODE(0xE1);
|
||||
// static const ReturnValue_t INVALID_ID = MAKE_RETURN_CODE(0xE2);
|
||||
virtual ReturnValue_t check() = 0;
|
||||
virtual ReturnValue_t setLimits( uint8_t type, const uint8_t* data, uint32_t size) = 0;
|
||||
virtual ReturnValue_t setChecking(uint8_t strategy) = 0;
|
||||
virtual ReturnValue_t setToUnchecked() = 0;
|
||||
virtual uint8_t getLimitType() const = 0;
|
||||
virtual uint32_t getLimitId() const = 0;
|
||||
// virtual ReturnValue_t setEventReporting(bool active) = 0;
|
||||
virtual ~MonitoringIF() {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* MONITORINGIF_H_ */
|
||||
#ifndef MONITORINGIF_H_
|
||||
#define MONITORINGIF_H_
|
||||
|
||||
#include "../memory/HasMemoryIF.h"
|
||||
#include "../monitoring/MonitoringMessage.h"
|
||||
#include "../serialize/SerializeIF.h"
|
||||
|
||||
class MonitoringIF : public SerializeIF {
|
||||
public:
|
||||
static const uint8_t VIOLATION_REPORT_MAX_SIZE = 32;
|
||||
static const uint8_t LIMIT_TYPE_NO_TYPE = 0xFF;
|
||||
static const uint8_t LIMIT_TYPE_LIMIT_CHECK = 0;
|
||||
static const uint8_t LIMIT_TYPE_DELTA_CHECK = 1;
|
||||
static const uint8_t LIMIT_TYPE_ABSOLUTE_CHECK = 2;
|
||||
static const uint8_t LIMIT_TYPE_OBJECT = 128;
|
||||
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FDIR_2;
|
||||
static const Event MONITOR_CHANGED_STATE = MAKE_EVENT(1, SEVERITY::LOW);
|
||||
static const Event VALUE_BELOW_LOW_LIMIT = MAKE_EVENT(2, SEVERITY::LOW);
|
||||
static const Event VALUE_ABOVE_HIGH_LIMIT = MAKE_EVENT(3, SEVERITY::LOW);
|
||||
static const Event VALUE_OUT_OF_RANGE = MAKE_EVENT(4, SEVERITY::LOW);
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::LIMITS_IF;
|
||||
static const ReturnValue_t UNCHECKED = MAKE_RETURN_CODE(1);
|
||||
static const ReturnValue_t INVALID = MAKE_RETURN_CODE(2);
|
||||
static const ReturnValue_t UNSELECTED = MAKE_RETURN_CODE(3);
|
||||
static const ReturnValue_t BELOW_LOW_LIMIT = MAKE_RETURN_CODE(4);
|
||||
// static const ReturnValue_t CHECKING_STATUS_BELOW_LOW_THRESHOLD = MAKE_RETURN_CODE(4);
|
||||
// static const ReturnValue_t CHECKING_STATUS_ABOVE_HIGH_THRESHOLD = MAKE_RETURN_CODE(5);
|
||||
static const ReturnValue_t ABOVE_HIGH_LIMIT = MAKE_RETURN_CODE(5);
|
||||
static const ReturnValue_t UNEXPECTED_VALUE = MAKE_RETURN_CODE(6);
|
||||
static const ReturnValue_t OUT_OF_RANGE = MAKE_RETURN_CODE(7);
|
||||
|
||||
|
||||
static const ReturnValue_t FIRST_SAMPLE = MAKE_RETURN_CODE(0xA0);
|
||||
static const ReturnValue_t INVALID_SIZE = MAKE_RETURN_CODE(0xE0);
|
||||
static const ReturnValue_t WRONG_TYPE = MAKE_RETURN_CODE(0xE1);
|
||||
static const ReturnValue_t WRONG_PID = MAKE_RETURN_CODE(0xE2);
|
||||
static const ReturnValue_t WRONG_LIMIT_ID = MAKE_RETURN_CODE(0xE3);
|
||||
static const ReturnValue_t MONITOR_NOT_FOUND = MAKE_RETURN_CODE(0xEE);
|
||||
|
||||
static const uint8_t REPORT_NONE = 0;
|
||||
static const uint8_t REPORT_EVENTS_ONLY = 1;
|
||||
static const uint8_t REPORT_REPORTS_ONLY = 2;
|
||||
static const uint8_t REPORT_ALL = 3;
|
||||
|
||||
// static const ReturnValue_t STILL_IN_LOW_WARNING = MAKE_RETURN_CODE(0x11);
|
||||
// static const ReturnValue_t STILL_IN_LOW_LIMIT = MAKE_RETURN_CODE(0x12);
|
||||
// static const ReturnValue_t STILL_IN_HIGH_WARNING = MAKE_RETURN_CODE(0x13);
|
||||
// static const ReturnValue_t STILL_IN_HIGH_LIMIT = MAKE_RETURN_CODE(0x14);
|
||||
// static const ReturnValue_t VARIABLE_IS_INVALID = MAKE_RETURN_CODE(0xE0);
|
||||
// static const ReturnValue_t INVALID_SIZE = MAKE_RETURN_CODE(0xE1);
|
||||
// static const ReturnValue_t INVALID_ID = MAKE_RETURN_CODE(0xE2);
|
||||
virtual ReturnValue_t check() = 0;
|
||||
virtual ReturnValue_t setLimits( uint8_t type, const uint8_t* data, uint32_t size) = 0;
|
||||
virtual ReturnValue_t setChecking(uint8_t strategy) = 0;
|
||||
virtual ReturnValue_t setToUnchecked() = 0;
|
||||
virtual uint8_t getLimitType() const = 0;
|
||||
virtual uint32_t getLimitId() const = 0;
|
||||
// virtual ReturnValue_t setEventReporting(bool active) = 0;
|
||||
virtual ~MonitoringIF() {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* MONITORINGIF_H_ */
|
||||
|
@ -1,38 +1,38 @@
|
||||
#include "../monitoring/MonitoringMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
MonitoringMessage::~MonitoringMessage() {
|
||||
}
|
||||
|
||||
void MonitoringMessage::setLimitViolationReport(CommandMessage* message,
|
||||
store_address_t storeId) {
|
||||
setTypicalMessage(message, LIMIT_VIOLATION_REPORT, storeId);
|
||||
}
|
||||
|
||||
void MonitoringMessage::setTypicalMessage(CommandMessage* message,
|
||||
Command_t type, store_address_t storeId) {
|
||||
message->setCommand(type);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
store_address_t MonitoringMessage::getStoreId(const CommandMessage* message) {
|
||||
store_address_t temp;
|
||||
temp.raw = message->getParameter2();
|
||||
return temp;
|
||||
}
|
||||
|
||||
void MonitoringMessage::clear(CommandMessage* message) {
|
||||
message->setCommand(CommandMessage::CMD_NONE);
|
||||
switch (message->getCommand()) {
|
||||
case MonitoringMessage::LIMIT_VIOLATION_REPORT: {
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != NULL) {
|
||||
ipcStore->deleteData(getStoreId(message));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#include "../monitoring/MonitoringMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
MonitoringMessage::~MonitoringMessage() {
|
||||
}
|
||||
|
||||
void MonitoringMessage::setLimitViolationReport(CommandMessage* message,
|
||||
store_address_t storeId) {
|
||||
setTypicalMessage(message, LIMIT_VIOLATION_REPORT, storeId);
|
||||
}
|
||||
|
||||
void MonitoringMessage::setTypicalMessage(CommandMessage* message,
|
||||
Command_t type, store_address_t storeId) {
|
||||
message->setCommand(type);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
store_address_t MonitoringMessage::getStoreId(const CommandMessage* message) {
|
||||
store_address_t temp;
|
||||
temp.raw = message->getParameter2();
|
||||
return temp;
|
||||
}
|
||||
|
||||
void MonitoringMessage::clear(CommandMessage* message) {
|
||||
message->setCommand(CommandMessage::CMD_NONE);
|
||||
switch (message->getCommand()) {
|
||||
case MonitoringMessage::LIMIT_VIOLATION_REPORT: {
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != NULL) {
|
||||
ipcStore->deleteData(getStoreId(message));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
#ifndef MONITORINGMESSAGE_H_
|
||||
#define MONITORINGMESSAGE_H_
|
||||
|
||||
#include "../ipc/CommandMessage.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
|
||||
class MonitoringMessage: public CommandMessage {
|
||||
public:
|
||||
static const uint8_t MESSAGE_ID = messagetypes::MONITORING;
|
||||
//Object id could be useful, but we better manage that on service level (register potential reporters).
|
||||
static const Command_t LIMIT_VIOLATION_REPORT = MAKE_COMMAND_ID(10);
|
||||
virtual ~MonitoringMessage();
|
||||
static void setLimitViolationReport(CommandMessage* message, store_address_t storeId);
|
||||
static void clear(CommandMessage* message);
|
||||
static store_address_t getStoreId(const CommandMessage* message);
|
||||
static void setTypicalMessage(CommandMessage* message, Command_t type, store_address_t storeId);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* MONITORINGMESSAGE_H_ */
|
||||
#ifndef MONITORINGMESSAGE_H_
|
||||
#define MONITORINGMESSAGE_H_
|
||||
|
||||
#include "../ipc/CommandMessage.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
|
||||
class MonitoringMessage: public CommandMessage {
|
||||
public:
|
||||
static const uint8_t MESSAGE_ID = messagetypes::MONITORING;
|
||||
//Object id could be useful, but we better manage that on service level (register potential reporters).
|
||||
static const Command_t LIMIT_VIOLATION_REPORT = MAKE_COMMAND_ID(10);
|
||||
virtual ~MonitoringMessage();
|
||||
static void setLimitViolationReport(CommandMessage* message, store_address_t storeId);
|
||||
static void clear(CommandMessage* message);
|
||||
static store_address_t getStoreId(const CommandMessage* message);
|
||||
static void setTypicalMessage(CommandMessage* message, Command_t type, store_address_t storeId);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* MONITORINGMESSAGE_H_ */
|
||||
|
@ -1,77 +1,77 @@
|
||||
#ifndef MONITORINGMESSAGECONTENT_H_
|
||||
#define MONITORINGMESSAGECONTENT_H_
|
||||
|
||||
#include "../monitoring/HasMonitorsIF.h"
|
||||
#include "../monitoring/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"
|
||||
|
||||
namespace Factory{
|
||||
void setStaticFrameworkObjectIds();
|
||||
}
|
||||
|
||||
//PID(uint32_t), TYPE, LIMIT_ID, value,limitValue, previous, later, timestamp
|
||||
template<typename T>
|
||||
class MonitoringReportContent: public SerialLinkedListAdapter<SerializeIF> {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
public:
|
||||
SerializeElement<uint8_t> monitorId;
|
||||
SerializeElement<uint32_t> parameterId;
|
||||
SerializeElement<T> parameterValue;
|
||||
SerializeElement<T> limitValue;
|
||||
SerializeElement<ReturnValue_t> oldState;
|
||||
SerializeElement<ReturnValue_t> newState;
|
||||
uint8_t rawTimestamp[TimeStamperIF::MISSION_TIMESTAMP_SIZE];
|
||||
SerializeElement<SerialBufferAdapter<uint8_t>> timestampSerializer;
|
||||
TimeStamperIF* timeStamper;
|
||||
MonitoringReportContent() :
|
||||
SerialLinkedListAdapter<SerializeIF>(
|
||||
LinkedElement<SerializeIF>::Iterator(¶meterId)), monitorId(0), parameterId(
|
||||
0), parameterValue(0), limitValue(0), oldState(0), newState(
|
||||
0), rawTimestamp( { 0 }), timestampSerializer(rawTimestamp,
|
||||
sizeof(rawTimestamp)), timeStamper(NULL) {
|
||||
setAllNext();
|
||||
}
|
||||
MonitoringReportContent(uint32_t setPID, T value, T limitValue,
|
||||
ReturnValue_t oldState, ReturnValue_t newState) :
|
||||
SerialLinkedListAdapter<SerializeIF>(
|
||||
LinkedElement<SerializeIF>::Iterator(¶meterId)), monitorId(0), parameterId(
|
||||
setPID), parameterValue(value), limitValue(limitValue), oldState(
|
||||
oldState), newState(newState), timestampSerializer(rawTimestamp,
|
||||
sizeof(rawTimestamp)), timeStamper(NULL) {
|
||||
setAllNext();
|
||||
if (checkAndSetStamper()) {
|
||||
timeStamper->addTimeStamp(rawTimestamp, sizeof(rawTimestamp));
|
||||
}
|
||||
}
|
||||
private:
|
||||
|
||||
static object_id_t timeStamperId;
|
||||
void setAllNext() {
|
||||
parameterId.setNext(¶meterValue);
|
||||
parameterValue.setNext(&limitValue);
|
||||
limitValue.setNext(&oldState);
|
||||
oldState.setNext(&newState);
|
||||
newState.setNext(×tampSerializer);
|
||||
}
|
||||
bool checkAndSetStamper() {
|
||||
if (timeStamper == NULL) {
|
||||
timeStamper = objectManager->get<TimeStamperIF>( timeStamperId );
|
||||
if ( timeStamper == NULL ) {
|
||||
sif::error << "MonitoringReportContent::checkAndSetStamper: "
|
||||
"Stamper not found!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
template<typename T>
|
||||
object_id_t MonitoringReportContent<T>::timeStamperId = 0;
|
||||
|
||||
#endif /* MONITORINGMESSAGECONTENT_H_ */
|
||||
#ifndef MONITORINGMESSAGECONTENT_H_
|
||||
#define MONITORINGMESSAGECONTENT_H_
|
||||
|
||||
#include "../monitoring/HasMonitorsIF.h"
|
||||
#include "../monitoring/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"
|
||||
|
||||
namespace Factory{
|
||||
void setStaticFrameworkObjectIds();
|
||||
}
|
||||
|
||||
//PID(uint32_t), TYPE, LIMIT_ID, value,limitValue, previous, later, timestamp
|
||||
template<typename T>
|
||||
class MonitoringReportContent: public SerialLinkedListAdapter<SerializeIF> {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
public:
|
||||
SerializeElement<uint8_t> monitorId;
|
||||
SerializeElement<uint32_t> parameterId;
|
||||
SerializeElement<T> parameterValue;
|
||||
SerializeElement<T> limitValue;
|
||||
SerializeElement<ReturnValue_t> oldState;
|
||||
SerializeElement<ReturnValue_t> newState;
|
||||
uint8_t rawTimestamp[TimeStamperIF::MISSION_TIMESTAMP_SIZE];
|
||||
SerializeElement<SerialBufferAdapter<uint8_t>> timestampSerializer;
|
||||
TimeStamperIF* timeStamper;
|
||||
MonitoringReportContent() :
|
||||
SerialLinkedListAdapter<SerializeIF>(
|
||||
LinkedElement<SerializeIF>::Iterator(¶meterId)), monitorId(0), parameterId(
|
||||
0), parameterValue(0), limitValue(0), oldState(0), newState(
|
||||
0), rawTimestamp( { 0 }), timestampSerializer(rawTimestamp,
|
||||
sizeof(rawTimestamp)), timeStamper(NULL) {
|
||||
setAllNext();
|
||||
}
|
||||
MonitoringReportContent(uint32_t setPID, T value, T limitValue,
|
||||
ReturnValue_t oldState, ReturnValue_t newState) :
|
||||
SerialLinkedListAdapter<SerializeIF>(
|
||||
LinkedElement<SerializeIF>::Iterator(¶meterId)), monitorId(0), parameterId(
|
||||
setPID), parameterValue(value), limitValue(limitValue), oldState(
|
||||
oldState), newState(newState), timestampSerializer(rawTimestamp,
|
||||
sizeof(rawTimestamp)), timeStamper(NULL) {
|
||||
setAllNext();
|
||||
if (checkAndSetStamper()) {
|
||||
timeStamper->addTimeStamp(rawTimestamp, sizeof(rawTimestamp));
|
||||
}
|
||||
}
|
||||
private:
|
||||
|
||||
static object_id_t timeStamperId;
|
||||
void setAllNext() {
|
||||
parameterId.setNext(¶meterValue);
|
||||
parameterValue.setNext(&limitValue);
|
||||
limitValue.setNext(&oldState);
|
||||
oldState.setNext(&newState);
|
||||
newState.setNext(×tampSerializer);
|
||||
}
|
||||
bool checkAndSetStamper() {
|
||||
if (timeStamper == NULL) {
|
||||
timeStamper = objectManager->get<TimeStamperIF>( timeStamperId );
|
||||
if ( timeStamper == NULL ) {
|
||||
sif::error << "MonitoringReportContent::checkAndSetStamper: "
|
||||
"Stamper not found!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
template<typename T>
|
||||
object_id_t MonitoringReportContent<T>::timeStamperId = 0;
|
||||
|
||||
#endif /* MONITORINGMESSAGECONTENT_H_ */
|
||||
|
@ -1,15 +1,15 @@
|
||||
#ifndef RECEIVESMONITORINGREPORTSIF_H_
|
||||
#define RECEIVESMONITORINGREPORTSIF_H_
|
||||
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
|
||||
class ReceivesMonitoringReportsIF {
|
||||
public:
|
||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||
virtual ~ReceivesMonitoringReportsIF() {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* RECEIVESMONITORINGREPORTSIF_H_ */
|
||||
#ifndef RECEIVESMONITORINGREPORTSIF_H_
|
||||
#define RECEIVESMONITORINGREPORTSIF_H_
|
||||
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
|
||||
class ReceivesMonitoringReportsIF {
|
||||
public:
|
||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||
virtual ~ReceivesMonitoringReportsIF() {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* RECEIVESMONITORINGREPORTSIF_H_ */
|
||||
|
@ -1,155 +1,155 @@
|
||||
#ifndef FRAMEWORK_MONITORING_TRIPLEXMONITOR_H_
|
||||
#define FRAMEWORK_MONITORING_TRIPLEXMONITOR_H_
|
||||
|
||||
#include "../datapool/DataSet.h"
|
||||
#include "../datapool/PIDReaderList.h"
|
||||
#include "../health/HealthTableIF.h"
|
||||
#include "../parameters/HasParametersIF.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
|
||||
//SHOULDDO: This is by far not perfect. Could be merged with new Monitor classes. But still, it's over-engineering.
|
||||
template<typename T>
|
||||
class TriplexMonitor : public HasParametersIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::TRIPLE_REDUNDACY_CHECK;
|
||||
static const ReturnValue_t NOT_ENOUGH_SENSORS = MAKE_RETURN_CODE(1);
|
||||
static const ReturnValue_t LOWEST_VALUE_OOL = MAKE_RETURN_CODE(2);
|
||||
static const ReturnValue_t HIGHEST_VALUE_OOL = MAKE_RETURN_CODE(3);
|
||||
static const ReturnValue_t BOTH_VALUES_OOL = MAKE_RETURN_CODE(4);
|
||||
static const ReturnValue_t DUPLEX_OOL = MAKE_RETURN_CODE(5);
|
||||
|
||||
static const uint8_t THREE = 3;
|
||||
|
||||
TriplexMonitor(const uint32_t parameterIds[3], uint8_t domainId, const T initialLimit,
|
||||
Event eventTripleCheck, Event eventDualCheck) :
|
||||
values(parameterIds, &dataSet), limit(initialLimit), eventTripleCheck(
|
||||
eventTripleCheck), eventDualCheck(eventDualCheck), healthTable(
|
||||
NULL), domainId(domainId) {
|
||||
|
||||
}
|
||||
virtual ~TriplexMonitor() {
|
||||
}
|
||||
ReturnValue_t check() {
|
||||
dataSet.read();
|
||||
//check health and validity
|
||||
uint8_t availableIndex[2] = { 0, 0 };
|
||||
bool first = true;
|
||||
uint8_t nAvailable = 0;
|
||||
for (uint8_t count = 0; count < THREE; count++) {
|
||||
if (values[count].isValid() && checkObjectHealthState(count)) {
|
||||
if (first) {
|
||||
availableIndex[0] = count;
|
||||
first = false;
|
||||
} else {
|
||||
//Might be filled twice, but then it's not needed anyway.
|
||||
availableIndex[1] = count;
|
||||
}
|
||||
nAvailable++;
|
||||
}
|
||||
}
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
switch (nAvailable) {
|
||||
case 3:
|
||||
result = doTriplexMonitoring();
|
||||
break;
|
||||
case 2:
|
||||
result = doDuplexMonitoring(availableIndex);
|
||||
break;
|
||||
default:
|
||||
result = NOT_ENOUGH_SENSORS;
|
||||
break;
|
||||
}
|
||||
dataSet.commit();
|
||||
return result;
|
||||
}
|
||||
ReturnValue_t initialize() {
|
||||
healthTable = objectManager->get<HealthTableIF>(objects::HEALTH_TABLE);
|
||||
if (healthTable == NULL) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
|
||||
ParameterWrapper *parameterWrapper,
|
||||
const ParameterWrapper *newValues, uint16_t startAtIndex) {
|
||||
if (domainId != this->domainId) {
|
||||
return INVALID_DOMAIN_ID;
|
||||
}
|
||||
switch (parameterId) {
|
||||
case 0:
|
||||
parameterWrapper->set(limit);
|
||||
break;
|
||||
default:
|
||||
return INVALID_MATRIX_ID;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
DataSet dataSet;
|
||||
PIDReaderList<T, THREE> values;
|
||||
T limit;
|
||||
Event eventTripleCheck;
|
||||
Event eventDualCheck;
|
||||
HealthTableIF* healthTable;
|
||||
uint8_t domainId;
|
||||
ReturnValue_t doTriplexMonitoring() {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
//Find middle value, by ordering indices
|
||||
uint8_t index[3] = { 0, 1, 2 };
|
||||
if (values[index[0]].value > values[index[1]].value) {
|
||||
std::swap(index[0], index[1]);
|
||||
}
|
||||
if (values[index[0]].value > values[index[2]].value) {
|
||||
std::swap(index[0], index[2]);
|
||||
}
|
||||
if (values[index[1]].value > values[index[2]].value) {
|
||||
std::swap(index[1], index[2]);
|
||||
}
|
||||
//Test if smallest value is out-of-limit.
|
||||
if (values[index[0]] < (values[index[1]] - limit)) {
|
||||
EventManagerIF::triggerEvent(getRefereneceObject(index[0]),
|
||||
eventTripleCheck, LOWEST_VALUE_OOL, 0);
|
||||
result = LOWEST_VALUE_OOL;
|
||||
}
|
||||
//Test if largest value is out-of-limit.
|
||||
if (values[index[2]] > (values[index[1]] + limit)) {
|
||||
EventManagerIF::triggerEvent(getRefereneceObject(index[2]),
|
||||
eventTripleCheck, HIGHEST_VALUE_OOL, 0);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
result = HIGHEST_VALUE_OOL;
|
||||
} else {
|
||||
result = BOTH_VALUES_OOL;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t doDuplexMonitoring(uint8_t index[2]) {
|
||||
T mean = (values[index[0]] + values[index[1]]) / 2;
|
||||
if (values[index[0]] > values[index[1]]) {
|
||||
if (values[index[0]] > (mean + limit)) {
|
||||
EventManagerIF::triggerEvent(getRefereneceObject(index[0]),
|
||||
eventDualCheck, 0, 0);
|
||||
EventManagerIF::triggerEvent(getRefereneceObject(index[1]),
|
||||
eventDualCheck, 0, 0);
|
||||
return DUPLEX_OOL;
|
||||
}
|
||||
} else {
|
||||
if (values[index[1]] > (mean + limit)) {
|
||||
EventManagerIF::triggerEvent(getRefereneceObject(index[0]),
|
||||
eventDualCheck, 0, 0);
|
||||
EventManagerIF::triggerEvent(getRefereneceObject(index[1]),
|
||||
eventDualCheck, 0, 0);
|
||||
return DUPLEX_OOL;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
virtual bool checkObjectHealthState(uint8_t valueIndex) = 0;
|
||||
virtual object_id_t getRefereneceObject(uint8_t valueIndex) = 0;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_MONITORING_TRIPLEXMONITOR_H_ */
|
||||
#ifndef FRAMEWORK_MONITORING_TRIPLEXMONITOR_H_
|
||||
#define FRAMEWORK_MONITORING_TRIPLEXMONITOR_H_
|
||||
|
||||
#include "../datapool/DataSet.h"
|
||||
#include "../datapool/PIDReaderList.h"
|
||||
#include "../health/HealthTableIF.h"
|
||||
#include "../parameters/HasParametersIF.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
|
||||
//SHOULDDO: This is by far not perfect. Could be merged with new Monitor classes. But still, it's over-engineering.
|
||||
template<typename T>
|
||||
class TriplexMonitor : public HasParametersIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::TRIPLE_REDUNDACY_CHECK;
|
||||
static const ReturnValue_t NOT_ENOUGH_SENSORS = MAKE_RETURN_CODE(1);
|
||||
static const ReturnValue_t LOWEST_VALUE_OOL = MAKE_RETURN_CODE(2);
|
||||
static const ReturnValue_t HIGHEST_VALUE_OOL = MAKE_RETURN_CODE(3);
|
||||
static const ReturnValue_t BOTH_VALUES_OOL = MAKE_RETURN_CODE(4);
|
||||
static const ReturnValue_t DUPLEX_OOL = MAKE_RETURN_CODE(5);
|
||||
|
||||
static const uint8_t THREE = 3;
|
||||
|
||||
TriplexMonitor(const uint32_t parameterIds[3], uint8_t domainId, const T initialLimit,
|
||||
Event eventTripleCheck, Event eventDualCheck) :
|
||||
values(parameterIds, &dataSet), limit(initialLimit), eventTripleCheck(
|
||||
eventTripleCheck), eventDualCheck(eventDualCheck), healthTable(
|
||||
NULL), domainId(domainId) {
|
||||
|
||||
}
|
||||
virtual ~TriplexMonitor() {
|
||||
}
|
||||
ReturnValue_t check() {
|
||||
dataSet.read();
|
||||
//check health and validity
|
||||
uint8_t availableIndex[2] = { 0, 0 };
|
||||
bool first = true;
|
||||
uint8_t nAvailable = 0;
|
||||
for (uint8_t count = 0; count < THREE; count++) {
|
||||
if (values[count].isValid() && checkObjectHealthState(count)) {
|
||||
if (first) {
|
||||
availableIndex[0] = count;
|
||||
first = false;
|
||||
} else {
|
||||
//Might be filled twice, but then it's not needed anyway.
|
||||
availableIndex[1] = count;
|
||||
}
|
||||
nAvailable++;
|
||||
}
|
||||
}
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
switch (nAvailable) {
|
||||
case 3:
|
||||
result = doTriplexMonitoring();
|
||||
break;
|
||||
case 2:
|
||||
result = doDuplexMonitoring(availableIndex);
|
||||
break;
|
||||
default:
|
||||
result = NOT_ENOUGH_SENSORS;
|
||||
break;
|
||||
}
|
||||
dataSet.commit();
|
||||
return result;
|
||||
}
|
||||
ReturnValue_t initialize() {
|
||||
healthTable = objectManager->get<HealthTableIF>(objects::HEALTH_TABLE);
|
||||
if (healthTable == NULL) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
|
||||
ParameterWrapper *parameterWrapper,
|
||||
const ParameterWrapper *newValues, uint16_t startAtIndex) {
|
||||
if (domainId != this->domainId) {
|
||||
return INVALID_DOMAIN_ID;
|
||||
}
|
||||
switch (parameterId) {
|
||||
case 0:
|
||||
parameterWrapper->set(limit);
|
||||
break;
|
||||
default:
|
||||
return INVALID_MATRIX_ID;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
DataSet dataSet;
|
||||
PIDReaderList<T, THREE> values;
|
||||
T limit;
|
||||
Event eventTripleCheck;
|
||||
Event eventDualCheck;
|
||||
HealthTableIF* healthTable;
|
||||
uint8_t domainId;
|
||||
ReturnValue_t doTriplexMonitoring() {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
//Find middle value, by ordering indices
|
||||
uint8_t index[3] = { 0, 1, 2 };
|
||||
if (values[index[0]].value > values[index[1]].value) {
|
||||
std::swap(index[0], index[1]);
|
||||
}
|
||||
if (values[index[0]].value > values[index[2]].value) {
|
||||
std::swap(index[0], index[2]);
|
||||
}
|
||||
if (values[index[1]].value > values[index[2]].value) {
|
||||
std::swap(index[1], index[2]);
|
||||
}
|
||||
//Test if smallest value is out-of-limit.
|
||||
if (values[index[0]] < (values[index[1]] - limit)) {
|
||||
EventManagerIF::triggerEvent(getRefereneceObject(index[0]),
|
||||
eventTripleCheck, LOWEST_VALUE_OOL, 0);
|
||||
result = LOWEST_VALUE_OOL;
|
||||
}
|
||||
//Test if largest value is out-of-limit.
|
||||
if (values[index[2]] > (values[index[1]] + limit)) {
|
||||
EventManagerIF::triggerEvent(getRefereneceObject(index[2]),
|
||||
eventTripleCheck, HIGHEST_VALUE_OOL, 0);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
result = HIGHEST_VALUE_OOL;
|
||||
} else {
|
||||
result = BOTH_VALUES_OOL;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t doDuplexMonitoring(uint8_t index[2]) {
|
||||
T mean = (values[index[0]] + values[index[1]]) / 2;
|
||||
if (values[index[0]] > values[index[1]]) {
|
||||
if (values[index[0]] > (mean + limit)) {
|
||||
EventManagerIF::triggerEvent(getRefereneceObject(index[0]),
|
||||
eventDualCheck, 0, 0);
|
||||
EventManagerIF::triggerEvent(getRefereneceObject(index[1]),
|
||||
eventDualCheck, 0, 0);
|
||||
return DUPLEX_OOL;
|
||||
}
|
||||
} else {
|
||||
if (values[index[1]] > (mean + limit)) {
|
||||
EventManagerIF::triggerEvent(getRefereneceObject(index[0]),
|
||||
eventDualCheck, 0, 0);
|
||||
EventManagerIF::triggerEvent(getRefereneceObject(index[1]),
|
||||
eventDualCheck, 0, 0);
|
||||
return DUPLEX_OOL;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
virtual bool checkObjectHealthState(uint8_t valueIndex) = 0;
|
||||
virtual object_id_t getRefereneceObject(uint8_t valueIndex) = 0;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_MONITORING_TRIPLEXMONITOR_H_ */
|
||||
|
@ -1,44 +1,44 @@
|
||||
#ifndef FRAMEWORK_MONITORING_TWOVALUELIMITMONITOR_H_
|
||||
#define FRAMEWORK_MONITORING_TWOVALUELIMITMONITOR_H_
|
||||
|
||||
#include "../monitoring/LimitMonitor.h"
|
||||
|
||||
template<typename T>
|
||||
class TwoValueLimitMonitor: public LimitMonitor<T> {
|
||||
public:
|
||||
TwoValueLimitMonitor(object_id_t reporterId, uint8_t monitorId,
|
||||
uint32_t lowParameterId, uint32_t highParameterId,
|
||||
uint16_t confirmationLimit, T lowerLimit, T upperLimit,
|
||||
Event belowLowEvent = MonitoringIF::VALUE_BELOW_LOW_LIMIT,
|
||||
Event aboveHighEvent = MonitoringIF::VALUE_ABOVE_HIGH_LIMIT) :
|
||||
LimitMonitor<T>(reporterId, monitorId, lowParameterId,
|
||||
confirmationLimit, lowerLimit, upperLimit, belowLowEvent,
|
||||
aboveHighEvent), highValueParameterId(highParameterId) {
|
||||
}
|
||||
virtual ~TwoValueLimitMonitor() {
|
||||
}
|
||||
ReturnValue_t doCheck(T lowSample, T highSample) {
|
||||
T crossedLimit;
|
||||
ReturnValue_t currentState = this->checkSample(lowSample, &crossedLimit);
|
||||
if (currentState != HasReturnvaluesIF::RETURN_OK) {
|
||||
return this->monitorStateIs(currentState, lowSample, crossedLimit);
|
||||
}
|
||||
currentState = this->checkSample(highSample, &crossedLimit);
|
||||
return this->monitorStateIs(currentState, highSample, crossedLimit);
|
||||
}
|
||||
protected:
|
||||
virtual void sendTransitionReport(T parameterValue, T crossedLimit,
|
||||
ReturnValue_t state) {
|
||||
uint32_t usedParameterId = this->parameterId;
|
||||
if (state == MonitoringIF::ABOVE_HIGH_LIMIT) {
|
||||
usedParameterId = this->highValueParameterId;
|
||||
}
|
||||
MonitoringReportContent<T> report(usedParameterId, parameterValue,
|
||||
crossedLimit, this->oldState, state);
|
||||
LimitViolationReporter::sendLimitViolationReport(&report);
|
||||
}
|
||||
private:
|
||||
const uint32_t highValueParameterId;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_MONITORING_TWOVALUELIMITMONITOR_H_ */
|
||||
#ifndef FRAMEWORK_MONITORING_TWOVALUELIMITMONITOR_H_
|
||||
#define FRAMEWORK_MONITORING_TWOVALUELIMITMONITOR_H_
|
||||
|
||||
#include "../monitoring/LimitMonitor.h"
|
||||
|
||||
template<typename T>
|
||||
class TwoValueLimitMonitor: public LimitMonitor<T> {
|
||||
public:
|
||||
TwoValueLimitMonitor(object_id_t reporterId, uint8_t monitorId,
|
||||
uint32_t lowParameterId, uint32_t highParameterId,
|
||||
uint16_t confirmationLimit, T lowerLimit, T upperLimit,
|
||||
Event belowLowEvent = MonitoringIF::VALUE_BELOW_LOW_LIMIT,
|
||||
Event aboveHighEvent = MonitoringIF::VALUE_ABOVE_HIGH_LIMIT) :
|
||||
LimitMonitor<T>(reporterId, monitorId, lowParameterId,
|
||||
confirmationLimit, lowerLimit, upperLimit, belowLowEvent,
|
||||
aboveHighEvent), highValueParameterId(highParameterId) {
|
||||
}
|
||||
virtual ~TwoValueLimitMonitor() {
|
||||
}
|
||||
ReturnValue_t doCheck(T lowSample, T highSample) {
|
||||
T crossedLimit;
|
||||
ReturnValue_t currentState = this->checkSample(lowSample, &crossedLimit);
|
||||
if (currentState != HasReturnvaluesIF::RETURN_OK) {
|
||||
return this->monitorStateIs(currentState, lowSample, crossedLimit);
|
||||
}
|
||||
currentState = this->checkSample(highSample, &crossedLimit);
|
||||
return this->monitorStateIs(currentState, highSample, crossedLimit);
|
||||
}
|
||||
protected:
|
||||
virtual void sendTransitionReport(T parameterValue, T crossedLimit,
|
||||
ReturnValue_t state) {
|
||||
uint32_t usedParameterId = this->parameterId;
|
||||
if (state == MonitoringIF::ABOVE_HIGH_LIMIT) {
|
||||
usedParameterId = this->highValueParameterId;
|
||||
}
|
||||
MonitoringReportContent<T> report(usedParameterId, parameterValue,
|
||||
crossedLimit, this->oldState, state);
|
||||
LimitViolationReporter::sendLimitViolationReport(&report);
|
||||
}
|
||||
private:
|
||||
const uint32_t highValueParameterId;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_MONITORING_TWOVALUELIMITMONITOR_H_ */
|
||||
|
Reference in New Issue
Block a user