auto-sync

This commit is contained in:
rusEfi 2014-10-03 14:05:03 -05:00
parent 53fd044863
commit ff14facc8b
8 changed files with 166 additions and 4 deletions

View File

@ -3,5 +3,6 @@ CONTROLLERS_CORE_SRC = $(PROJECT_DIR)/controllers/core/avg_values.c
CONTROLLERS_CORE_SRC_CPP = $(PROJECT_DIR)/controllers/core/EfiWave.cpp \
$(PROJECT_DIR)/controllers/core/table_helper.cpp \
$(PROJECT_DIR)/controllers/core/logic_expression.cpp \
$(PROJECT_DIR)/controllers/core/interpolation.cpp \

View File

@ -14,6 +14,7 @@ class FLStack {
public:
FLStack();
void push(T value);
void reset();
T pop();
int size();
bool isEmpty();
@ -24,7 +25,7 @@ private:
template<typename T, int MAXSIZE>
FLStack<T, MAXSIZE>::FLStack() {
index = 0;
reset();
}
template<typename T, int MAXSIZE>
@ -32,11 +33,22 @@ bool FLStack<T, MAXSIZE>::isEmpty() {
return index == 0;
}
template<typename T, int MAXSIZE>
void FLStack<T, MAXSIZE>::reset() {
index = 0;
}
template<typename T, int MAXSIZE>
void FLStack<T, MAXSIZE>::push(T value) {
values[index++] = value;
}
template<typename T, int MAXSIZE>
T FLStack<T, MAXSIZE>::pop() {
return values[--index];
}
template<typename T, int MAXSIZE>
int FLStack<T, MAXSIZE>::size() {
return index;

View File

@ -0,0 +1,61 @@
/**
* @file logic_expression.cpp
*
* @date Oct 3, 2014
* @author Andrey Belomutskiy, (c) 2012-2014
*/
#include "main.h"
#include "logic_expression.h"
LEElement::LEElement() {
action = LE_UNDEFINED;
next = NULL;
}
//void LEElement::init(le_action_e action, int iValue) {
// this->action = action;
// this->iValue = iValue;
//}
void LEElement::init(le_action_e action) {
this->action = action;
}
void LEElement::init(le_action_e action, float fValue) {
this->action = action;
this->fValue = fValue;
}
LECalculator::LECalculator() {
first = NULL;
}
float LECalculator::getValue() {
LEElement *element = first;
stack.reset();
while(element != NULL) {
stack.push(element->fValue);
element = element->next;
}
return stack.pop();
}
void LECalculator::add(LEElement *element) {
if (first == NULL) {
first = element;
} else {
LEElement *last = first;
while (last->next != NULL) {
last = last->next;
}
last->next = element;
}
}

View File

@ -0,0 +1,53 @@
/**
* @file logic_expression.h
*
* @date Oct 3, 2014
* @author Andrey Belomutskiy, (c) 2012-2014
*/
#ifndef LOGIC_EXPRESSION_H_
#define LOGIC_EXPRESSION_H_
#include "rusefi_enums.h"
#include "fl_stack.h"
typedef enum {
LE_UNDEFINED,
LE_NUMERIC_VALUE,
LE_OPERATOR_LESS,
LE_OPERATOR_MORE,
LE_OPERATOR_AND,
LE_OPERATOR_OR,
Force_4b_le_action = ENUM_SIZE_HACK,
} le_action_e;
class LEElement {
public:
LEElement();
// void init(le_action_e action, int iValue);
void init(le_action_e action);
void init(le_action_e action, float fValue);
le_action_e action;
float fValue;
int iValue;
LEElement *next;
};
#define MAX_STACK_DEPTH 32
class LECalculator {
public:
LECalculator();
float getValue();
void add(LEElement *element);
LEElement *first;
private:
FLStack<float, MAX_STACK_DEPTH> stack;
};
#endif /* LOGIC_EXPRESSION_H_ */

View File

@ -241,5 +241,5 @@ void firmwareError(const char *fmt, ...) {
}
int getRusEfiVersion(void) {
return 20141002;
return 20141003;
}

View File

@ -21,6 +21,8 @@
#include "test_fuel_map.h"
#include "fuel_math.h"
#include "test_logic_expression.h"
#include "engine_configuration.h"
extern "C"
{
@ -29,7 +31,6 @@ extern "C"
#include "test_event_registry.h"
#include "test_signal_executor.h"
#include "test_util.h"
#include "engine_configuration.h"
}
#include "engine_math.h"
@ -95,6 +96,7 @@ static engine_configuration2_s ec2;
engine_configuration2_s *engineConfiguration2 = &ec2;
int main(void) {
testLogicExpressions();
testOverflow64Counter();
testInterpolate3d();
testFindIndex();
@ -130,7 +132,7 @@ int main(void) {
testFLStack();
// resizeMap();
printf("Success 20131002\r\n");
printf("Success 20131003\r\n");
return EXIT_SUCCESS;
}

View File

@ -9,8 +9,28 @@
#include "main.h"
#include "test_logic_expression.h"
#include "logic_expression.h"
void testLogicExpressions(void) {
printf("*************************************************** testLogicExpressions\r\n");
LECalculator c;
LEElement value1;
value1.init(LE_NUMERIC_VALUE, 123.0);
c.add(&value1);
assertEqualsM("123", 123.0, c.getValue());
LEElement value2;
value2.init(LE_NUMERIC_VALUE, 321.0);
c.add(&value2);
LEElement value3;
value3.init(LE_OPERATOR_AND);
c.add(&value3);
/**
* fuel_pump = (time_since_boot < 4 seconds) OR (rpm > 0)
* fuel_pump = time_since_boot 4 less rpm 0 more OR

View File

@ -311,6 +311,19 @@ void testFLStack(void) {
FLStack<int, 4> stack;
assertEquals(0, stack.size());
stack.push(123);
stack.push(234);
assertEquals(2, stack.size());
int v = stack.pop();
assertEquals(234, v);
assertEquals(1, stack.size());
v = stack.pop();
assertEquals(123, v);
assertEquals(0, stack.size());
}
void testMisc(void) {