fome-fw/firmware/controllers/core/fsio_core.h

117 lines
2.3 KiB
C
Raw Normal View History

2014-10-03 12:05:03 -07:00
/**
2014-12-27 13:03:38 -08:00
* @file fsio_core.h
2014-10-03 12:05:03 -07:00
*
* @date Oct 3, 2014
2015-01-12 15:04:10 -08:00
* @author Andrey Belomutskiy, (c) 2012-2015
2014-10-03 12:05:03 -07:00
*/
#ifndef LOGIC_EXPRESSION_H_
#define LOGIC_EXPRESSION_H_
#include "rusefi_enums.h"
#include "fl_stack.h"
2014-10-05 07:03:00 -07:00
#include "engine.h"
2014-10-03 12:05:03 -07:00
typedef enum {
2014-10-03 16:03:06 -07:00
2014-10-05 07:03:00 -07:00
LE_UNDEFINED = 0 ,
LE_NUMERIC_VALUE = 1,
LE_OPERATOR_LESS = 2,
LE_OPERATOR_MORE = 3,
LE_OPERATOR_LESS_OR_EQUAL = 4,
LE_OPERATOR_MORE_OR_EQUAL = 5,
LE_OPERATOR_AND = 6,
LE_OPERATOR_OR = 7,
LE_OPERATOR_NOT = 8,
2014-11-18 18:05:41 -08:00
LE_OPERATOR_ADDITION = 9,
LE_OPERATOR_SUBSTRACTION = 10,
LE_OPERATOR_MULTIPLICATION = 11,
LE_OPERATOR_DIVISION = 12,
2014-12-04 17:03:09 -08:00
LE_METHOD_MAX = 13,
LE_METHOD_MIN = 14,
2014-12-04 18:03:12 -08:00
LE_METHOD_IF = 15,
2014-10-05 07:03:00 -07:00
LE_METHOD_RPM = 100,
LE_METHOD_COOLANT = 101,
LE_METHOD_FAN = 102,
LE_METHOD_TIME_SINCE_BOOT = 103,
LE_METHOD_FAN_ON_SETTING = 104,
LE_METHOD_FAN_OFF_SETTING = 105,
2014-10-06 00:03:15 -07:00
LE_METHOD_TPS = 106,
LE_METHOD_MAF = 107,
LE_METHOD_INTAKE_AIR = 108,
2014-11-06 10:04:30 -08:00
LE_METHOD_VBATT = 109,
2014-11-26 20:03:05 -08:00
LE_METHOD_AC_TOGGLE = 110,
2014-12-05 19:04:09 -08:00
LE_METHOD_FSIO_SETTING = 111,
2014-10-03 12:05:03 -07:00
2014-10-05 07:03:00 -07:00
Force_4b_le_action = ENUM_SIZE_HACK,
2014-10-03 15:03:01 -07:00
2014-10-03 12:05:03 -07:00
} le_action_e;
class LEElement {
public:
LEElement();
// void init(le_action_e action, int iValue);
void init(le_action_e action);
void init(le_action_e action, float fValue);
le_action_e action;
float fValue;
int iValue;
LEElement *next;
};
2014-10-03 15:03:01 -07:00
class LEElementPool {
public:
2014-11-17 13:03:20 -08:00
LEElementPool(LEElement *pool, int size);
2014-11-17 12:03:37 -08:00
LEElement *pool;
2014-10-03 15:03:01 -07:00
LEElement *next();
void reset();
2014-11-18 13:03:12 -08:00
LEElement * parseExpression(const char * line);
2014-12-06 12:04:01 -08:00
int getSize();
2014-10-03 15:03:01 -07:00
private:
int index;
2014-12-06 12:04:01 -08:00
int capacity;
2014-10-03 15:03:01 -07:00
};
2014-10-03 12:05:03 -07:00
#define MAX_STACK_DEPTH 32
2014-12-05 19:04:09 -08:00
typedef FLStack<float, MAX_STACK_DEPTH> calc_stack_t;
2014-10-03 12:05:03 -07:00
class LECalculator {
public:
LECalculator();
2014-10-06 05:03:03 -07:00
float getValue(Engine *engine);
2014-10-18 04:03:25 -07:00
float getValue2(LEElement *element, Engine *engine);
2014-10-03 12:05:03 -07:00
void add(LEElement *element);
2014-10-03 15:03:01 -07:00
void reset();
2014-10-06 02:03:01 -07:00
void reset(LEElement *element);
2014-10-03 12:05:03 -07:00
private:
2014-10-06 05:03:03 -07:00
void doJob(Engine *engine, LEElement *element);
2014-10-07 08:04:35 -07:00
float pop(le_action_e action);
2014-10-03 15:03:01 -07:00
LEElement *first;
2014-12-05 19:04:09 -08:00
calc_stack_t stack;
2014-10-03 12:05:03 -07:00
};
2014-10-04 15:03:07 -07:00
class LENameOrdinalPair {
public:
LENameOrdinalPair(le_action_e action, const char *name);
LENameOrdinalPair *next;
le_action_e action;
const char *name;
};
2014-11-17 12:03:37 -08:00
/**
* This method extract the first token on the line into the specified buffer
*
* @return pointer after the token
*/
const char *getNextToken(const char *line, char *buffer);
2014-10-04 11:02:53 -07:00
bool isNumeric(const char* line);
le_action_e parseAction(const char * line);
2014-10-04 08:03:38 -07:00
2014-10-03 12:05:03 -07:00
#endif /* LOGIC_EXPRESSION_H_ */