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.
90 lines
1.7 KiB
C++
90 lines
1.7 KiB
C++
/*
|
|
* ContactorFault.cpp
|
|
*
|
|
* Author: Aleksey Gerasimenko
|
|
* gerasimenko.aleksey.n@gmail.com
|
|
*/
|
|
#include "SYSCTRL/ContactorFault.h"
|
|
|
|
namespace SYSCTRL
|
|
{
|
|
//CONSTRUCTOR
|
|
ContactorFault::ContactorFault():
|
|
m_time_sample(-1.0),
|
|
m_period(-1.0),
|
|
m_counter(FP_ZERO),
|
|
m_status(),
|
|
status(),
|
|
_execute(&SYSCTRL::ContactorFault::_execute_undef)
|
|
{}
|
|
//end CONSTRUCTOR
|
|
|
|
void ContactorFault::setup(float time_sample)
|
|
{
|
|
|
|
m_time_sample = time_sample;
|
|
_execute = &SYSCTRL::ContactorFault::_execute_undef;
|
|
//
|
|
}//
|
|
//
|
|
void ContactorFault::configure(ContactorFaultConfiguration& config)
|
|
{
|
|
m_period = config.period;
|
|
|
|
if((m_time_sample > FP_ZERO) && (m_period > m_time_sample))
|
|
{
|
|
_execute = &SYSCTRL::ContactorFault::_execute_operational;
|
|
}
|
|
//
|
|
}//
|
|
//
|
|
//#pragma CODE_SECTION("ramfuncs");
|
|
void ContactorFault::reset(bool ref)
|
|
{
|
|
m_status.signal.fault &= !ref;
|
|
status.all = m_status.all;
|
|
//
|
|
}//
|
|
//
|
|
#pragma CODE_SECTION("ramfuncs");
|
|
void ContactorFault::execute(bool ref, bool current)
|
|
{
|
|
(this->*_execute)(ref, current);
|
|
//
|
|
}//
|
|
//
|
|
|
|
void ContactorFault::_execute_undef(bool ref, bool current)
|
|
{
|
|
//
|
|
}//
|
|
//
|
|
#pragma CODE_SECTION("ramfuncs");
|
|
void ContactorFault::_execute_operational(bool ref, bool current)
|
|
{
|
|
if(!m_status.signal.fault)
|
|
{
|
|
if(ref == current)
|
|
{
|
|
m_counter = FP_ZERO;
|
|
|
|
}else{
|
|
|
|
if(m_counter >= m_period)
|
|
{
|
|
m_status.signal.fault = 1;
|
|
m_counter = FP_ZERO;
|
|
|
|
}else{
|
|
|
|
m_counter += m_time_sample;
|
|
}
|
|
}
|
|
}
|
|
status.all = m_status.all;
|
|
//
|
|
}//
|
|
//
|
|
|
|
} /* namespace SYSCTRL */
|