trigger refactoring

This commit is contained in:
rusefi 2020-01-26 06:12:01 -05:00
parent 154b679491
commit 080e7e12db
4 changed files with 33 additions and 34 deletions

View File

@ -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) {

View File

@ -58,7 +58,7 @@ public:
cyclic_buffer<int> triggerErrorDetection;
void OnTriggerStateDecodingError() override;
void OnTriggerStateDecodingError();
void OnTriggerStateProperState(efitick_t nowNt) override;
void OnTriggerSyncronization(bool wasSynchronized) override;
void OnTriggerInvalidIndex(int currentIndex) override;

View File

@ -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) {

View File

@ -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);
/**