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.

115 lines
3.0 KiB
C

/*
* AlgorithmContext.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "SYSCTRL/AlgorithmBase.h"
#include "SYSCTRL/AlgorithmFault.h"
#include "SYSCTRL/AlgorithmOff.h"
#include "SYSCTRL/AlgorithmSource.h"
#include "SYSCTRL/AlgorithmStart.h"
#include "SYSCTRL/AlgorithmStop.h"
#include "SYSCTRL/AlgorithmWork.h"
#include "SYSCTRL/AlgorithmZero.h"
#include "SYSCTRL/SystemEnvironment.h"
#ifndef SYSCTRL_ALGORITHMCONTEXT_H_
#define SYSCTRL_ALGORITHMCONTEXT_H_
namespace SYSCTRL
{
class AlgorithmContext
{
private:
friend class SYSCTRL::AlgorithmBase;
friend class SYSCTRL::AlgorithmFault;
friend class SYSCTRL::AlgorithmWork;
friend class SYSCTRL::AlgorithmStop;
friend class SYSCTRL::AlgorithmStart;
friend class SYSCTRL::AlgorithmOff;
friend class SYSCTRL::AlgorithmSource;
public:
enum mode_t {UNDEFINED, CONFIGURATE, OPERATIONAL};
enum algorithm_t {UNKNOWN, OFF, START, ENTRY, WORK, STOP, FAULT, SOURCE};
private:
mode_t m_mode;
algorithm_t m_algorithm;
algorithm_t m_algorithm_previous;
private:
SYSCTRL::SystemEnvironment& m_env;
private:
SYSCTRL::AlgorithmBase* m_algorithm_pointer;
SYSCTRL::AlgorithmFault m_fault;
SYSCTRL::AlgorithmWork m_work;
SYSCTRL::AlgorithmStop m_stop;
SYSCTRL::AlgorithmStart m_start;
SYSCTRL::AlgorithmOff m_off;
SYSCTRL::AlgorithmSource m_source;
public:
AlgorithmContext(SYSCTRL::SystemEnvironment& env);
void setup();
void configure();
public:
mode_t get_mode();
algorithm_t get_algorithm();
bool compare(const mode_t mode);
bool compare_algorithm(const algorithm_t algorithm);
public:
void get_ref_invertor_voltage(float& volt_a, float& volt_b, float& volt_c);
public:
void strategy();
private:
void (AlgorithmContext::*_strategy)();
void _strategy_undef();
void _strategy_fault();
void _strategy_work();
void _strategy_stop();
void _strategy_start();
void _strategy_off();
void _strategy_source();
public:
void set_strategy_fault();
void set_strategy_work();
void set_strategy_stop();
void set_strategy_start();
void set_strategy_off();
void set_strategy_source();
public:
void execute();
public:
void set_fault();
void set_work();
void set_stop();
void set_start();
void set_off();
void set_source();
private:
void (AlgorithmContext::*_set_fault)();
void (AlgorithmContext::*_set_work)();
void (AlgorithmContext::*_set_stop)();
void (AlgorithmContext::*_set_start)();
void (AlgorithmContext::*_set_off)();
void (AlgorithmContext::*_set_source)();
void _set_fault_exe();
void _set_work_exe();
void _set_stop_exe();
void _set_start_exe();
void _set_off_exe();
void _set_source_exe();
void _set_empty_exe();
//
};//class AlgorithmContext
} /* namespace SYSCTRL */
#endif /* SYSCTRL_ALGORITHMCONTEXT_H_ */