The Big Refactoring of 2019: configuration version should not be a global variable #656
This commit is contained in:
parent
fd9506b4e1
commit
2f0804022b
|
@ -64,7 +64,7 @@ static msg_t auxPidThread(int param) {
|
|||
while (true) {
|
||||
auxPid.sleep();
|
||||
|
||||
if (parametersVersion.isOld()) {
|
||||
if (parametersVersion.isOld(getGlobalConfigurationVersion())) {
|
||||
pidReset();
|
||||
}
|
||||
|
||||
|
|
|
@ -318,7 +318,7 @@ static void periodicSlowCallback(Engine *engine) {
|
|||
updatePrimeInjectionPulseState(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
}
|
||||
|
||||
if (versionForConfigurationListeners.isOld()) {
|
||||
if (versionForConfigurationListeners.isOld(getGlobalConfigurationVersion())) {
|
||||
updateAccelParameters();
|
||||
engine->engineState.warmupAfrPid.reset();
|
||||
}
|
||||
|
|
|
@ -489,7 +489,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D
|
|||
|
||||
if (trgEventIndex == 0) {
|
||||
|
||||
if (checkIfTriggerConfigChanged()) {
|
||||
if (checkIfTriggerConfigChanged(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
||||
engine->ignitionEvents.isReady = false; // we need to rebuild ignition schedule
|
||||
engine->injectionEvents.isReady = false;
|
||||
// moved 'triggerIndexByAngle' into trigger initialization (why was it invoked from here if it's only about trigger shape & optimization?)
|
||||
|
|
|
@ -691,8 +691,8 @@ void onConfigurationChangeTriggerCallback(engine_configuration_s *previousConfig
|
|||
/**
|
||||
* @returns true if configuration just changed, and if that change has affected trigger
|
||||
*/
|
||||
bool checkIfTriggerConfigChanged(void) {
|
||||
bool result = triggerVersion.isOld() && isTriggerConfigChanged;
|
||||
bool checkIfTriggerConfigChanged(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
bool result = triggerVersion.isOld(getGlobalConfigurationVersion()) && isTriggerConfigChanged;
|
||||
isTriggerConfigChanged = false; // whoever has called the method is supposed to react to changes
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ int isSignalDecoderError(void);
|
|||
void resetMaxValues();
|
||||
|
||||
void onConfigurationChangeTriggerCallback(engine_configuration_s *previousConfiguration DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
bool checkIfTriggerConfigChanged(void);
|
||||
bool checkIfTriggerConfigChanged(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
bool readIfTriggerConfigChangedForUnitTest(void);
|
||||
void resetTriggerConfigChangedForUnitTest(void);
|
||||
|
||||
|
|
|
@ -7,11 +7,6 @@
|
|||
|
||||
#include "LocalVersionHolder.h"
|
||||
|
||||
/**
|
||||
* we rely on external source of global version
|
||||
*/
|
||||
int getGlobalConfigurationVersion(void);
|
||||
|
||||
LocalVersionHolder::LocalVersionHolder() {
|
||||
/**
|
||||
* we want local version to be 'old' on instantiation
|
||||
|
@ -23,8 +18,7 @@ int LocalVersionHolder::getVersion() {
|
|||
return localVersion;
|
||||
}
|
||||
|
||||
bool LocalVersionHolder::isOld() {
|
||||
int global = getGlobalConfigurationVersion();
|
||||
bool LocalVersionHolder::isOld(int global) {
|
||||
if (global > localVersion) {
|
||||
localVersion = global;
|
||||
return true;
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
*
|
||||
* @return true if getGlobalConfigurationVersion() has changed since last time we've invoked this method
|
||||
*/
|
||||
bool isOld();
|
||||
bool isOld(int currentVersion);
|
||||
int getVersion();
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue