auto-sync

This commit is contained in:
rusEfi 2014-11-17 14:03:37 -06:00
parent a661751ce8
commit b51f7d6d32
5 changed files with 32 additions and 21 deletions

View File

@ -11,12 +11,11 @@
#include "rpm_calculator.h"
#include "efiGpio.h"
extern LENameOrdinalPair * LE_FIRST;
//extern LENameOrdinalPair * LE_FIRST;
static LENameOrdinalPair leLess(LE_OPERATOR_LESS, "<");
static LENameOrdinalPair leLessEquals(LE_OPERATOR_LESS_OR_EQUAL, "<=");
static LENameOrdinalPair leMore(LE_OPERATOR_MORE, ">");
static LENameOrdinalPair leMoreEquals(LE_OPERATOR_MORE_OR_EQUAL, ">=");
/**
* Here we define all rusEfi-specific methods
*/
static LENameOrdinalPair leRpm(LE_METHOD_RPM, "rpm");
static LENameOrdinalPair leTps(LE_METHOD_TPS, "tps");
static LENameOrdinalPair leMaf(LE_METHOD_MAF, "maf");

View File

@ -25,9 +25,13 @@ LENameOrdinalPair * LE_FIRST = NULL;
*/
static LENameOrdinalPair leAnd(LE_OPERATOR_AND, "and");
static LENameOrdinalPair leOr(LE_OPERATOR_OR, "or");
static LENameOrdinalPair leNot(LE_OPERATOR_NOT, "not");
static LENameOrdinalPair leMore(LE_OPERATOR_MORE, ">");
static LENameOrdinalPair leMoreOrEqual(LE_OPERATOR_MORE_OR_EQUAL, ">=");
static LENameOrdinalPair leNot(LE_OPERATOR_NOT, "not");
static LENameOrdinalPair leLess(LE_OPERATOR_LESS, "<");
static LENameOrdinalPair leLessOrEquals(LE_OPERATOR_LESS_OR_EQUAL, "<=");
LENameOrdinalPair::LENameOrdinalPair(le_action_e action, const char *name) {
this->action = action;
@ -178,7 +182,9 @@ float LECalculator::getValue(Engine *engine) {
return stack.pop();
}
LEElementPool::LEElementPool() {
LEElementPool::LEElementPool(int size) {
pool = thepool;
this->size = size;
reset();
}
@ -198,7 +204,7 @@ bool isNumeric(const char* line) {
return line[0] >= '0' && line[0] <= '9';
}
const char *processToken(const char *line, char *buffer) {
const char *getNextToken(const char *line, char *buffer) {
while (line[0] != 0 && line[0] == ' ') {
line++;
}
@ -236,7 +242,7 @@ LEElement * parseExpression(LEElementPool *pool, const char * line) {
LEElement *last = NULL;
while (true) {
line = processToken(line, parsingBuffer);
line = getNextToken(line, parsingBuffer);
if (line == NULL) {
/**

View File

@ -57,12 +57,14 @@ public:
class LEElementPool {
public:
LEElementPool();
LEElement pool[LE_ELEMENT_POOL_SIZE];
LEElementPool(int size);
LEElement thepool[LE_ELEMENT_POOL_SIZE];
LEElement *pool;
LEElement *next();
void reset();
private:
int index;
int size;
};
@ -92,8 +94,12 @@ public:
const char *name;
};
const char *processToken(const char *line, char *buffer);
/**
* 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);
bool isNumeric(const char* line);
le_action_e parseAction(const char * line);
LEElement * parseExpression(LEElementPool *pool, const char * line);

View File

@ -57,7 +57,7 @@
LECalculator calc;
LEElementPool lePool;
LEElementPool lePool(LE_ELEMENT_POOL_SIZE);
LEElement * fuelPumpLogic;
LEElement * radiatorFanLogic;

View File

@ -42,21 +42,21 @@ static void testParsing(void) {
assertFalse(strEqualCaseInsensitive("hello", "HElo2"));
const char *ptr;
ptr = processToken(" hello ", buffer);
ptr = getNextToken(" hello ", buffer);
assertTrue(strEqual("hello", buffer));
ptr = processToken("hello", buffer);
ptr = getNextToken("hello", buffer);
assertTrue(strEqual("hello", buffer));
ptr = processToken(" hello world ", buffer);
ptr = getNextToken(" hello world ", buffer);
assertTrue(strEqual("hello", buffer));
ptr = processToken(ptr, buffer);
ptr = getNextToken(ptr, buffer);
assertTrue(strEqual("world", buffer));
assertTrue(isNumeric("123"));
assertFalse(isNumeric("a123"));
LEElementPool pool;
LEElementPool pool(LE_ELEMENT_POOL_SIZE);
LEElement *element;
element = parseExpression(&pool, "1 3 AND not");
@ -80,7 +80,7 @@ static void testParsing(void) {
}
static void testExpression(const char *line, float expected) {
LEElementPool pool;
LEElementPool pool(LE_ELEMENT_POOL_SIZE);
pool.reset();
LEElement * element = parseExpression(&pool, line);
print("Parsing [%s]", line);
@ -119,7 +119,7 @@ void testLogicExpressions(void) {
c.reset();
LEElementPool pool;
LEElementPool pool(LE_ELEMENT_POOL_SIZE);
LEElement *e = pool.next();
e->init(LE_METHOD_TIME_SINCE_BOOT);