auto-sync

This commit is contained in:
rusEfi 2014-10-06 07:03:03 -05:00
parent 4f77977e11
commit 3c84a0f300
4 changed files with 41 additions and 35 deletions

View File

@ -78,7 +78,7 @@ static bool float2bool(float v) {
return v != 0; return v != 0;
} }
void LECalculator::doJob(LEElement *element) { void LECalculator::doJob(Engine *engine, LEElement *element) {
switch (element->action) { switch (element->action) {
case LE_NUMERIC_VALUE: case LE_NUMERIC_VALUE:
@ -143,13 +143,13 @@ void LECalculator::doJob(LEElement *element) {
} }
} }
float LECalculator::getValue() { float LECalculator::getValue(Engine *engine) {
LEElement *element = first; LEElement *element = first;
stack.reset(); stack.reset();
while (element != NULL) { while (element != NULL) {
doJob(element); doJob(engine, element);
element = element->next; element = element->next;
} }

View File

@ -70,13 +70,13 @@ private:
class LECalculator { class LECalculator {
public: public:
LECalculator(); LECalculator();
float getValue(); float getValue(Engine *engine);
void add(LEElement *element); void add(LEElement *element);
void reset(); void reset();
void reset(LEElement *element); void reset(LEElement *element);
private: private:
void doJob(LEElement *element); void doJob(Engine *engine, LEElement *element);
LEElement *first; LEElement *first;
FLStack<float, MAX_STACK_DEPTH> stack; FLStack<float, MAX_STACK_DEPTH> stack;
}; };

View File

@ -82,7 +82,7 @@ board_configuration_s *boardConfiguration = &persistentState.persistentConfigura
#define FUEL_PUMP_DELAY (4 * CH_FREQUENCY) #define FUEL_PUMP_DELAY (4 * CH_FREQUENCY)
static VirtualTimer everyMsTimer; static VirtualTimer everyMsTimer;
static VirtualTimer fuelPumpTimer; //static VirtualTimer fuelPumpTimer;
static Logging logger; static Logging logger;
@ -185,6 +185,11 @@ static void onEvenyGeneralMilliseconds(void *arg) {
engine.watchdog(); engine.watchdog();
engine.updateSlowSensors(); engine.updateSlowSensors();
if(boardConfiguration->fuelPumpPin != GPIO_NONE && engineConfiguration->isFuelPumpEnabled) {
calc.reset(fuelPumpLogic);
//int value = calc.getValue())
}
updateErrorCodes(); updateErrorCodes();
fanRelayControl(); fanRelayControl();
@ -202,33 +207,33 @@ static void initPeriodicEvents(void) {
&onEvenyGeneralMilliseconds, 0); &onEvenyGeneralMilliseconds, 0);
} }
static void fuelPumpOff(void *arg) { //static void fuelPumpOff(void *arg) {
(void)arg; // (void)arg;
if (getOutputPinValue(FUEL_PUMP_RELAY)) // if (getOutputPinValue(FUEL_PUMP_RELAY))
scheduleMsg(&logger, "fuelPump OFF at %s%d", hwPortname(boardConfiguration->fuelPumpPin)); // scheduleMsg(&logger, "fuelPump OFF at %s%d", hwPortname(boardConfiguration->fuelPumpPin));
turnOutputPinOff(FUEL_PUMP_RELAY); // turnOutputPinOff(FUEL_PUMP_RELAY);
} //}
static void fuelPumpOn(trigger_event_e signal, uint32_t index, void *arg) { //static void fuelPumpOn(trigger_event_e signal, uint32_t index, void *arg) {
(void)arg; // (void)arg;
if (index != 0) // if (index != 0)
return; // let's not abuse the timer - one time per revolution would be enough // return; // let's not abuse the timer - one time per revolution would be enough
// todo: the check about GPIO_NONE should be somewhere else! // // todo: the check about GPIO_NONE should be somewhere else!
if (!getOutputPinValue(FUEL_PUMP_RELAY) && boardConfiguration->fuelPumpPin != GPIO_NONE) // if (!getOutputPinValue(FUEL_PUMP_RELAY) && boardConfiguration->fuelPumpPin != GPIO_NONE)
scheduleMsg(&logger, "fuelPump ON at %s", hwPortname(boardConfiguration->fuelPumpPin)); // scheduleMsg(&logger, "fuelPump ON at %s", hwPortname(boardConfiguration->fuelPumpPin));
turnOutputPinOn(FUEL_PUMP_RELAY); // turnOutputPinOn(FUEL_PUMP_RELAY);
/** // /**
* the idea of this implementation is that we turn the pump when the ECU turns on or // * the idea of this implementation is that we turn the pump when the ECU turns on or
* if the shafts are spinning and then we are constantly postponing the time when we // * if the shafts are spinning and then we are constantly postponing the time when we
* will turn it off. Only if the shafts stop the turn off would actually happen. // * will turn it off. Only if the shafts stop the turn off would actually happen.
*/ // */
chVTSetAny(&fuelPumpTimer, FUEL_PUMP_DELAY, &fuelPumpOff, 0); // chVTSetAny(&fuelPumpTimer, FUEL_PUMP_DELAY, &fuelPumpOff, 0);
} //}
static void initFuelPump(void) { //static void initFuelPump(void) {
addTriggerEventListener(&fuelPumpOn, "fuel pump", NULL); // addTriggerEventListener(&fuelPumpOn, "fuel pump", NULL);
fuelPumpOn(SHAFT_PRIMARY_UP, 0, NULL); // fuelPumpOn(SHAFT_PRIMARY_UP, 0, NULL);
} //}
char * getPinNameByAdcChannel(adc_channel_e hwChannel, char *buffer) { char * getPinNameByAdcChannel(adc_channel_e hwChannel, char *buffer) {
strcpy((char*) buffer, portname(getAdcChannelPort(hwChannel))); strcpy((char*) buffer, portname(getAdcChannelPort(hwChannel)));
@ -342,7 +347,7 @@ void initEngineContoller(void) {
#if EFI_FUEL_PUMP #if EFI_FUEL_PUMP
if (engineConfiguration->isFuelPumpEnabled) { if (engineConfiguration->isFuelPumpEnabled) {
initFuelPump(); // initFuelPump();
} }
#endif #endif

View File

@ -24,6 +24,7 @@ float getLEValue(Engine *engine, le_action_e action) {
return mockCoolant; return mockCoolant;
default: default:
firmwareError("No value for %d", action); firmwareError("No value for %d", action);
return NAN;
} }
} }
@ -79,7 +80,7 @@ static void testExpression(const char *line, float expected) {
assertTrueM("Not NULL expected", element != NULL); assertTrueM("Not NULL expected", element != NULL);
LECalculator c; LECalculator c;
c.add(element); c.add(element);
assertEqualsM(line, expected, c.getValue()); assertEqualsM(line, expected, c.getValue(NULL));
} }
void testLogicExpressions(void) { void testLogicExpressions(void) {
@ -93,7 +94,7 @@ void testLogicExpressions(void) {
value1.init(LE_NUMERIC_VALUE, 123.0); value1.init(LE_NUMERIC_VALUE, 123.0);
c.add(&value1); c.add(&value1);
assertEqualsM("123", 123.0, c.getValue()); assertEqualsM("123", 123.0, c.getValue(NULL));
LEElement value2; LEElement value2;
value2.init(LE_NUMERIC_VALUE, 321.0); value2.init(LE_NUMERIC_VALUE, 321.0);
@ -102,7 +103,7 @@ void testLogicExpressions(void) {
LEElement value3; LEElement value3;
value3.init(LE_OPERATOR_AND); value3.init(LE_OPERATOR_AND);
c.add(&value3); c.add(&value3);
assertEqualsM("123 and 321", 1.0, c.getValue()); assertEqualsM("123 and 321", 1.0, c.getValue(NULL));
/** /**
* fuel_pump = (time_since_boot < 4 seconds) OR (rpm > 0) * fuel_pump = (time_since_boot < 4 seconds) OR (rpm > 0)