custom-board-bundle-sample-.../firmware/controllers/core/logic_expression.h

95 lines
1.7 KiB
C
Raw Normal View History

2014-10-03 12:05:03 -07:00
/**
* @file logic_expression.h
*
* @date Oct 3, 2014
* @author Andrey Belomutskiy, (c) 2012-2014
*/
#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,
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-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
#define LE_ELEMENT_POOL_SIZE 64
class LEElementPool {
public:
LEElementPool();
LEElement pool[LE_ELEMENT_POOL_SIZE];
LEElement *next();
void reset();
private:
int index;
};
2014-10-03 12:05:03 -07:00
#define MAX_STACK_DEPTH 32
class LECalculator {
public:
LECalculator();
float getValue();
void add(LEElement *element);
2014-10-03 15:03:01 -07:00
void reset();
2014-10-03 12:05:03 -07:00
private:
2014-10-03 14:03:00 -07:00
void doJob(LEElement *element);
2014-10-03 15:03:01 -07:00
LEElement *first;
2014-10-03 12:05:03 -07:00
FLStack<float, MAX_STACK_DEPTH> stack;
};
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-10-04 08:03:38 -07:00
const char *processToken(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);
LEElement * parseExpression(LEElementPool *pool, const char * line);
2014-10-04 08:03:38 -07:00
2014-10-03 12:05:03 -07:00
#endif /* LOGIC_EXPRESSION_H_ */