This commit is contained in:
rusefi 2019-01-19 19:45:35 -05:00
parent 64e7f3cf32
commit 78f4a68d3a
2 changed files with 5 additions and 12 deletions

View File

@ -59,9 +59,6 @@ RpmCalculator::RpmCalculator() {
// we need this initial to have not_running at first invocation
lastRpmEventTimeNt = (efitime_t) -10 * US2NT(US_PER_SECOND_LL);
revolutionCounterSinceBootForUnitTest = 0;
// WAT? this was just assigned a non-zero value a few lines above? which one is right?
lastRpmEventTimeNt = 0;
}
bool RpmCalculator::isStopped(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
@ -89,11 +86,6 @@ bool RpmCalculator::isRunning(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
* @return true if engine is spinning (cranking or running)
*/
bool RpmCalculator::checkIfSpinning(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (lastRpmEventTimeNt == 0) {
// here we assume 64 bit time does not overflow
// zero value is the default meaning no RPM events since reboot
return false;
}
efitick_t nowNt = getTimeNowNt();
if (ENGINE(needToStopEngine(nowNt))) {
setStopped(PASS_ENGINE_PARAMETER_SIGNATURE);

View File

@ -14,9 +14,10 @@ TEST(sensors, testFasterEngineSpinningUp) {
EngineTestHelper eth(TEST_ENGINE);
EXPAND_EngineTestHelper
// turn on FasterEngineSpinUp mode
engineConfiguration->bc.isFasterEngineSpinUpEnabled = true;
eth.firePrimaryTriggerRise();
// set ignition mode
engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS;
// set cranking threshold (used below)
@ -65,7 +66,7 @@ TEST(sensors, testFasterEngineSpinningUp) {
// check if the mode is changed when fully synched
ASSERT_EQ(CRANKING, engine->rpmCalculator.getState());
// check RPM
ASSERT_EQ( 300, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "RPM#2";
ASSERT_EQ( 200, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "RPM#2";
// test if they are simultaneous in cranking mode too
ASSERT_EQ(IM_SIMULTANEOUS, engine->getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE));
// test if ignition mode is restored to ind.coils
@ -73,8 +74,8 @@ TEST(sensors, testFasterEngineSpinningUp) {
// two simultaneous injections
ASSERT_EQ( 4, engine->executor.size()) << "plain#2";
// check real events
eth.assertEvent5(&engine->executor, "inj start#2", 0, (void*)startSimultaniousInjection, eth.getTimeNowUs(), 97975);
eth.assertEvent5(&engine->executor, "inj end#2", 1, (void*)endSimultaniousInjection, eth.getTimeNowUs(), 100000);
eth.assertEvent5(&engine->executor, "inj start#2", 0, (void*)startSimultaniousInjection, eth.getTimeNowUs(), 147975);
eth.assertEvent5(&engine->executor, "inj end#2", 1, (void*)endSimultaniousInjection, eth.getTimeNowUs(), 150000);
// skip, clear & advance 1 more revolution at higher RPM
eth.fireFall(60);