auto-sync
This commit is contained in:
parent
6f51295479
commit
9824339764
|
@ -63,24 +63,34 @@ floatms_t WallFuel::getWallFuel(int injectorIndex) {
|
|||
return wallFuel[injectorIndex];
|
||||
}
|
||||
|
||||
float AccelEnrichmemnt::getMaxDelta(DECLARE_ENGINE_PARAMETER_F) {
|
||||
int AccelEnrichmemnt::getMaxDeltaIndex(DECLARE_ENGINE_PARAMETER_F) {
|
||||
|
||||
int len = minI(cb.getSize(), cb.getCount());
|
||||
if (len < 2)
|
||||
return 0;
|
||||
float maxValue = cb.elements[0] - cb.elements[len - 1];
|
||||
// int resultIndex = 0;
|
||||
int ci = cb.currentIndex - 1;
|
||||
float maxValue = cb.get(ci) - cb.get(ci - 1);
|
||||
int resultIndex = ci;
|
||||
|
||||
for (int i = 1; i<len;i++) {
|
||||
float v = cb.elements[i] - cb.elements[i - 1];
|
||||
// todo: 'get' method is maybe a bit heavy because of the branching
|
||||
// todo: this could be optimized with some careful magic
|
||||
|
||||
for (int i = 1; i<len - 1;i++) {
|
||||
float v = cb.get(ci - i) - cb.get(ci - i - 1);
|
||||
if (v > maxValue) {
|
||||
maxValue = v;
|
||||
// resultIndex = i;
|
||||
resultIndex = ci - i;
|
||||
}
|
||||
}
|
||||
|
||||
return resultIndex;
|
||||
}
|
||||
|
||||
float AccelEnrichmemnt::getMaxDelta(DECLARE_ENGINE_PARAMETER_F) {
|
||||
int index = getMaxDeltaIndex(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
FuelSchedule *fs = engine->engineConfiguration2->injectionEvents;
|
||||
return maxValue * fs->eventsCount;
|
||||
return (cb.get(index) - (cb.get(index - 1))) * fs->eventsCount;
|
||||
}
|
||||
|
||||
// todo: eliminate code duplication between these two methods! Some pointer magic would help.
|
||||
|
|
|
@ -27,6 +27,7 @@ public:
|
|||
* @return Extra fuel squirt duration for TPS acceleration
|
||||
*/
|
||||
floatms_t getTpsEnrichment(DECLARE_ENGINE_PARAMETER_F);
|
||||
int getMaxDeltaIndex(DECLARE_ENGINE_PARAMETER_F);
|
||||
float getMaxDelta(DECLARE_ENGINE_PARAMETER_F);
|
||||
|
||||
void onEngineCycle(DECLARE_ENGINE_PARAMETER_F);
|
||||
|
|
|
@ -275,5 +275,5 @@ int getRusEfiVersion(void) {
|
|||
return 123; // this is here to make the compiler happy about the unused array
|
||||
if (UNUSED_CCM_SIZE[0] * 0 != 0)
|
||||
return 3211; // this is here to make the compiler happy about the unused array
|
||||
return 20160303;
|
||||
return 20160310;
|
||||
}
|
||||
|
|
|
@ -45,10 +45,10 @@ class cyclic_buffer
|
|||
int getCount();
|
||||
void clear();
|
||||
volatile T elements[CB_MAX_SIZE];
|
||||
volatile int currentIndex;
|
||||
|
||||
private:
|
||||
void baseC(int size);
|
||||
volatile int currentIndex;
|
||||
/**
|
||||
* number of elements added into this buffer, would be eventually bigger then size
|
||||
*/
|
||||
|
|
|
@ -28,16 +28,16 @@ void testAccelEnrichment(void) {
|
|||
engine->tpsAccelEnrichment.onNewValue(0 PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("maxDelta", 0, engine->tpsAccelEnrichment.getMaxDelta(PASS_ENGINE_PARAMETER_F));
|
||||
engine->tpsAccelEnrichment.onNewValue(10 PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("maxDelta", 40, engine->tpsAccelEnrichment.getMaxDelta(PASS_ENGINE_PARAMETER_F));
|
||||
assertEqualsM("maxDelta#1", 40, engine->tpsAccelEnrichment.getMaxDelta(PASS_ENGINE_PARAMETER_F));
|
||||
engine->tpsAccelEnrichment.onNewValue(30 PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("maxDelta", 80, engine->tpsAccelEnrichment.getMaxDelta(PASS_ENGINE_PARAMETER_F));
|
||||
assertEqualsM("maxDelta#2", 80, engine->tpsAccelEnrichment.getMaxDelta(PASS_ENGINE_PARAMETER_F));
|
||||
|
||||
engine->tpsAccelEnrichment.onNewValue(0 PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("maxDelta", 80, engine->tpsAccelEnrichment.getMaxDelta(PASS_ENGINE_PARAMETER_F));
|
||||
assertEqualsM("maxDelta#3", 80, engine->tpsAccelEnrichment.getMaxDelta(PASS_ENGINE_PARAMETER_F));
|
||||
engine->tpsAccelEnrichment.onNewValue(0 PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("maxDelta", 80, engine->tpsAccelEnrichment.getMaxDelta(PASS_ENGINE_PARAMETER_F));
|
||||
assertEqualsM("maxDelta#4", 80, engine->tpsAccelEnrichment.getMaxDelta(PASS_ENGINE_PARAMETER_F));
|
||||
engine->tpsAccelEnrichment.onNewValue(0 PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("maxDelta", 120, engine->tpsAccelEnrichment.getMaxDelta(PASS_ENGINE_PARAMETER_F));
|
||||
assertEqualsM("maxDelta#5", 0, engine->tpsAccelEnrichment.getMaxDelta(PASS_ENGINE_PARAMETER_F));
|
||||
engine->tpsAccelEnrichment.onNewValue(0 PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("maxDelta", 0, engine->tpsAccelEnrichment.getMaxDelta(PASS_ENGINE_PARAMETER_F));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue