The Big Refactoring of 2019: configuration version should not be a global variable #656
This commit is contained in:
parent
a8b3c8f8d2
commit
8539ba3271
|
@ -64,7 +64,7 @@ static msg_t auxPidThread(int param) {
|
||||||
while (true) {
|
while (true) {
|
||||||
auxPid.sleep();
|
auxPid.sleep();
|
||||||
|
|
||||||
if (parametersVersion.isOld(getGlobalConfigurationVersion())) {
|
if (parametersVersion.isOld(engine->getGlobalConfigurationVersion())) {
|
||||||
pidReset();
|
pidReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,9 @@ static TriggerState initState CCM_OPTIONAL;
|
||||||
|
|
||||||
LoggingWithStorage engineLogger("engine");
|
LoggingWithStorage engineLogger("engine");
|
||||||
|
|
||||||
|
extern int globalConfigurationVersion;
|
||||||
|
|
||||||
|
|
||||||
EXTERN_ENGINE
|
EXTERN_ENGINE
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -166,6 +169,10 @@ bool Engine::needToStopEngine(efitick_t nowNt) {
|
||||||
nowNt - stopEngineRequestTimeNt < 3 * US2NT(US_PER_SECOND_LL);
|
nowNt - stopEngineRequestTimeNt < 3 * US2NT(US_PER_SECOND_LL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Engine::getGlobalConfigurationVersion(void) const {
|
||||||
|
return globalConfigurationVersion;
|
||||||
|
}
|
||||||
|
|
||||||
void Engine::reset() {
|
void Engine::reset() {
|
||||||
withError = isEngineChartEnabled = false;
|
withError = isEngineChartEnabled = false;
|
||||||
etbAutoTune = false;
|
etbAutoTune = false;
|
||||||
|
|
|
@ -343,6 +343,8 @@ public:
|
||||||
InjectionSignalPair fuelActuators[INJECTION_PIN_COUNT];
|
InjectionSignalPair fuelActuators[INJECTION_PIN_COUNT];
|
||||||
IgnitionEventList ignitionEvents;
|
IgnitionEventList ignitionEvents;
|
||||||
|
|
||||||
|
int getGlobalConfigurationVersion(void) const;
|
||||||
|
|
||||||
// a pointer with interface type would make this code nicer but would carry extra runtime
|
// a pointer with interface type would make this code nicer but would carry extra runtime
|
||||||
// cost to resolve pointer, we use instances as a micro optimization
|
// cost to resolve pointer, we use instances as a micro optimization
|
||||||
#if EFI_SIGNAL_EXECUTOR_ONE_TIMER
|
#if EFI_SIGNAL_EXECUTOR_ONE_TIMER
|
||||||
|
|
|
@ -136,7 +136,11 @@ static fuel_table_t alphaNfuel = {
|
||||||
{/*15 engineLoad=100.00*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx}
|
{/*15 engineLoad=100.00*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx}
|
||||||
};
|
};
|
||||||
|
|
||||||
static volatile int globalConfigurationVersion = 0;
|
/**
|
||||||
|
* This counter is incremented every time user adjusts ECU parameters online (either via dev console or other
|
||||||
|
* tuning software)
|
||||||
|
*/
|
||||||
|
volatile int globalConfigurationVersion = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current engine configuration. On firmware start we assign empty configuration, then
|
* Current engine configuration. On firmware start we assign empty configuration, then
|
||||||
|
@ -153,13 +157,6 @@ void rememberCurrentConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
memcpy(&activeConfiguration, engineConfiguration, sizeof(engine_configuration_s));
|
memcpy(&activeConfiguration, engineConfiguration, sizeof(engine_configuration_s));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This counter is incremented every time user adjusts ECU parameters online (either via dev console or other
|
|
||||||
* tuning software)
|
|
||||||
*/
|
|
||||||
int getGlobalConfigurationVersion(void) {
|
|
||||||
return globalConfigurationVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern LoggingWithStorage sharedLogger;
|
extern LoggingWithStorage sharedLogger;
|
||||||
|
|
||||||
|
|
|
@ -308,7 +308,7 @@ static void periodicSlowCallback(Engine *engine) {
|
||||||
updatePrimeInjectionPulseState(PASS_ENGINE_PARAMETER_SIGNATURE);
|
updatePrimeInjectionPulseState(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (versionForConfigurationListeners.isOld(getGlobalConfigurationVersion())) {
|
if (versionForConfigurationListeners.isOld(engine->getGlobalConfigurationVersion())) {
|
||||||
updateAccelParameters();
|
updateAccelParameters();
|
||||||
engine->engineState.warmupAfrPid.reset();
|
engine->engineState.warmupAfrPid.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,7 +206,7 @@ void printConfiguration(const engine_configuration_s *engineConfiguration) {
|
||||||
getEngine_load_mode_e(engineConfiguration->fuelAlgorithm), engineConfiguration->fuelAlgorithm);
|
getEngine_load_mode_e(engineConfiguration->fuelAlgorithm), engineConfiguration->fuelAlgorithm);
|
||||||
|
|
||||||
|
|
||||||
scheduleMsg(&logger, "configurationVersion=%d", getGlobalConfigurationVersion());
|
scheduleMsg(&logger, "configurationVersion=%d", engine->getGlobalConfigurationVersion());
|
||||||
|
|
||||||
for (int k = 0; k < FUEL_LOAD_COUNT; k++) {
|
for (int k = 0; k < FUEL_LOAD_COUNT; k++) {
|
||||||
// print("line %d (%.2f): ", k, engineConfiguration->fuelKeyBins[k]);
|
// print("line %d (%.2f): ", k, engineConfiguration->fuelKeyBins[k]);
|
||||||
|
|
|
@ -692,7 +692,7 @@ void onConfigurationChangeTriggerCallback(engine_configuration_s *previousConfig
|
||||||
* @returns true if configuration just changed, and if that change has affected trigger
|
* @returns true if configuration just changed, and if that change has affected trigger
|
||||||
*/
|
*/
|
||||||
bool checkIfTriggerConfigChanged(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
bool checkIfTriggerConfigChanged(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
bool result = triggerVersion.isOld(getGlobalConfigurationVersion()) && isTriggerConfigChanged;
|
bool result = triggerVersion.isOld(engine->getGlobalConfigurationVersion()) && isTriggerConfigChanged;
|
||||||
isTriggerConfigChanged = false; // whoever has called the method is supposed to react to changes
|
isTriggerConfigChanged = false; // whoever has called the method is supposed to react to changes
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ static void updateTriggerShapeIfNeeded(PwmConfig *state) {
|
||||||
if (atTriggerVersion < engine->triggerCentral.triggerShape.version) {
|
if (atTriggerVersion < engine->triggerCentral.triggerShape.version) {
|
||||||
atTriggerVersion = engine->triggerCentral.triggerShape.version;
|
atTriggerVersion = engine->triggerCentral.triggerShape.version;
|
||||||
scheduleMsg(logger, "Stimulator: updating trigger shape: %d/%d %d", atTriggerVersion,
|
scheduleMsg(logger, "Stimulator: updating trigger shape: %d/%d %d", atTriggerVersion,
|
||||||
getGlobalConfigurationVersion(), currentTimeMillis());
|
engine->getGlobalConfigurationVersion(), currentTimeMillis());
|
||||||
|
|
||||||
|
|
||||||
TriggerShape *s = &engine->triggerCentral.triggerShape;
|
TriggerShape *s = &engine->triggerCentral.triggerShape;
|
||||||
|
|
|
@ -18,9 +18,9 @@ int LocalVersionHolder::getVersion() {
|
||||||
return localVersion;
|
return localVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocalVersionHolder::isOld(int global) {
|
bool LocalVersionHolder::isOld(int globalVersion) {
|
||||||
if (global > localVersion) {
|
if (globalVersion > localVersion) {
|
||||||
localVersion = global;
|
localVersion = globalVersion;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -21,9 +21,9 @@ public:
|
||||||
* Calling this method changes the internal state of the class - each consumer interested in tracking
|
* Calling this method changes the internal state of the class - each consumer interested in tracking
|
||||||
* changes should have it's own instance of this class
|
* changes should have it's own instance of this class
|
||||||
*
|
*
|
||||||
* @return true if getGlobalConfigurationVersion() has changed since last time we've invoked this method
|
* @return true if 'globalVersion' has changed since last time we've invoked this method
|
||||||
*/
|
*/
|
||||||
bool isOld(int currentVersion);
|
bool isOld(int globalVersion);
|
||||||
int getVersion();
|
int getVersion();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue