tear down Engine god object #4511

just trying different things
This commit is contained in:
Andrey 2022-09-05 02:44:06 -04:00
parent 1983a07078
commit 76b74a85ba
6 changed files with 14 additions and 9 deletions

View File

@ -570,8 +570,8 @@ float Engine::getTimeIgnitionSeconds(void) const {
return numSeconds; return numSeconds;
} }
injection_mode_e Engine::getCurrentInjectionMode() { injection_mode_e getCurrentInjectionMode() {
return rpmCalculator.isCranking() ? engineConfiguration->crankingInjectionMode : engineConfiguration->injectionMode; return getEngineRotationState()->isCranking() ? engineConfiguration->crankingInjectionMode : engineConfiguration->injectionMode;
} }
// see also in TunerStudio project '[doesTriggerImplyOperationMode] tag // see also in TunerStudio project '[doesTriggerImplyOperationMode] tag

View File

@ -246,7 +246,6 @@ public:
#endif #endif
void setConfig(); void setConfig();
injection_mode_e getCurrentInjectionMode();
LocalVersionHolder versionForConfigurationListeners; LocalVersionHolder versionForConfigurationListeners;
LocalVersionHolder auxParametersVersion; LocalVersionHolder auxParametersVersion;

View File

@ -242,7 +242,7 @@ int getNumberOfInjections(injection_mode_e mode) {
} }
float getInjectionModeDurationMultiplier() { float getInjectionModeDurationMultiplier() {
injection_mode_e mode = engine->getCurrentInjectionMode(); injection_mode_e mode = getCurrentInjectionMode();
switch (mode) { switch (mode) {
case IM_SIMULTANEOUS: { case IM_SIMULTANEOUS: {

View File

@ -5,6 +5,7 @@
*/ */
#include "pch.h" #include "pch.h"
#include "rpm_calculator_api.h"
#include "event_registry.h" #include "event_registry.h"
#if EFI_ENGINE_CONTROL #if EFI_ENGINE_CONTROL
@ -114,7 +115,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i) {
return false; return false;
} }
injection_mode_e mode = engine->getCurrentInjectionMode(); injection_mode_e mode = getCurrentInjectionMode();
// We need two outputs if: // We need two outputs if:
// - we are running batch fuel, and have "use two wire batch" enabled // - we are running batch fuel, and have "use two wire batch" enabled

View File

@ -4,9 +4,14 @@
#include "rusefi_types.h" #include "rusefi_types.h"
#pragma once
class EngineRotationState { class EngineRotationState {
public: public:
virtual floatus_t getOneDegreeUs() = 0; virtual floatus_t getOneDegreeUs() = 0;
virtual bool isCranking() const = 0;
}; };
EngineRotationState * getEngineRotationState(); EngineRotationState * getEngineRotationState();
injection_mode_e getCurrentInjectionMode();

View File

@ -27,7 +27,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
eth.fireRise(1000 /*ms*/); eth.fireRise(1000 /*ms*/);
// check if it's true // check if it's true
ASSERT_EQ(IM_SEQUENTIAL, engine->getCurrentInjectionMode()); ASSERT_EQ(IM_SEQUENTIAL, getCurrentInjectionMode());
ASSERT_EQ(IM_WASTED_SPARK, getCurrentIgnitionMode()); ASSERT_EQ(IM_WASTED_SPARK, getCurrentIgnitionMode());
// check if the engine has the right state // check if the engine has the right state
ASSERT_EQ(SPINNING_UP, engine->rpmCalculator.getState()); ASSERT_EQ(SPINNING_UP, engine->rpmCalculator.getState());
@ -48,7 +48,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
// two simultaneous injections // two simultaneous injections
ASSERT_EQ(4, engine->executor.size()) << "plain#2"; ASSERT_EQ(4, engine->executor.size()) << "plain#2";
// test if they are simultaneous // test if they are simultaneous
ASSERT_EQ(IM_SIMULTANEOUS, engine->getCurrentInjectionMode()); ASSERT_EQ(IM_SIMULTANEOUS, getCurrentInjectionMode());
// test if ignition mode is temporary changed to wasted spark, if set to individual coils // test if ignition mode is temporary changed to wasted spark, if set to individual coils
ASSERT_EQ(IM_WASTED_SPARK, getCurrentIgnitionMode()); ASSERT_EQ(IM_WASTED_SPARK, getCurrentIgnitionMode());
// check real events // check real events
@ -68,7 +68,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
// check RPM // check RPM
ASSERT_EQ( 200, round(Sensor::getOrZero(SensorType::Rpm))) << "RPM#2"; ASSERT_EQ( 200, round(Sensor::getOrZero(SensorType::Rpm))) << "RPM#2";
// test if they are simultaneous in cranking mode too // test if they are simultaneous in cranking mode too
ASSERT_EQ(IM_SIMULTANEOUS, engine->getCurrentInjectionMode()); ASSERT_EQ(IM_SIMULTANEOUS, getCurrentInjectionMode());
// Should still be in wasted spark since we don't have cam sync yet // Should still be in wasted spark since we don't have cam sync yet
ASSERT_EQ(IM_WASTED_SPARK, getCurrentIgnitionMode()); ASSERT_EQ(IM_WASTED_SPARK, getCurrentIgnitionMode());
// two simultaneous injections // two simultaneous injections
@ -92,7 +92,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
// check RPM // check RPM
ASSERT_EQ( 1000, round(Sensor::getOrZero(SensorType::Rpm))) << "RPM#3"; ASSERT_EQ( 1000, round(Sensor::getOrZero(SensorType::Rpm))) << "RPM#3";
// check if the injection mode is back to sequential now // check if the injection mode is back to sequential now
ASSERT_EQ(IM_SEQUENTIAL, engine->getCurrentInjectionMode()); ASSERT_EQ(IM_SEQUENTIAL, getCurrentInjectionMode());
// 4 sequential injections for the full cycle // 4 sequential injections for the full cycle
ASSERT_EQ( 8, engine->executor.size()) << "plain#3"; ASSERT_EQ( 8, engine->executor.size()) << "plain#3";