auto-sync
This commit is contained in:
parent
0da4fac8b3
commit
66f0257d28
|
@ -46,10 +46,10 @@ void FLStack<T, MAXSIZE>::push(T value) {
|
|||
|
||||
template<typename T, int MAXSIZE>
|
||||
T FLStack<T, MAXSIZE>::pop() {
|
||||
if(index==0) {
|
||||
if (index == 0) {
|
||||
firmwareError("FLStack is empty");
|
||||
}
|
||||
return values[--index];
|
||||
return values[--index];
|
||||
}
|
||||
|
||||
template<typename T, int MAXSIZE>
|
||||
|
|
|
@ -78,6 +78,14 @@ static bool float2bool(float v) {
|
|||
return v != 0;
|
||||
}
|
||||
|
||||
float LECalculator::pop(le_action_e action) {
|
||||
if (stack.size() == 0) {
|
||||
firmwareError("empty stack for %d", action);
|
||||
return NAN;
|
||||
}
|
||||
return stack.pop();
|
||||
}
|
||||
|
||||
void LECalculator::doJob(Engine *engine, LEElement *element) {
|
||||
switch (element->action) {
|
||||
|
||||
|
@ -85,52 +93,52 @@ void LECalculator::doJob(Engine *engine, LEElement *element) {
|
|||
stack.push(element->fValue);
|
||||
break;
|
||||
case LE_OPERATOR_AND: {
|
||||
float v1 = stack.pop();
|
||||
float v2 = stack.pop();
|
||||
float v1 = pop(LE_OPERATOR_AND);
|
||||
float v2 = pop(LE_OPERATOR_AND);
|
||||
|
||||
stack.push(float2bool(v1) && float2bool(v2));
|
||||
}
|
||||
break;
|
||||
case LE_OPERATOR_OR: {
|
||||
float v1 = stack.pop();
|
||||
float v2 = stack.pop();
|
||||
float v1 = pop(LE_OPERATOR_OR);
|
||||
float v2 = pop(LE_OPERATOR_OR);
|
||||
|
||||
stack.push(float2bool(v1) || float2bool(v2));
|
||||
}
|
||||
break;
|
||||
case LE_OPERATOR_LESS: {
|
||||
// elements on stack are in reverse order
|
||||
float v2 = stack.pop();
|
||||
float v1 = stack.pop();
|
||||
float v2 = pop(LE_OPERATOR_LESS);
|
||||
float v1 = pop(LE_OPERATOR_LESS);
|
||||
|
||||
stack.push(v1 < v2);
|
||||
}
|
||||
break;
|
||||
case LE_OPERATOR_NOT: {
|
||||
float v = stack.pop();
|
||||
float v = pop(LE_OPERATOR_NOT);
|
||||
stack.push(!float2bool(v));
|
||||
}
|
||||
break;
|
||||
case LE_OPERATOR_MORE: {
|
||||
// elements on stack are in reverse order
|
||||
float v2 = stack.pop();
|
||||
float v1 = stack.pop();
|
||||
float v2 = pop(LE_OPERATOR_MORE);
|
||||
float v1 = pop(LE_OPERATOR_MORE);
|
||||
|
||||
stack.push(v1 > v2);
|
||||
}
|
||||
break;
|
||||
case LE_OPERATOR_LESS_OR_EQUAL: {
|
||||
// elements on stack are in reverse order
|
||||
float v2 = stack.pop();
|
||||
float v1 = stack.pop();
|
||||
float v2 = pop(LE_OPERATOR_LESS_OR_EQUAL);
|
||||
float v1 = pop(LE_OPERATOR_LESS_OR_EQUAL);
|
||||
|
||||
stack.push(v1 <= v2);
|
||||
}
|
||||
break;
|
||||
case LE_OPERATOR_MORE_OR_EQUAL: {
|
||||
// elements on stack are in reverse order
|
||||
float v2 = stack.pop();
|
||||
float v1 = stack.pop();
|
||||
float v2 = pop(LE_OPERATOR_MORE_OR_EQUAL);
|
||||
float v1 = pop(LE_OPERATOR_MORE_OR_EQUAL);
|
||||
|
||||
stack.push(v1 >= v2);
|
||||
}
|
||||
|
@ -152,6 +160,7 @@ float LECalculator::getValue(Engine *engine) {
|
|||
doJob(engine, element);
|
||||
element = element->next;
|
||||
}
|
||||
efiAssert(stack.size() == 1, "One value expected on stack", NAN);
|
||||
|
||||
return stack.pop();
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ public:
|
|||
|
||||
private:
|
||||
void doJob(Engine *engine, LEElement *element);
|
||||
float pop(le_action_e action);
|
||||
LEElement *first;
|
||||
FLStack<float, MAX_STACK_DEPTH> stack;
|
||||
};
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
#include "engine.h"
|
||||
#include "logic_expression.h"
|
||||
|
||||
#define FUEL_PUMP_LOGIC "time_since_boot 4 less rpm 0 > OR"
|
||||
#define FUEL_PUMP_LOGIC "time_since_boot 4 < rpm 0 > OR"
|
||||
|
||||
LECalculator calc;
|
||||
|
||||
|
@ -126,8 +126,10 @@ static void updateErrorCodes(void) {
|
|||
/**
|
||||
* technically we can set error codes right inside the getMethods, but I a bit on a fence about it
|
||||
*/
|
||||
setError(isValidIntakeAirTemperature(getIntakeAirTemperature(engineConfiguration2)), OBD_Intake_Air_Temperature_Circuit_Malfunction);
|
||||
setError(isValidCoolantTemperature(getCoolantTemperature(engineConfiguration2)), OBD_Engine_Coolant_Temperature_Circuit_Malfunction);
|
||||
setError(isValidIntakeAirTemperature(getIntakeAirTemperature(engineConfiguration2)),
|
||||
OBD_Intake_Air_Temperature_Circuit_Malfunction);
|
||||
setError(isValidCoolantTemperature(getCoolantTemperature(engineConfiguration2)),
|
||||
OBD_Engine_Coolant_Temperature_Circuit_Malfunction);
|
||||
}
|
||||
|
||||
static void fanRelayControl(void) {
|
||||
|
@ -173,7 +175,7 @@ int getTimeNowSeconds(void) {
|
|||
}
|
||||
|
||||
static void onEvenyGeneralMilliseconds(void *arg) {
|
||||
(void)arg;
|
||||
(void) arg;
|
||||
/**
|
||||
* We need to push current value into the 64 bit counter often enough so that we do not miss an overflow
|
||||
*/
|
||||
|
@ -185,10 +187,20 @@ static void onEvenyGeneralMilliseconds(void *arg) {
|
|||
engine.watchdog();
|
||||
engine.updateSlowSensors();
|
||||
|
||||
if(boardConfiguration->fuelPumpPin != GPIO_NONE && engineConfiguration->isFuelPumpEnabled) {
|
||||
calc.reset(fuelPumpLogic);
|
||||
//int value = calc.getValue())
|
||||
#if EFI_FUEL_PUMP
|
||||
if (boardConfiguration->fuelPumpPin != GPIO_NONE && engineConfiguration->isFuelPumpEnabled) {
|
||||
if (fuelPumpLogic == NULL) {
|
||||
warning(OBD_PCM_Processor_Fault, "invalid expression for %s", getIo_pin_e(FUEL_PUMP_RELAY));
|
||||
} else {
|
||||
calc.reset(fuelPumpLogic);
|
||||
int value = calc.getValue(&engine);
|
||||
if (value != getOutputPinValue(FUEL_PUMP_RELAY)) {
|
||||
scheduleMsg(&logger, "setting %s %s", getIo_pin_e(FUEL_PUMP_RELAY), boolToString(value));
|
||||
setOutputPinValue(FUEL_PUMP_RELAY, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
updateErrorCodes();
|
||||
|
||||
|
@ -346,12 +358,8 @@ void initEngineContoller(void) {
|
|||
#endif
|
||||
|
||||
#if EFI_FUEL_PUMP
|
||||
if (engineConfiguration->isFuelPumpEnabled) {
|
||||
// initFuelPump();
|
||||
}
|
||||
#endif
|
||||
|
||||
fuelPumpLogic = parseExpression(&lePool, FUEL_PUMP_LOGIC);
|
||||
#endif
|
||||
|
||||
addConsoleAction("analoginfo", printAnalogInfo);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue