3#ifndef IMT_BASE_LIB_ALARMS_RANGEALARMWITHHYSTERESIS_H
4#define IMT_BASE_LIB_ALARMS_RANGEALARMWITHHYSTERESIS_H
19template<
typename ValueType>
73 void activateLowerAlarm();
74 void activateUpperAlarm();
75 void deactivateLowerAlarm();
76 void deactivateUpperAlarm();
77 void updateValueUpperRange(ValueType
const& value);
78 void updateValueLowerRange(ValueType
const& value);
86 bool m_isLowerAlarmActive;
88 bool m_isUpperAlarmActive;
91template<
typename ValueType>
98 ::
imt::base::core::platform::Noncopyable {},
99 m_alarmSender {alarmSender},
100 m_rangeSet {rangeSet},
101 m_rangeReset {rangeReset},
102 m_lowerAlarmId {lowerAlarmId},
103 m_upperAlarmId {upperAlarmId},
104 m_isLowerAlarmActive {
false},
105 m_isUpperAlarmActive {
false} {
108template<
typename ValueType>
110 updateValueUpperRange(value);
111 updateValueLowerRange(value);
114template<
typename ValueType>
116 deactivateLowerAlarm();
117 deactivateUpperAlarm();
120template<
typename ValueType>
122 return m_isLowerAlarmActive || m_isUpperAlarmActive;
125template<
typename ValueType>
127 return m_isLowerAlarmActive;
130template<
typename ValueType>
132 return m_isUpperAlarmActive;
137template<
typename ValueType>
140 if (!m_isLowerAlarmActive) {
141 if (m_lowerAlarmId != NO_ALARM) {
142 m_alarmSender.activateAlarm(m_lowerAlarmId);
143 m_isLowerAlarmActive =
true;
148template<
typename ValueType>
149void RangeAlarmWithHysteresis<ValueType>::activateUpperAlarm() {
151 if (!m_isUpperAlarmActive) {
152 if (m_upperAlarmId != NO_ALARM) {
153 m_alarmSender.activateAlarm(m_upperAlarmId);
154 m_isUpperAlarmActive =
true;
159template<
typename ValueType>
160void RangeAlarmWithHysteresis<ValueType>::deactivateLowerAlarm() {
162 if (m_isLowerAlarmActive) {
163 if (m_lowerAlarmId != NO_ALARM) {
164 m_alarmSender.deactivateAlarm(m_lowerAlarmId);
166 m_isLowerAlarmActive =
false;
170template<
typename ValueType>
171void RangeAlarmWithHysteresis<ValueType>::deactivateUpperAlarm() {
173 if (m_isUpperAlarmActive) {
174 if (m_upperAlarmId != NO_ALARM) {
175 m_alarmSender.deactivateAlarm(m_upperAlarmId);
177 m_isUpperAlarmActive =
false;
181template<
typename ValueType>
182void RangeAlarmWithHysteresis<ValueType>::updateValueUpperRange(ValueType
const& value) {
184 if (m_rangeSet.isAbove(value)) {
185 activateUpperAlarm();
187 else if (!m_rangeReset.isAbove(value)) {
188 deactivateUpperAlarm();
192template<
typename ValueType>
193void RangeAlarmWithHysteresis<ValueType>::updateValueLowerRange(ValueType
const& value) {
195 if (m_rangeSet.isBelow(value)) {
196 activateLowerAlarm();
198 else if (!m_rangeReset.isBelow(value)) {
199 deactivateLowerAlarm();
A range of values limited by an lower and upper value that is included in the range.
Interface to send an alarm message to activate or deactivate a given alarm.
Activates the given alarms if the value is outside the set range.
bool isUpperAlarmActive() const
Returns whether the upper alarm is currently activated.
RangeAlarmWithHysteresis(AlarmSenderIfc &alarmSender, ::imt::base::core::util::Range< ValueType > const &rangeSet, ::imt::base::core::util::Range< ValueType > const &rangeReset, AlarmIdentifier const lowerAlarmId, AlarmIdentifier const upperAlarmId)
Constructor.
void deactivateAlarms()
Deactivates both alarms.
bool isLowerAlarmActive() const
Returns whether the lower alarm is currently activated.
void updateValue(ValueType const &value)
Updates the value and checks for the alarm condition.
bool isAlarmActive() const
Returns if any alarm is currently activated.
uint32_t AlarmIdentifier
The alarm identifier.
This is a application specific file which is used to configure Imt.Base.Core.Math.