From 2e4c6c6f76cb839eb014472f1f228683d413742b Mon Sep 17 00:00:00 2001 From: rusEfi Date: Tue, 18 Nov 2014 15:03:12 -0600 Subject: [PATCH] auto-sync --- firmware/controllers/core/logic_expression.cpp | 9 ++++++--- firmware/controllers/core/logic_expression.h | 2 +- firmware/controllers/engine_controller.cpp | 2 +- unit_tests/test_logic_expression.cpp | 6 +++--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/firmware/controllers/core/logic_expression.cpp b/firmware/controllers/core/logic_expression.cpp index c7d65f56a6..a12103d025 100644 --- a/firmware/controllers/core/logic_expression.cpp +++ b/firmware/controllers/core/logic_expression.cpp @@ -243,7 +243,7 @@ le_action_e parseAction(const char * line) { static char parsingBuffer[64]; -LEElement * parseExpression(LEElementPool *pool, const char * line) { +LEElement *LEElementPool::parseExpression(const char * line) { LEElement *first = NULL; LEElement *last = NULL; @@ -258,7 +258,7 @@ LEElement * parseExpression(LEElementPool *pool, const char * line) { return first; } - LEElement *n = pool->next(); + LEElement *n = next(); if (isNumeric(parsingBuffer)) { n->init(LE_NUMERIC_VALUE, atoff(parsingBuffer)); @@ -288,11 +288,14 @@ LEElement * parseExpression(LEElementPool *pool, const char * line) { #if (EFI_PROD_CODE || EFI_SIMULATOR) static void eval(char *line, Engine *engine) { + evalPool.reset(); + evalPool.parseExpression(line); + } void initEval(Engine *engine) { - addConsoleActionSP("evan", (VoidCharPtrVoidPtr)eval, engine); + addConsoleActionSP("eval", (VoidCharPtrVoidPtr)eval, engine); } #endif diff --git a/firmware/controllers/core/logic_expression.h b/firmware/controllers/core/logic_expression.h index 7d11a26b97..4b49b2c75b 100644 --- a/firmware/controllers/core/logic_expression.h +++ b/firmware/controllers/core/logic_expression.h @@ -59,6 +59,7 @@ public: LEElement *pool; LEElement *next(); void reset(); + LEElement * parseExpression(const char * line); private: int index; int size; @@ -99,7 +100,6 @@ public: 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); void initEval(Engine *engine); #endif /* LOGIC_EXPRESSION_H_ */ diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index e3c2520ab7..4b074286c6 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -400,7 +400,7 @@ void initEngineContoller(Engine *engine) { #endif #if EFI_FUEL_PUMP - fuelPumpLogic = parseExpression(&lePool, FUEL_PUMP_LOGIC); + fuelPumpLogic = lePool.parseExpression(FUEL_PUMP_LOGIC); #endif addConsoleAction("analoginfo", printAnalogInfo); diff --git a/unit_tests/test_logic_expression.cpp b/unit_tests/test_logic_expression.cpp index ea74a483e9..123cffc94d 100644 --- a/unit_tests/test_logic_expression.cpp +++ b/unit_tests/test_logic_expression.cpp @@ -62,7 +62,7 @@ static void testParsing(void) { LEElementPool pool(thepool, TEST_POOL_SIZE); LEElement *element; - element = parseExpression(&pool, "1 3 AND not"); + element = pool.parseExpression("1 3 AND not"); assertTrue(element != NULL); assertEquals(element->action, LE_NUMERIC_VALUE); @@ -86,7 +86,7 @@ static void testExpression(const char *line, float expected) { LEElement thepool[TEST_POOL_SIZE]; LEElementPool pool(thepool, TEST_POOL_SIZE); pool.reset(); - LEElement * element = parseExpression(&pool, line); + LEElement * element = pool.parseExpression(line); print("Parsing [%s]", line); assertTrueM("Not NULL expected", element != NULL); LECalculator c; @@ -148,7 +148,7 @@ void testLogicExpressions(void) { pool.reset(); LEElement *element; - element = parseExpression(&pool, "fan no_such_method"); + element = pool.parseExpression("fan no_such_method"); assertTrueM("NULL expected", element == NULL);