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;
}
void LECalculator::doJob(LEElement *element) {
void LECalculator::doJob(Engine *engine, LEElement *element) {
switch (element->action) {
case LE_NUMERIC_VALUE:
@ -143,13 +143,13 @@ void LECalculator::doJob(LEElement *element) {
}
}
float LECalculator::getValue() {
float LECalculator::getValue(Engine *engine) {
LEElement *element = first;
stack.reset();
while (element != NULL) {
doJob(element);
doJob(engine, element);
element = element->next;
}

View File

@ -70,13 +70,13 @@ private:
class LECalculator {
public:
LECalculator();
float getValue();
float getValue(Engine *engine);
void add(LEElement *element);
void reset();
void reset(LEElement *element);
private:
void doJob(LEElement *element);
void doJob(Engine *engine, LEElement *element);
LEElement *first;
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)
static VirtualTimer everyMsTimer;
static VirtualTimer fuelPumpTimer;
//static VirtualTimer fuelPumpTimer;
static Logging logger;
@ -185,6 +185,11 @@ static void onEvenyGeneralMilliseconds(void *arg) {
engine.watchdog();
engine.updateSlowSensors();
if(boardConfiguration->fuelPumpPin != GPIO_NONE && engineConfiguration->isFuelPumpEnabled) {
calc.reset(fuelPumpLogic);
//int value = calc.getValue())
}
updateErrorCodes();
fanRelayControl();
@ -202,33 +207,33 @@ static void initPeriodicEvents(void) {
&onEvenyGeneralMilliseconds, 0);
}
static void fuelPumpOff(void *arg) {
(void)arg;
if (getOutputPinValue(FUEL_PUMP_RELAY))
scheduleMsg(&logger, "fuelPump OFF at %s%d", hwPortname(boardConfiguration->fuelPumpPin));
turnOutputPinOff(FUEL_PUMP_RELAY);
}
//static void fuelPumpOff(void *arg) {
// (void)arg;
// if (getOutputPinValue(FUEL_PUMP_RELAY))
// scheduleMsg(&logger, "fuelPump OFF at %s%d", hwPortname(boardConfiguration->fuelPumpPin));
// turnOutputPinOff(FUEL_PUMP_RELAY);
//}
static void fuelPumpOn(trigger_event_e signal, uint32_t index, void *arg) {
(void)arg;
if (index != 0)
return; // let's not abuse the timer - one time per revolution would be enough
// todo: the check about GPIO_NONE should be somewhere else!
if (!getOutputPinValue(FUEL_PUMP_RELAY) && boardConfiguration->fuelPumpPin != GPIO_NONE)
scheduleMsg(&logger, "fuelPump ON at %s", hwPortname(boardConfiguration->fuelPumpPin));
turnOutputPinOn(FUEL_PUMP_RELAY);
/**
* 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
* will turn it off. Only if the shafts stop the turn off would actually happen.
*/
chVTSetAny(&fuelPumpTimer, FUEL_PUMP_DELAY, &fuelPumpOff, 0);
}
//static void fuelPumpOn(trigger_event_e signal, uint32_t index, void *arg) {
// (void)arg;
// if (index != 0)
// return; // let's not abuse the timer - one time per revolution would be enough
// // todo: the check about GPIO_NONE should be somewhere else!
// if (!getOutputPinValue(FUEL_PUMP_RELAY) && boardConfiguration->fuelPumpPin != GPIO_NONE)
// scheduleMsg(&logger, "fuelPump ON at %s", hwPortname(boardConfiguration->fuelPumpPin));
// turnOutputPinOn(FUEL_PUMP_RELAY);
// /**
// * 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
// * will turn it off. Only if the shafts stop the turn off would actually happen.
// */
// chVTSetAny(&fuelPumpTimer, FUEL_PUMP_DELAY, &fuelPumpOff, 0);
//}
static void initFuelPump(void) {
addTriggerEventListener(&fuelPumpOn, "fuel pump", NULL);
fuelPumpOn(SHAFT_PRIMARY_UP, 0, NULL);
}
//static void initFuelPump(void) {
// addTriggerEventListener(&fuelPumpOn, "fuel pump", NULL);
// fuelPumpOn(SHAFT_PRIMARY_UP, 0, NULL);
//}
char * getPinNameByAdcChannel(adc_channel_e hwChannel, char *buffer) {
strcpy((char*) buffer, portname(getAdcChannelPort(hwChannel)));
@ -342,7 +347,7 @@ void initEngineContoller(void) {
#if EFI_FUEL_PUMP
if (engineConfiguration->isFuelPumpEnabled) {
initFuelPump();
// initFuelPump();
}
#endif

View File

@ -24,6 +24,7 @@ float getLEValue(Engine *engine, le_action_e action) {
return mockCoolant;
default:
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);
LECalculator c;
c.add(element);
assertEqualsM(line, expected, c.getValue());
assertEqualsM(line, expected, c.getValue(NULL));
}
void testLogicExpressions(void) {
@ -93,7 +94,7 @@ void testLogicExpressions(void) {
value1.init(LE_NUMERIC_VALUE, 123.0);
c.add(&value1);
assertEqualsM("123", 123.0, c.getValue());
assertEqualsM("123", 123.0, c.getValue(NULL));
LEElement value2;
value2.init(LE_NUMERIC_VALUE, 321.0);
@ -102,7 +103,7 @@ void testLogicExpressions(void) {
LEElement value3;
value3.init(LE_OPERATOR_AND);
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)