From 080e7e12db04d95c7589b9faf9014df5f6311e61 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 26 Jan 2020 06:12:01 -0500 Subject: [PATCH] trigger refactoring --- firmware/controllers/algo/engine.cpp | 33 ++++++++++++++++++- firmware/controllers/algo/engine.h | 2 +- .../controllers/trigger/trigger_decoder.cpp | 30 ----------------- .../controllers/trigger/trigger_decoder.h | 2 -- 4 files changed, 33 insertions(+), 34 deletions(-) diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 901911da5c..f79b5d0a00 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -246,7 +246,38 @@ void Engine::preCalculate(DECLARE_ENGINE_PARAMETER_SIGNATURE) { void Engine::OnTriggerStateDecodingError() { Engine *engine = this; EXPAND_Engine; - triggerCentral.triggerState.handleTriggerError(PASS_ENGINE_PARAMETER_SIGNATURE); + if (engineConfiguration->debugMode == DBG_TRIGGER_SYNC) { +#if EFI_TUNER_STUDIO + tsOutputChannels.debugIntField1 = triggerCentral.triggerState.currentCycle.eventCount[0]; + tsOutputChannels.debugIntField2 = triggerCentral.triggerState.currentCycle.eventCount[1]; + tsOutputChannels.debugIntField3 = triggerCentral.triggerState.currentCycle.eventCount[2]; +#endif /* EFI_TUNER_STUDIO */ + } + + warning(CUSTOM_SYNC_COUNT_MISMATCH, "trigger not happy current %d/%d/%d expected %d/%d/%d", + triggerCentral.triggerState.currentCycle.eventCount[0], + triggerCentral.triggerState.currentCycle.eventCount[1], + triggerCentral.triggerState.currentCycle.eventCount[2], + TRIGGER_WAVEFORM(expectedEventCount[0]), + TRIGGER_WAVEFORM(expectedEventCount[1]), + TRIGGER_WAVEFORM(expectedEventCount[2])); + triggerCentral.triggerState.lastDecodingErrorTime = getTimeNowNt(); + triggerCentral.triggerState.someSortOfTriggerError = true; + + triggerCentral.triggerState.totalTriggerErrorCounter++; + if (CONFIG(verboseTriggerSynchDetails) || (triggerCentral.triggerState.someSortOfTriggerError && !CONFIG(silentTriggerError))) { +#if EFI_PROD_CODE + scheduleMsg(&engineLogger, "error: synchronizationPoint @ index %d expected %d/%d/%d got %d/%d/%d", + triggerCentral.triggerState.currentCycle.current_index, + TRIGGER_WAVEFORM(expectedEventCount[0]), + TRIGGER_WAVEFORM(expectedEventCount[1]), + TRIGGER_WAVEFORM(expectedEventCount[2]), + triggerCentral.triggerState.currentCycle.eventCount[0], + triggerCentral.triggerState.currentCycle.eventCount[1], + triggerCentral.triggerState.currentCycle.eventCount[2]); +#endif /* EFI_PROD_CODE */ + } + } void Engine::OnTriggerStateProperState(efitick_t nowNt) { diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 31dbc55a96..b11c384c58 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -58,7 +58,7 @@ public: cyclic_buffer triggerErrorDetection; - void OnTriggerStateDecodingError() override; + void OnTriggerStateDecodingError(); void OnTriggerStateProperState(efitick_t nowNt) override; void OnTriggerSyncronization(bool wasSynchronized) override; void OnTriggerInvalidIndex(int currentIndex) override; diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 47424efdd6..bcd2bdd06a 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -348,36 +348,6 @@ bool TriggerState::validateEventCounters(TriggerWaveform *triggerShape) const { return isDecodingError; } -void TriggerState::handleTriggerError(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - if (engineConfiguration->debugMode == DBG_TRIGGER_SYNC) { -#if EFI_TUNER_STUDIO - tsOutputChannels.debugIntField1 = currentCycle.eventCount[0]; - tsOutputChannels.debugIntField2 = currentCycle.eventCount[1]; - tsOutputChannels.debugIntField3 = currentCycle.eventCount[2]; -#endif /* EFI_TUNER_STUDIO */ - } - - warning(CUSTOM_SYNC_COUNT_MISMATCH, "trigger not happy current %d/%d/%d expected %d/%d/%d", - currentCycle.eventCount[0], - currentCycle.eventCount[1], - currentCycle.eventCount[2], - TRIGGER_WAVEFORM(expectedEventCount[0]), - TRIGGER_WAVEFORM(expectedEventCount[1]), - TRIGGER_WAVEFORM(expectedEventCount[2])); - lastDecodingErrorTime = getTimeNowNt(); - someSortOfTriggerError = true; - - totalTriggerErrorCounter++; - if (CONFIG(verboseTriggerSynchDetails) || (someSortOfTriggerError && !CONFIG(silentTriggerError))) { -#if EFI_PROD_CODE - scheduleMsg(logger, "error: synchronizationPoint @ index %d expected %d/%d/%d got %d/%d/%d", - currentCycle.current_index, TRIGGER_WAVEFORM(expectedEventCount[0]), - TRIGGER_WAVEFORM(expectedEventCount[1]), TRIGGER_WAVEFORM(expectedEventCount[2]), - currentCycle.eventCount[0], currentCycle.eventCount[1], currentCycle.eventCount[2]); -#endif /* EFI_PROD_CODE */ - } -} - void TriggerState::onShaftSynchronization(const TriggerStateCallback triggerCycleCallback, efitick_t nowNt, trigger_wheel_e triggerWheel, TriggerWaveform *triggerShape) { diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index b9296c26cb..5a049d17f9 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -16,7 +16,6 @@ class TriggerState; class TriggerStateListener { public: - virtual void OnTriggerStateDecodingError() = 0; virtual void OnTriggerStateProperState(efitick_t nowNt) = 0; virtual void OnTriggerSyncronization(bool wasSynchronized) = 0; virtual void OnTriggerInvalidIndex(int currentIndex) = 0; @@ -72,7 +71,6 @@ public: trigger_event_e const signal, efitime_t nowUs DECLARE_CONFIG_PARAMETER_SUFFIX); bool validateEventCounters(TriggerWaveform *triggerShape) const; - void handleTriggerError(DECLARE_ENGINE_PARAMETER_SIGNATURE); void onShaftSynchronization(const TriggerStateCallback triggerCycleCallback, efitick_t nowNt, trigger_wheel_e triggerWheel, TriggerWaveform *triggerShape); /**