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.
93 lines
1.7 KiB
C++
93 lines
1.7 KiB
C++
/*
|
|
* FaultExceed.cpp
|
|
*
|
|
* Author: Aleksey Gerasimenko
|
|
* gerasimenko.aleksey.n@gmail.com
|
|
*/
|
|
|
|
#include "Alert/FaultExceed.h"
|
|
|
|
namespace ALERT
|
|
{
|
|
//CONSTRUCTOR
|
|
FaultExceed::FaultExceed():
|
|
ALERT::AlertBase(),
|
|
m_fault(false),
|
|
fault(false),
|
|
_execute(&ALERT::FaultExceed::_execute_undef)
|
|
//
|
|
{}//CONSTRUCTOR
|
|
//
|
|
void FaultExceed::setup(float time_sample)
|
|
{
|
|
m_time_sample = time_sample;
|
|
//
|
|
}//setup()
|
|
//
|
|
void FaultExceed::configure(const AlertBaseConfiguration& config)
|
|
{
|
|
|
|
m_level = config.level;
|
|
m_period = config.period;
|
|
//
|
|
m_fault = false;
|
|
fault = false;
|
|
|
|
//
|
|
if((m_time_sample > FP_ZERO) && (m_period >= m_time_sample)&&(m_level > FP_ZERO))
|
|
{
|
|
_execute = &ALERT::FaultExceed::_execute_operational;
|
|
//
|
|
}//if
|
|
//
|
|
}//configure()
|
|
//
|
|
#pragma CODE_SECTION("ramfuncs");
|
|
void FaultExceed::reset()
|
|
{
|
|
m_fault = false;
|
|
fault = false;
|
|
m_timer = FP_ZERO;
|
|
//
|
|
}//reset()
|
|
//
|
|
void FaultExceed::execute(float reference)
|
|
{
|
|
(this->*_execute)(reference);
|
|
//
|
|
}//execute()
|
|
//
|
|
void FaultExceed::_execute_undef(float reference)
|
|
{}//
|
|
//
|
|
#pragma CODE_SECTION("ramfuncs");
|
|
void FaultExceed::_execute_operational(float reference)
|
|
{
|
|
if(reference >= m_level)
|
|
{
|
|
if(m_timer >= m_period)
|
|
{
|
|
m_fault = true;
|
|
fault = true;
|
|
}
|
|
else
|
|
{
|
|
m_timer += m_time_sample;
|
|
m_fault = false;
|
|
fault = false;
|
|
//
|
|
}//if else
|
|
//
|
|
}
|
|
else
|
|
{
|
|
m_timer = FP_ZERO;
|
|
m_fault = false;
|
|
fault = false;
|
|
//
|
|
}//if else
|
|
//
|
|
}//
|
|
//
|
|
} /* namespace ALERT */
|