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.

86 lines
1.9 KiB
C++

/*
* FanControl.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "DSP2833x_Device.h"
#include "FLTSYSLIB/Hysteresis.h"
#include "FLTSYSLIB/DigitalInput.h"
#include "FLTSYSLIB/FTimer.h"
#include "FLTSYSLIB/Relay.h"
#ifndef SYSCTRL_FANCONTROL_H_
#define SYSCTRL_FANCONTROL_H_
namespace SYSCTRL
{
struct FanControlConfiguration
{
float delay_off_timer;
float control_state_timer;
float voltage_level_on;
float voltage_level_off;
FanControlConfiguration():
delay_off_timer(FP_ZERO),
control_state_timer(FP_ZERO),
voltage_level_on(FP_ZERO),
voltage_level_off(FP_ZERO)
{}
//
};//FanControlConfiguration
class FanControl
{
public:
enum mode_t {UNDEFINED, CONFIGURATE, OPERATIONAL};
private:
mode_t m_mode;
private:
float m_time_sample;
float m_contact_bounce_period;
float m_voltage_level_on;
float m_voltage_level_off;
private:
Uint16 m_km11_control;
Uint16 m_km11t_control;
bool m_fan_state;// false - is off, true - is on
bool m_fault;
FLTSYSLIB::Hysteresis m_voltage_relay;
FLTSYSLIB::FTimer m_delay_off_timer;
FLTSYSLIB::FTimer m_control_state_timer;
public:
FanControl();
void setup(float time_sample);
void configure(const FanControlConfiguration& config);
public:
mode_t get_mode();
bool compare(mode_t mode);
public:
Uint16 get_km11_control();
Uint16 get_km11t_control();
bool is_on();
bool is_off();
bool is_fault();
public:
void execute(float voltage, FLTSYSLIB::DigitalInput& aux_km);
private:
void (FanControl::*_execute)(float voltage, FLTSYSLIB::DigitalInput& aux_km);
void _execute_undef(float voltage, FLTSYSLIB::DigitalInput& aux_km);
void _execute_operational(float voltage, FLTSYSLIB::DigitalInput& aux_km);
//
};//FanControl
} /* namespace SYSCTRL */
#endif /* SYSCTRL_FANCONTROL_H_ */