helping us trace CUSTOM_FSIO_STACK_SIZE
This commit is contained in:
parent
462e24354d
commit
b49c5200b7
|
@ -259,7 +259,7 @@ FsioResult LECalculator::processElement(const LEElement *element DECLARE_ENGINE_
|
|||
}
|
||||
}
|
||||
|
||||
float LECalculator::evaluate(float selfValue, const LEElement* element DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
float LECalculator::evaluate(const char * msg, float selfValue, const LEElement* element DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
if (!element) {
|
||||
warning(CUSTOM_NO_FSIO, "no FSIO code");
|
||||
return NAN;
|
||||
|
|
|
@ -132,7 +132,7 @@ typedef FLStack<float, MAX_STACK_DEPTH> calc_stack_t;
|
|||
class LECalculator {
|
||||
public:
|
||||
LECalculator();
|
||||
float evaluate(float selfValue, const LEElement* element DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
float evaluate(const char * msg, float selfValue, const LEElement* element DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
void reset();
|
||||
|
||||
// Log history of calculation actions for debugging
|
||||
|
|
|
@ -345,7 +345,7 @@ float getFsioOutputValue(int index DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
warning(CUSTOM_NO_FSIO, "no FSIO for #%d %s", index + 1, hwPortname(CONFIG(fsioOutputPins)[index]));
|
||||
return NAN;
|
||||
} else {
|
||||
return calc.evaluate(engine->fsioState.fsioLastValue[index], state.fsioLogics[index] PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
return calc.evaluate("FSIO", engine->fsioState.fsioLastValue[index], state.fsioLogics[index] PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -412,7 +412,7 @@ static void setPinState(const char * msg, OutputPin *pin, LEElement *element DEC
|
|||
if (!element) {
|
||||
warning(CUSTOM_FSIO_INVALID_EXPRESSION, "invalid expression for %s", msg);
|
||||
} else {
|
||||
int value = (int)calc.evaluate(pin->getLogicValue(), element PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
int value = (int)calc.evaluate(msg, pin->getLogicValue(), element PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
if (pin->isInitialized() && value != pin->getLogicValue()) {
|
||||
|
||||
for (int i = 0;i < calc.currentCalculationLogPosition;i++) {
|
||||
|
@ -454,7 +454,7 @@ static bool updateValueOrWarning(int humanIndex, const char *msg, float *value D
|
|||
return false;
|
||||
} else {
|
||||
float beforeValue = *value;
|
||||
*value = calc.evaluate(beforeValue, element PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
*value = calc.evaluate(msg, beforeValue, element PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
// floating '==' comparison without EPS seems fine here
|
||||
return (beforeValue != *value);
|
||||
}
|
||||
|
@ -674,7 +674,7 @@ static void rpnEval(char *line) {
|
|||
if (e == NULL) {
|
||||
scheduleMsg(logger, "parsing failed");
|
||||
} else {
|
||||
float result = evalCalc.evaluate(0, e PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
float result = evalCalc.evaluate("eval", 0, e PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
scheduleMsg(logger, "Evaluate result: %.2f", result);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -117,7 +117,7 @@ static void testExpression2(float selfValue, const char *line, float expected, E
|
|||
|
||||
EXPAND_Engine;
|
||||
|
||||
ASSERT_NEAR(expected, c.evaluate(selfValue, element PASS_ENGINE_PARAMETER_SUFFIX), EPS4D) << line;
|
||||
ASSERT_NEAR(expected, c.evaluate("test", selfValue, element PASS_ENGINE_PARAMETER_SUFFIX), EPS4D) << line;
|
||||
}
|
||||
|
||||
static void testExpression2(float selfValue, const char *line, float expected, const std::unordered_map<SensorType, float>& sensorVals = {}) {
|
||||
|
@ -144,20 +144,20 @@ TEST(fsio, testHysteresisSelf) {
|
|||
double selfValue = 0;
|
||||
|
||||
engine->fsioState.mockRpm = 0;
|
||||
selfValue = c.evaluate(selfValue, element PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
selfValue = c.evaluate("test", selfValue, element PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
ASSERT_EQ(0, selfValue);
|
||||
|
||||
engine->fsioState.mockRpm = 430;
|
||||
selfValue = c.evaluate(selfValue, element PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
selfValue = c.evaluate("test", selfValue, element PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
// OFF since not ON yet
|
||||
ASSERT_EQ(0, selfValue);
|
||||
|
||||
engine->fsioState.mockRpm = 460;
|
||||
selfValue = c.evaluate(selfValue, element PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
selfValue = c.evaluate("test", selfValue, element PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
ASSERT_EQ(1, selfValue);
|
||||
|
||||
engine->fsioState.mockRpm = 430;
|
||||
selfValue = c.evaluate(selfValue, element PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
selfValue = c.evaluate("test", selfValue, element PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
// OFF since was ON yet
|
||||
ASSERT_EQ(1, selfValue);
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ TEST(fsio, testLogicExpressions) {
|
|||
LEElement * element = pool.parseExpression("fan NOT coolant 90 > AND fan coolant 85 > AND OR");
|
||||
ASSERT_TRUE(element != NULL) << "Not NULL expected";
|
||||
LECalculator c;
|
||||
ASSERT_EQ( 1, c.evaluate(0, element PASS_ENGINE_PARAMETER_SUFFIX)) << "that expression";
|
||||
ASSERT_EQ( 1, c.evaluate("test", 0, element PASS_ENGINE_PARAMETER_SUFFIX)) << "that expression";
|
||||
|
||||
ASSERT_EQ(12, c.currentCalculationLogPosition);
|
||||
ASSERT_EQ(102, c.calcLogAction[0]);
|
||||
|
|
Loading…
Reference in New Issue