You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
1.7 KiB
C++

/*
* WarningExceed.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "Alert/WarningExceed.h"
namespace ALERT
{
//CONSTRUCTOR
WarningExceed::WarningExceed():
ALERT::AlertBase(),
m_warning(false),
warning(false),
_execute(&ALERT::WarningExceed::_execute_undef)
{}//CONSTRUCTOR
//
void WarningExceed::setup(float time_sample)
{
m_time_sample = time_sample;
//
}//setup()
//
void WarningExceed::configure(const AlertBaseConfiguration& config)
{
m_level = config.level;
m_period = config.period;
//
m_warning = false;
//
if((m_time_sample > FP_ZERO)&&(m_period > m_time_sample)&&(m_level >= FP_ZERO))
{
_execute = &ALERT::WarningExceed::_execute_operational;
//
}//if
//
}//configure()
//
//
//
//
#pragma CODE_SECTION("ramfuncs");
void WarningExceed::reset()
{
m_warning = false;
warning = false;
m_timer = FP_ZERO;
//
}//reset()
//
void WarningExceed::execute(float reference)
{
(this->*_execute)(reference);
//
}//execute()
//
void WarningExceed::_execute_undef(float reference)
{}//
//
#pragma CODE_SECTION("ramfuncs");
void WarningExceed::_execute_operational(float reference)
{
//
if(reference >= m_level)
{
if(m_timer >= m_period)
{
m_warning = true;
warning = true;
}
else
{
m_timer += m_time_sample;
m_warning = false;
warning = false;
//
}//if else
}
else
{
m_warning = false;
warning = false;
m_timer = FP_ZERO;
//
}//else if
//
}//_execute_operational()
//
} /* namespace ALERT */