auto-sync

This commit is contained in:
rusEfi 2016-03-09 23:02:39 -05:00
parent 0548e1de48
commit 7792a0fbe2
3 changed files with 31 additions and 12 deletions

View File

@ -97,6 +97,10 @@ void AccelEnrichmemnt::reset() {
previousValue = NAN; previousValue = NAN;
} }
void AccelEnrichmemnt::setLength(int length) {
cb.setSize(length);
}
void AccelEnrichmemnt::onNewValue(float currentValue DECLARE_ENGINE_PARAMETER_S) { void AccelEnrichmemnt::onNewValue(float currentValue DECLARE_ENGINE_PARAMETER_S) {
if (!cisnan(previousValue)) { if (!cisnan(previousValue)) {
/** /**
@ -178,21 +182,21 @@ static void setDecelMult(float value) {
accelInfo(); accelInfo();
} }
static void setTpsAccelLen(int len) { static void setTpsAccelLen(int length) {
if (len < 1) { if (length < 1) {
scheduleMsg(logger, "Length should be positive"); scheduleMsg(logger, "Length should be positive");
return; return;
} }
engine->tpsAccelEnrichment.cb.setSize(len); engine->tpsAccelEnrichment.setLength(length);
accelInfo(); accelInfo();
} }
void setEngineLoadAccelLen(int len) { void setEngineLoadAccelLen(int length) {
if (len < 1) { if (length < 1) {
scheduleMsg(logger, "Length should be positive"); scheduleMsg(logger, "Length should be positive");
return; return;
} }
engine->engineLoadAccelEnrichment.cb.setSize(len); engine->engineLoadAccelEnrichment.setLength(length);
accelInfo(); accelInfo();
} }

View File

@ -32,6 +32,7 @@ public:
void onEngineCycle(DECLARE_ENGINE_PARAMETER_F); void onEngineCycle(DECLARE_ENGINE_PARAMETER_F);
void onEngineCycleTps(DECLARE_ENGINE_PARAMETER_F); void onEngineCycleTps(DECLARE_ENGINE_PARAMETER_F);
void reset(); void reset();
void setLength(int length);
cyclic_buffer<float> cb; cyclic_buffer<float> cb;
void onNewValue(float currentValue DECLARE_ENGINE_PARAMETER_S); void onNewValue(float currentValue DECLARE_ENGINE_PARAMETER_S);

View File

@ -10,15 +10,29 @@
#include "accel_enrichment.h" #include "accel_enrichment.h"
#include "test_accel_enrichment.h" #include "test_accel_enrichment.h"
#include "engine_configuration.h" #include "engine_configuration.h"
#include "engine_test_helper.h"
void testAccelEnrichment(void) { void testAccelEnrichment(void) {
engine_configuration_s ec;
engine_configuration_s *engineConfiguration = &ec;
printf("*************************************************** testAccelEnrichment\r\n"); printf("*************************************************** testAccelEnrichment\r\n");
// todo: add test EngineTestHelper eth(FORD_ASPIRE_1996);
AccelEnrichmemnt instance; EXPAND_EngineTestHelper;
engine->rpmCalculator.setRpmValue(600);
engine->periodicFastCallback(PASS_ENGINE_PARAMETER_F);
assertEqualsM("eventsCount", 4, engine->engineConfiguration2->injectionEvents->eventsCount);
engine->tpsAccelEnrichment.setLength(4);
engine->tpsAccelEnrichment.onNewValue(0 PASS_ENGINE_PARAMETER);
engine->tpsAccelEnrichment.onNewValue(10 PASS_ENGINE_PARAMETER);
engine->tpsAccelEnrichment.onNewValue(30 PASS_ENGINE_PARAMETER);
assertEqualsM("maxDelta", 80, engine->tpsAccelEnrichment.getMaxDelta());
engine->tpsAccelEnrichment.onNewValue(0 PASS_ENGINE_PARAMETER);
engine->tpsAccelEnrichment.onNewValue(0 PASS_ENGINE_PARAMETER);
engine->tpsAccelEnrichment.onNewValue(0 PASS_ENGINE_PARAMETER);
engine->tpsAccelEnrichment.onNewValue(0 PASS_ENGINE_PARAMETER);
assertEqualsM("maxDelta", 0, engine->tpsAccelEnrichment.getMaxDelta());
} }