auto-sync
This commit is contained in:
parent
b7286292ff
commit
f92aa12489
|
@ -12,6 +12,10 @@
|
||||||
|
|
||||||
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, ">=");
|
||||||
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");
|
||||||
|
@ -21,10 +25,10 @@ static LENameOrdinalPair leFanOnSetting(LE_METHOD_FAN_ON_SETTING, "fan_on_settin
|
||||||
static LENameOrdinalPair leFanOffSetting(LE_METHOD_FAN_OFF_SETTING, "fan_off_setting");
|
static LENameOrdinalPair leFanOffSetting(LE_METHOD_FAN_OFF_SETTING, "fan_off_setting");
|
||||||
static LENameOrdinalPair leTimeSinceBoot(LE_METHOD_TIME_SINCE_BOOT, "time_since_boot");
|
static LENameOrdinalPair leTimeSinceBoot(LE_METHOD_TIME_SINCE_BOOT, "time_since_boot");
|
||||||
|
|
||||||
|
|
||||||
#if EFI_PROD_CODE || EFI_SIMULATOR
|
#if EFI_PROD_CODE || EFI_SIMULATOR
|
||||||
float getLEValue(Engine *engine, le_action_e action) {
|
float getLEValue(Engine *engine, le_action_e action) {
|
||||||
switch(action) {
|
efiAssert(engine!=NULL, "getLEValue", NAN);
|
||||||
|
switch (action) {
|
||||||
// case LE_METHOD_FAN:
|
// case LE_METHOD_FAN:
|
||||||
// return ;
|
// return ;
|
||||||
case LE_METHOD_COOLANT:
|
case LE_METHOD_COOLANT:
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "logic_expression.h"
|
#include "logic_expression.h"
|
||||||
|
|
||||||
|
#define FUEL_PUMP_LOGIC "time_since_boot 4 < rpm 0 > OR"
|
||||||
|
|
||||||
float getLEValue(Engine *engine, le_action_e action);
|
float getLEValue(Engine *engine, le_action_e action);
|
||||||
|
|
||||||
#endif /* LE_FUNCTIONS_H_ */
|
#endif /* LE_FUNCTIONS_H_ */
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
/**
|
/**
|
||||||
* @file logic_expression.cpp
|
* @file logic_expression.cpp
|
||||||
|
* @brief Logical expressions handling logic
|
||||||
|
*
|
||||||
|
* Here we parse and evaluate logical expressions in
|
||||||
|
* http://en.wikipedia.org/wiki/Reverse_Polish_notation
|
||||||
|
*
|
||||||
|
* Once the expressions are parsed on startup (that's a heavy operation),
|
||||||
|
* evaluating those is relatively efficient.
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* @date Oct 3, 2014
|
* @date Oct 3, 2014
|
||||||
* @author Andrey Belomutskiy, (c) 2012-2014
|
* @author Andrey Belomutskiy, (c) 2012-2014
|
||||||
|
@ -147,7 +155,7 @@ void LECalculator::doJob(Engine *engine, LEElement *element) {
|
||||||
firmwareError("Undefined not expected here");
|
firmwareError("Undefined not expected here");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
stack.push(getLEValue(NULL, element->action));
|
stack.push(getLEValue(engine, element->action));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,7 @@
|
||||||
#include "PwmTester.h"
|
#include "PwmTester.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "logic_expression.h"
|
#include "logic_expression.h"
|
||||||
|
#include "le_functions.h"
|
||||||
#define FUEL_PUMP_LOGIC "time_since_boot 4 < rpm 0 > OR"
|
|
||||||
|
|
||||||
LECalculator calc;
|
LECalculator calc;
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ int main(void) {
|
||||||
testFLStack();
|
testFLStack();
|
||||||
|
|
||||||
// resizeMap();
|
// resizeMap();
|
||||||
printf("Success 20131004\r\n");
|
printf("Success 20131009\r\n");
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,14 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "test_logic_expression.h"
|
#include "test_logic_expression.h"
|
||||||
#include "logic_expression.h"
|
#include "logic_expression.h"
|
||||||
|
#include "le_functions.h"
|
||||||
#include "cli_registry.h"
|
#include "cli_registry.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
static float mockCoolant;
|
static float mockCoolant;
|
||||||
static float mockFan;
|
static float mockFan;
|
||||||
|
static float mockRpm;
|
||||||
|
static float mockTimeSinceBoot;
|
||||||
|
|
||||||
float getLEValue(Engine *engine, le_action_e action) {
|
float getLEValue(Engine *engine, le_action_e action) {
|
||||||
switch(action) {
|
switch(action) {
|
||||||
|
@ -22,13 +25,16 @@ float getLEValue(Engine *engine, le_action_e action) {
|
||||||
return mockFan;
|
return mockFan;
|
||||||
case LE_METHOD_COOLANT:
|
case LE_METHOD_COOLANT:
|
||||||
return mockCoolant;
|
return mockCoolant;
|
||||||
|
case LE_METHOD_RPM:
|
||||||
|
return mockRpm;
|
||||||
|
case LE_METHOD_TIME_SINCE_BOOT:
|
||||||
|
return mockTimeSinceBoot;
|
||||||
default:
|
default:
|
||||||
firmwareError("No value for %d", action);
|
firmwareError("No mock value for %d", action);
|
||||||
return NAN;
|
return NAN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void testParsing(void) {
|
static void testParsing(void) {
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
|
|
||||||
|
@ -77,6 +83,7 @@ static void testExpression(const char *line, float expected) {
|
||||||
LEElementPool pool;
|
LEElementPool pool;
|
||||||
pool.reset();
|
pool.reset();
|
||||||
LEElement * element = parseExpression(&pool, line);
|
LEElement * element = parseExpression(&pool, line);
|
||||||
|
print("Parsing [%s]", line);
|
||||||
assertTrueM("Not NULL expected", element != NULL);
|
assertTrueM("Not NULL expected", element != NULL);
|
||||||
LECalculator c;
|
LECalculator c;
|
||||||
c.add(element);
|
c.add(element);
|
||||||
|
@ -158,4 +165,7 @@ void testLogicExpressions(void) {
|
||||||
|
|
||||||
testExpression("fan NOT coolant 90 > AND fan coolant 85 > AND OR", 1);
|
testExpression("fan NOT coolant 90 > AND fan coolant 85 > AND OR", 1);
|
||||||
|
|
||||||
|
mockRpm = 900;
|
||||||
|
testExpression(FUEL_PUMP_LOGIC, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue