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 "rpm_calculator.h"
#include "efiGpio.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, "<="); * Here we define all rusEfi-specific methods
static LENameOrdinalPair leMore(LE_OPERATOR_MORE, ">"); */
static LENameOrdinalPair leMoreEquals(LE_OPERATOR_MORE_OR_EQUAL, ">=");
static LENameOrdinalPair leRpm(LE_METHOD_RPM, "rpm"); static LENameOrdinalPair leRpm(LE_METHOD_RPM, "rpm");
static LENameOrdinalPair leTps(LE_METHOD_TPS, "tps"); static LENameOrdinalPair leTps(LE_METHOD_TPS, "tps");
static LENameOrdinalPair leMaf(LE_METHOD_MAF, "maf"); 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 leAnd(LE_OPERATOR_AND, "and");
static LENameOrdinalPair leOr(LE_OPERATOR_OR, "or"); static LENameOrdinalPair leOr(LE_OPERATOR_OR, "or");
static LENameOrdinalPair leNot(LE_OPERATOR_NOT, "not");
static LENameOrdinalPair leMore(LE_OPERATOR_MORE, ">"); static LENameOrdinalPair leMore(LE_OPERATOR_MORE, ">");
static LENameOrdinalPair leMoreOrEqual(LE_OPERATOR_MORE_OR_EQUAL, ">="); 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) { LENameOrdinalPair::LENameOrdinalPair(le_action_e action, const char *name) {
this->action = action; this->action = action;
@ -178,7 +182,9 @@ float LECalculator::getValue(Engine *engine) {
return stack.pop(); return stack.pop();
} }
LEElementPool::LEElementPool() { LEElementPool::LEElementPool(int size) {
pool = thepool;
this->size = size;
reset(); reset();
} }
@ -198,7 +204,7 @@ bool isNumeric(const char* line) {
return line[0] >= '0' && line[0] <= '9'; 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] == ' ') { while (line[0] != 0 && line[0] == ' ') {
line++; line++;
} }
@ -236,7 +242,7 @@ LEElement * parseExpression(LEElementPool *pool, const char * line) {
LEElement *last = NULL; LEElement *last = NULL;
while (true) { while (true) {
line = processToken(line, parsingBuffer); line = getNextToken(line, parsingBuffer);
if (line == NULL) { if (line == NULL) {
/** /**

View File

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

View File

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

View File

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