auto-sync

This commit is contained in:
rusEfi 2015-02-24 18:11:57 -06:00
parent 8170245e9f
commit daa0284246
4 changed files with 27 additions and 12 deletions

View File

@ -112,7 +112,7 @@ float LECalculator::pop(le_action_e action) {
return stack.pop();
}
void LECalculator::doJob(Engine *engine, LEElement *element) {
bool_t LECalculator::doJob(Engine *engine, LEElement *element) {
switch (element->action) {
case LE_NUMERIC_VALUE:
@ -232,11 +232,12 @@ void LECalculator::doJob(Engine *engine, LEElement *element) {
}
break;
case LE_UNDEFINED:
firmwareError("FSIO undefined action");
break;
warning(OBD_PCM_Processor_Fault, "FSIO undefined action");
return true;
default:
stack.push(getLEValue(engine, &stack, element->action));
}
return false;
}
float LECalculator::getValue2(LEElement *element, Engine *engine) {
@ -254,7 +255,11 @@ float LECalculator::getValue(Engine *engine) {
stack.reset();
while (element != NULL) {
doJob(engine, element);
bool_t isError = doJob(engine, element);
if (isError) {
// error already reported
return NAN;
}
element = element->next;
}
if (stack.size() != 1) {

View File

@ -90,7 +90,7 @@ public:
void reset(LEElement *element);
private:
void doJob(Engine *engine, LEElement *element);
bool_t doJob(Engine *engine, LEElement *element);
float pop(le_action_e action);
LEElement *first;
calc_stack_t stack;

View File

@ -101,7 +101,10 @@ float FastInterpolation::getValue(float x) {
float interpolate(float x1, float y1, float x2, float y2, float x) {
// todo: double comparison using EPS
if (x1 == x2) {
firmwareError("interpolate: Same x1 and x2 in interpolate: %f/%f", x1, x2);
/**
* we could end up here for example while resetting bins while changing engine type
*/
warning(OBD_PCM_Processor_Fault, "interpolate: Same x1 and x2 in interpolate: %f/%f", x1, x2);
return NAN;
}

View File

@ -200,6 +200,17 @@ static void cylinderCleanupControl(Engine *engine) {
static LocalVersionHolder versionForConfigurationListeners;
static void onEvenyGeneralMilliseconds(Engine *engine);
static void scheduleNextInvocation(void) {
// schedule next invocation
int period = boardConfiguration->generalPeriodicThreadPeriod;
if (period == 0)
period = 50; // this might happen while resetting config
chVTSetAny(&everyMsTimer, period * TICKS_IN_MS, (vtfunc_t) &onEvenyGeneralMilliseconds, engine);
}
static void onEvenyGeneralMilliseconds(Engine *engine) {
efiAssertVoid(getRemainingStack(chThdSelf()) > 64, "lowStckOnEv");
#if EFI_PROD_CODE
@ -238,15 +249,11 @@ static void onEvenyGeneralMilliseconds(Engine *engine) {
cylinderCleanupControl(engine);
// schedule next invocation
chVTSetAny(&everyMsTimer, boardConfiguration->generalPeriodicThreadPeriod * TICKS_IN_MS,
(vtfunc_t) &onEvenyGeneralMilliseconds, engine);
scheduleNextInvocation();
}
void initPeriodicEvents(Engine *engine) {
// schedule first invocation
chVTSetAny(&everyMsTimer, boardConfiguration->generalPeriodicThreadPeriod * TICKS_IN_MS,
(vtfunc_t) &onEvenyGeneralMilliseconds, engine);
scheduleNextInvocation();
}
char * getPinNameByAdcChannel(adc_channel_e hwChannel, char *buffer) {