2016-06-15 23:48:41 +02:00
|
|
|
#ifndef FRAMEWORK_MONITORING_TWOVALUELIMITMONITOR_H_
|
|
|
|
#define FRAMEWORK_MONITORING_TWOVALUELIMITMONITOR_H_
|
|
|
|
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "LimitMonitor.h"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
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;
|
2018-07-13 18:28:26 +02:00
|
|
|
ReturnValue_t currentState = this->checkSample(lowSample, &crossedLimit);
|
2016-06-15 23:48:41 +02:00
|
|
|
if (currentState != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
return this->monitorStateIs(currentState, lowSample, crossedLimit);
|
|
|
|
}
|
2018-07-13 18:28:26 +02:00
|
|
|
currentState = this->checkSample(highSample, &crossedLimit);
|
2016-06-15 23:48:41 +02:00
|
|
|
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_ */
|