WFT is wrong with MRE_miata_na6 config? operationMode complexity #898

refactoring to begin with, zero logic change
This commit is contained in:
rusefi 2019-08-08 00:19:09 -04:00
parent 2438b3a27a
commit 51110b33ad
9 changed files with 26 additions and 13 deletions

View File

@ -308,6 +308,17 @@ injection_mode_e Engine::getCurrentInjectionMode(DECLARE_ENGINE_PARAMETER_SIGNAT
return rpmCalculator.isCranking(PASS_ENGINE_PARAMETER_SIGNATURE) ? CONFIG(crankingInjectionMode) : CONFIG(injectionMode);
}
// see also in TunerStudio project '[doesTriggerImplyOperationMode] tag
static bool doesTriggerImplyOperationMode(trigger_type_e type) {
return type != TT_TOOTHED_WHEEL && type != TT_TOOTHED_WHEEL_60_2 && type != TT_TOOTHED_WHEEL_36_1;
}
operation_mode_e Engine::getOperationMode(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
//return doesTriggerImplyOperationMode(engineConfiguration->trigger.type) ? triggerCentral.triggerShape.getOperationMode() : engineConfiguration->ambiguousOperationMode;
return engineConfiguration->operationMode;
}
/**
* 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.

View File

@ -77,6 +77,8 @@ public:
IgnitionEventList ignitionEvents;
LocalVersionHolder versionForConfigurationListeners;
LocalVersionHolder auxParametersVersion;
operation_mode_e getOperationMode(DECLARE_ENGINE_PARAMETER_SIGNATURE);
int globalSparkIdCoutner = 0;

View File

@ -235,7 +235,7 @@ void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
efiAssertVoid(CUSTOM_ERR_MAP_AVG_OFFSET, !cisnan(offsetAngle), "offsetAngle");
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
angle_t cylinderOffset = getEngineCycle(engineConfiguration->operationMode) * i / engineConfiguration->specs.cylindersCount;
angle_t cylinderOffset = getEngineCycle(engine->getOperationMode(PASS_ENGINE_PARAMETER_SIGNATURE)) * i / engineConfiguration->specs.cylindersCount;
efiAssertVoid(CUSTOM_ERR_6692, !cisnan(cylinderOffset), "cylinderOffset");
float cylinderStart = start + cylinderOffset - offsetAngle + tdcPosition();
fixAngle(cylinderStart, "cylinderStart", CUSTOM_ERR_6562);

View File

@ -34,7 +34,6 @@
#define CONFIG_ACCESS_FOR_CONFIG_HEADER_ONLY(x) persistentState.persistentConfiguration.engineConfiguration.x
#endif /* EFI_UNIT_TEST */
#define get_operationMode CONFIG_ACCESS_FOR_CONFIG_HEADER_ONLY(operationMode)
#define get_specs_displacement CONFIG_ACCESS_FOR_CONFIG_HEADER_ONLY(specs.displacement)
#define get_specs_cylindersCount CONFIG_ACCESS_FOR_CONFIG_HEADER_ONLY(specs.cylindersCount)
#define get_injector_flow CONFIG_ACCESS_FOR_CONFIG_HEADER_ONLY(injector.flow)

View File

@ -33,8 +33,8 @@
EXTERN_ENGINE
;
floatms_t getEngineCycleDuration(int rpm DECLARE_GLOBAL_SUFFIX) {
return getCrankshaftRevolutionTimeMs(rpm) * (get_operationMode == TWO_STROKE ? 1 : 2);
floatms_t getEngineCycleDuration(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
return getCrankshaftRevolutionTimeMs(rpm) * (engine->getOperationMode(PASS_ENGINE_PARAMETER_SIGNATURE) == TWO_STROKE ? 1 : 2);
}
/**
@ -472,7 +472,7 @@ ignition_mode_e getCurrentIgnitionMode(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
* This heavy method is only invoked in case of a configuration change or initialization.
*/
void prepareOutputSignals(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
ENGINE(engineCycle) = getEngineCycle(CONFIG(operationMode));
ENGINE(engineCycle) = getEngineCycle(engine->getOperationMode(PASS_ENGINE_PARAMETER_SIGNATURE));
angle_t maxTimingCorrMap = -720.0f;
angle_t maxTimingMap = -720.0f;

View File

@ -236,7 +236,7 @@ void printConfiguration(const engine_configuration_s *engineConfiguration) {
// printFloatArray("vBatt bins: ", engineConfiguration->injector.battLagCorrBins, VBAT_INJECTOR_CURVE_SIZE);
scheduleMsg(&logger, "rpmHardLimit: %d/operationMode=%d", engineConfiguration->rpmHardLimit,
engineConfiguration->operationMode);
engine->getOperationMode(PASS_ENGINE_PARAMETER_SIGNATURE));
scheduleMsg(&logger, "globalTriggerAngleOffset=%.2f", engineConfiguration->globalTriggerAngleOffset);

View File

@ -253,7 +253,7 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType,
if (diffNt == 0) {
rpmState->setRpmValue(NOISY_RPM PASS_ENGINE_PARAMETER_SUFFIX);
} else {
int mult = (int)getEngineCycle(engineConfiguration->operationMode) / 360;
int mult = (int)getEngineCycle(engine->getOperationMode(PASS_ENGINE_PARAMETER_SIGNATURE)) / 360;
int rpm = (int) (60 * US2NT(US_PER_SECOND_LL) * mult / diffNt);
rpmState->setRpmValue(rpm > UNREALISTIC_RPM ? NOISY_RPM : rpm PASS_ENGINE_PARAMETER_SUFFIX);
}

View File

@ -348,10 +348,11 @@ static ALWAYS_INLINE void prepareIgnitionSchedule(DECLARE_ENGINE_PARAMETER_SIGNA
* 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'
*/
float maxAllowedDwellAngle = (int) (getEngineCycle(engineConfiguration->operationMode) / 2); // the cast is about making Coverity happy
operation_mode_e operationMode = engine->getOperationMode(PASS_ENGINE_PARAMETER_SIGNATURE);
float maxAllowedDwellAngle = (int) (getEngineCycle(operationMode) / 2); // the cast is about making Coverity happy
if (getCurrentIgnitionMode(PASS_ENGINE_PARAMETER_SIGNATURE) == IM_ONE_COIL) {
maxAllowedDwellAngle = getEngineCycle(engineConfiguration->operationMode) / engineConfiguration->specs.cylindersCount / 1.1;
maxAllowedDwellAngle = getEngineCycle(operationMode) / engineConfiguration->specs.cylindersCount / 1.1;
}
if (engine->engineState.dwellAngle == 0) {
@ -450,6 +451,6 @@ int getNumberOfSparks(ignition_mode_e mode DECLARE_ENGINE_PARAMETER_SUFFIX) {
*/
percent_t getCoilDutyCycle(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
floatms_t totalPerCycle = 1/**getInjectionDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX)*/ * getNumberOfSparks(getCurrentIgnitionMode(PASS_ENGINE_PARAMETER_SIGNATURE) PASS_ENGINE_PARAMETER_SUFFIX);
floatms_t engineCycleDuration = getCrankshaftRevolutionTimeMs(rpm) * (engineConfiguration->operationMode == TWO_STROKE ? 1 : 2);
floatms_t engineCycleDuration = getCrankshaftRevolutionTimeMs(rpm) * (engine->getOperationMode(PASS_ENGINE_PARAMETER_SIGNATURE) == TWO_STROKE ? 1 : 2);
return 100 * totalPerCycle / engineCycleDuration;
}

View File

@ -1,12 +1,12 @@
// This file was generated by Version2Header
// Tue Aug 06 22:52:28 EDT 2019
// Wed Aug 07 22:44:31 EDT 2019
#ifndef GIT_HASH
#define GIT_HASH "2579897d060ece1d5416fa9a117b81f274a1f3ba"
#define GIT_HASH "1f8bfa4ee0f861b8087f350381e2c462be2b9bd8"
#endif
#ifndef VCS_VERSION
#define VCS_VERSION "19666"
#define VCS_VERSION "19676"
#endif