preparing for #973
This commit is contained in:
parent
f9fb4143a5
commit
344136eea9
|
@ -48,6 +48,7 @@ void WallFuel::resetWF() {
|
|||
|
||||
//
|
||||
floatms_t WallFuel::adjust(int injectorIndex, floatms_t desiredFuel DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
invocationCounter++;
|
||||
if (cisnan(desiredFuel)) {
|
||||
return desiredFuel;
|
||||
}
|
||||
|
@ -287,6 +288,8 @@ void TpsAccelEnrichment::onEngineCycleTps(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
// we update values in handleFuel() directly
|
||||
//onNewValue(getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
onUpdateInvocationCounter++;
|
||||
|
||||
// we used some extra fuel during the current cycle, so we "charge" our "acceleration pump" with it
|
||||
accumulatedValue -= maxExtraPerPeriod;
|
||||
maxExtraPerPeriod = maxF(maxExtraPerCycle, maxExtraPerPeriod);
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
void setLength(int length);
|
||||
cyclic_buffer<float> cb;
|
||||
void onNewValue(float currentValue DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
int onUpdateInvocationCounter = 0;
|
||||
};
|
||||
|
||||
class LoadAccelEnrichment : public AccelEnrichment {
|
||||
|
@ -75,6 +76,7 @@ public:
|
|||
floatms_t adjust(int injectorIndex, floatms_t target DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
floatms_t getWallFuel(int injectorIndex) const;
|
||||
void resetWF();
|
||||
int invocationCounter = 0;
|
||||
private:
|
||||
};
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ GTEST_API_ int main(int argc, char **argv) {
|
|||
// printTriggerDebug = true;
|
||||
|
||||
// resizeMap();
|
||||
printf("Success 20191013\r\n");
|
||||
printf("Success 20191016\r\n");
|
||||
printAllTriggers();
|
||||
// printConvertedTable();
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
/**
|
||||
* @file test_accel_enrichment.cpp
|
||||
*
|
||||
* See also test_fuel_wall_wetting.cpp
|
||||
*
|
||||
* @date Apr 29, 2014
|
||||
* Author: Dmitry Sidin
|
||||
* Author: Andrey Belomutskiy, (c) 2012-2018
|
||||
|
@ -10,8 +12,9 @@
|
|||
#include "engine_configuration.h"
|
||||
#include "accel_enrichment.h"
|
||||
#include "engine_test_helper.h"
|
||||
#include "tps.h"
|
||||
|
||||
TEST(fuel, testTpsAccelEnrichment) {
|
||||
TEST(fuel, testTpsAccelEnrichmentMath) {
|
||||
printf("====================================================================================== testAccelEnrichment\r\n");
|
||||
|
||||
WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996);
|
||||
|
@ -38,6 +41,40 @@ TEST(fuel, testTpsAccelEnrichment) {
|
|||
ASSERT_EQ( 0, engine->tpsAccelEnrichment.getMaxDelta(PASS_ENGINE_PARAMETER_SIGNATURE)) << "maxDelta";
|
||||
}
|
||||
|
||||
TEST(fuel, testTpsAccelEnrichmentScheduling) {
|
||||
WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996);
|
||||
|
||||
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
|
||||
engineConfiguration->useOnlyRisingEdgeForTrigger = true;
|
||||
|
||||
eth.setTriggerType(TT_ONE PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
setMockTpsValue(7 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
eth.fireTriggerEvents2(/* count */ 5, 25 /* ms */);
|
||||
ASSERT_EQ( 1200, GET_RPM()) << "RPM";
|
||||
int expectedInvocationCounter = 1;
|
||||
ASSERT_EQ(expectedInvocationCounter, ENGINE(tpsAccelEnrichment).onUpdateInvocationCounter);
|
||||
|
||||
setMockTpsValue(70 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
eth.fireTriggerEvents2(/* count */ 1, 25 /* ms */);
|
||||
|
||||
float expectedAEValue = 29.2;
|
||||
// it does not matter how many times we invoke 'getTpsEnrichment' - state does not change
|
||||
for (int i = 0; i <20;i++) {
|
||||
ASSERT_NEAR(expectedAEValue, ENGINE(tpsAccelEnrichment.getTpsEnrichment(PASS_ENGINE_PARAMETER_SIGNATURE)), EPS4D);
|
||||
}
|
||||
|
||||
expectedInvocationCounter++;
|
||||
ASSERT_EQ(expectedInvocationCounter, ENGINE(tpsAccelEnrichment).onUpdateInvocationCounter);
|
||||
|
||||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
ASSERT_EQ(expectedInvocationCounter, ENGINE(tpsAccelEnrichment).onUpdateInvocationCounter);
|
||||
}
|
||||
|
||||
static void doFractionalTpsIteration(int period, int divisor, int numCycles, std::vector<floatms_t> &tpsEnrich DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
// every cycle
|
||||
engineConfiguration->tpsAccelFractionPeriod = period;
|
||||
|
@ -53,7 +90,7 @@ static void doFractionalTpsIteration(int period, int divisor, int numCycles, std
|
|||
}
|
||||
}
|
||||
|
||||
TEST(big, testAccelEnrichmentFractionalTps) {
|
||||
TEST(fuel, testAccelEnrichmentFractionalTps) {
|
||||
printf("====================================================================================== testAccelEnrichmentFractionalTps\r\n");
|
||||
|
||||
WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "engine_test_helper.h"
|
||||
|
||||
|
||||
TEST(fuel, testWallWettingEnrichment) {
|
||||
TEST(fuel, testWallWettingEnrichmentMath) {
|
||||
WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996);
|
||||
|
||||
engineConfiguration->wwaeTau = 1.0f;
|
||||
|
@ -19,10 +19,31 @@ TEST(fuel, testWallWettingEnrichment) {
|
|||
|
||||
engine->rpmCalculator.setRpmValue(3000 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
// each invocation of 'adjust' changes WallWetting internal state
|
||||
ASSERT_NEAR(16.6666, ENGINE(wallFuel).adjust(0, 10.0 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
|
||||
|
||||
|
||||
ASSERT_NEAR(16.198, ENGINE(wallFuel).adjust(0, 10.0 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
|
||||
|
||||
|
||||
}
|
||||
|
||||
TEST(fuel, testWallWettingEnrichmentScheduling) {
|
||||
|
||||
WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996);
|
||||
|
||||
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
|
||||
engineConfiguration->useOnlyRisingEdgeForTrigger = true;
|
||||
|
||||
eth.setTriggerType(TT_ONE PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
|
||||
eth.fireTriggerEvents2(/* count */ 5, 25 /* ms */);
|
||||
ASSERT_EQ( 1200, GET_RPM()) << "RPM";
|
||||
|
||||
int expectedInvocationCounter = 4;
|
||||
ASSERT_EQ(expectedInvocationCounter, ENGINE(wallFuel).invocationCounter);
|
||||
|
||||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
// still same 4 - wall wetting is NOT invoked from 'periodicFastCallback'
|
||||
ASSERT_EQ(expectedInvocationCounter, ENGINE(wallFuel).invocationCounter);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue