inline method to reduce confusion
This commit is contained in:
parent
6b0941b8ed
commit
82cda62bac
|
@ -585,22 +585,6 @@ static bool doesTriggerImplyOperationMode(trigger_type_e type) {
|
|||
}
|
||||
}
|
||||
|
||||
operation_mode_e Engine::getOperationMode() const {
|
||||
return rpmCalculator.getOperationMode();
|
||||
}
|
||||
|
||||
|
||||
operation_mode_e RpmCalculator::getOperationMode() const {
|
||||
// Ignore user-provided setting for well known triggers.
|
||||
if (doesTriggerImplyOperationMode(engineConfiguration->trigger.type)) {
|
||||
// For example for Miata NA, there is no reason to allow user to set FOUR_STROKE_CRANK_SENSOR
|
||||
return engine->triggerCentral.triggerShape.getWheelOperationMode();
|
||||
} else {
|
||||
// For example 36-1, could be on either cam or crank, so we have to ask the user
|
||||
return lookupOperationMode();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The idea of this method is to execute all heavy calculations in a lower-priority thread,
|
||||
* so that trigger event handler/IO scheduler tasks are faster.
|
||||
|
|
|
@ -219,7 +219,6 @@ public:
|
|||
|
||||
LocalVersionHolder versionForConfigurationListeners;
|
||||
LocalVersionHolder auxParametersVersion;
|
||||
operation_mode_e getOperationMode() const;
|
||||
|
||||
AuxActor auxValves[AUX_DIGITAL_VALVE_COUNT][2];
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ void refreshMapAveragingPreCalc() {
|
|||
efiAssertVoid(CUSTOM_ERR_MAP_AVG_OFFSET, !cisnan(offsetAngle), "offsetAngle");
|
||||
|
||||
for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
||||
angle_t cylinderOffset = getEngineCycle(engine->getOperationMode()) * i / engineConfiguration->specs.cylindersCount;
|
||||
angle_t cylinderOffset = getEngineCycle(getEngineRotationState()->getOperationMode()) * i / engineConfiguration->specs.cylindersCount;
|
||||
efiAssertVoid(CUSTOM_ERR_MAP_CYL_OFFSET, !cisnan(cylinderOffset), "cylinderOffset");
|
||||
// part of this formula related to specific cylinder offset is never changing - we can
|
||||
// move the loop into start-up calculation and not have this loop as part of periodic calculation
|
||||
|
|
|
@ -101,6 +101,18 @@ bool RpmCalculator::checkIfSpinning(efitick_t nowNt) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
// todo: move to triggerCentral/triggerShape since has nothing to do with rotation state!
|
||||
operation_mode_e RpmCalculator::getOperationMode() const {
|
||||
// Ignore user-provided setting for well known triggers.
|
||||
if (doesTriggerImplyOperationMode(engineConfiguration->trigger.type)) {
|
||||
// For example for Miata NA, there is no reason to allow user to set FOUR_STROKE_CRANK_SENSOR
|
||||
return engine->triggerCentral.triggerShape.getWheelOperationMode();
|
||||
} else {
|
||||
// For example 36-1, could be on either cam or crank, so we have to ask the user
|
||||
return lookupOperationMode();
|
||||
}
|
||||
}
|
||||
|
||||
void RpmCalculator::assignRpmValue(float floatRpmValue) {
|
||||
previousRpmValue = cachedRpmValue;
|
||||
|
||||
|
@ -255,7 +267,7 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType,
|
|||
rpmState->setRpmValue(NOISY_RPM);
|
||||
rpmState->rpmRate = 0;
|
||||
} else {
|
||||
int mult = (int)getEngineCycle(engine->getOperationMode()) / 360;
|
||||
int mult = (int)getEngineCycle(getEngineRotationState()->getOperationMode()) / 360;
|
||||
float rpm = 60 * mult / periodSeconds;
|
||||
|
||||
auto rpmDelta = rpm - rpmState->previousRpmValue;
|
||||
|
|
|
@ -15,6 +15,7 @@ public:
|
|||
*/
|
||||
virtual bool isStopped() const = 0;
|
||||
|
||||
// todo: move to triggerCentral/triggerShape since has nothing to do with rotation state!
|
||||
virtual operation_mode_e getOperationMode() const = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -406,7 +406,7 @@ static void prepareIgnitionSchedule() {
|
|||
* but we are already re-purposing the output signals, but everything works because we
|
||||
* are not affecting that space in memory. todo: use two instances of 'ignitionSignals'
|
||||
*/
|
||||
operation_mode_e operationMode = engine->getOperationMode();
|
||||
operation_mode_e operationMode = getEngineRotationState()->getOperationMode();
|
||||
float maxAllowedDwellAngle = (int) (getEngineCycle(operationMode) / 2); // the cast is about making Coverity happy
|
||||
|
||||
if (getCurrentIgnitionMode() == IM_ONE_COIL) {
|
||||
|
@ -498,7 +498,7 @@ int getNumberOfSparks(ignition_mode_e mode) {
|
|||
*/
|
||||
percent_t getCoilDutyCycle(int rpm) {
|
||||
floatms_t totalPerCycle = engine->engineState.sparkDwell * getNumberOfSparks(getCurrentIgnitionMode());
|
||||
floatms_t engineCycleDuration = getCrankshaftRevolutionTimeMs(rpm) * (engine->getOperationMode() == TWO_STROKE ? 1 : 2);
|
||||
floatms_t engineCycleDuration = getCrankshaftRevolutionTimeMs(rpm) * (getEngineRotationState()->getOperationMode() == TWO_STROKE ? 1 : 2);
|
||||
return 100 * totalPerCycle / engineCycleDuration;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#define CLEANUP_MODE_TPS 90
|
||||
|
||||
static bool noFiringUntilVvtSync(vvt_mode_e vvtMode) {
|
||||
auto operationMode = engine->getOperationMode();
|
||||
auto operationMode = getEngineRotationState()->getOperationMode();
|
||||
|
||||
// V-Twin MAP phase sense needs to always wait for sync
|
||||
if (vvtMode == VVT_MAP_V_TWIN) {
|
||||
|
|
|
@ -35,7 +35,7 @@ angle_t wrapAngleMethod(angle_t param, const char *msg, obd_code_e code) {
|
|||
}
|
||||
|
||||
floatms_t getEngineCycleDuration(int rpm) {
|
||||
return getCrankshaftRevolutionTimeMs(rpm) * (engine->getOperationMode() == TWO_STROKE ? 1 : 2);
|
||||
return getCrankshaftRevolutionTimeMs(rpm) * (getEngineRotationState()->getOperationMode() == TWO_STROKE ? 1 : 2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -433,7 +433,7 @@ ignition_mode_e getCurrentIgnitionMode() {
|
|||
* This heavy method is only invoked in case of a configuration change or initialization.
|
||||
*/
|
||||
void prepareOutputSignals() {
|
||||
getEngineState()->engineCycle = getEngineCycle(engine->getOperationMode());
|
||||
getEngineState()->engineCycle = getEngineCycle(getEngineRotationState()->getOperationMode());
|
||||
|
||||
#if EFI_UNIT_TEST
|
||||
if (verboseMode) {
|
||||
|
|
|
@ -95,7 +95,7 @@ void printConfiguration(const engine_configuration_s *engineConfiguration) {
|
|||
efiPrintf("configurationVersion=%d", engine->getGlobalConfigurationVersion());
|
||||
|
||||
efiPrintf("rpmHardLimit: %d/operationMode=%d", engineConfiguration->rpmHardLimit,
|
||||
engine->getOperationMode());
|
||||
getEngineRotationState()->getOperationMode());
|
||||
|
||||
efiPrintf("globalTriggerAngleOffset=%.2f", engineConfiguration->globalTriggerAngleOffset);
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ static bool vvtWithRealDecoder(vvt_mode_e vvtMode) {
|
|||
}
|
||||
|
||||
static angle_t syncAndReport(TriggerCentral *tc, int divider, int remainder) {
|
||||
angle_t engineCycle = getEngineCycle(engine->getOperationMode());
|
||||
angle_t engineCycle = getEngineCycle(getEngineRotationState()->getOperationMode());
|
||||
|
||||
return tc->triggerState.syncEnginePhase(divider, remainder, engineCycle);
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ static angle_t adjustCrankPhase(int camIndex) {
|
|||
}
|
||||
|
||||
TriggerCentral *tc = &engine->triggerCentral;
|
||||
operation_mode_e operationMode = engine->getOperationMode();
|
||||
operation_mode_e operationMode = getEngineRotationState()->getOperationMode();
|
||||
|
||||
vvt_mode_e vvtMode = engineConfiguration->vvtMode[camIndex];
|
||||
switch (vvtMode) {
|
||||
|
|
|
@ -93,7 +93,7 @@ void setTriggerEmulatorRPM(int rpm) {
|
|||
if (rpm == 0) {
|
||||
triggerSignal.setFrequency(NAN);
|
||||
} else {
|
||||
float rpmM = getRpmMultiplier(engine->getOperationMode());
|
||||
float rpmM = getRpmMultiplier(getEngineRotationState()->getOperationMode());
|
||||
float rPerSecond = rpm * rpmM / 60.0; // per minute converted to per second
|
||||
triggerSignal.setFrequency(rPerSecond);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ TEST(engine, testSymmetricalCrank) {
|
|||
engineConfiguration->isFasterEngineSpinUpEnabled = false;
|
||||
engineConfiguration->alwaysInstantRpm = true;
|
||||
|
||||
ASSERT_EQ(FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR, engine->getOperationMode());
|
||||
ASSERT_EQ(FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR, getEngineRotationState()->getOperationMode());
|
||||
|
||||
float mult = 0.02;
|
||||
|
||||
|
|
Loading…
Reference in New Issue