refactoring: de-coupling trigger decoder and engine

This commit is contained in:
rusefi 2020-01-26 03:48:25 -05:00
parent db2ab72d12
commit 154b679491
4 changed files with 10 additions and 10 deletions

View File

@ -279,7 +279,7 @@ void Engine::OnTriggerSyncronization(bool wasSynchronized) {
/**
* We can check if things are fine by comparing the number of events in a cycle with the expected number of event.
*/
bool isDecodingError = triggerCentral.triggerState.validateEventCounters(PASS_ENGINE_PARAMETER_SIGNATURE);
bool isDecodingError = triggerCentral.triggerState.validateEventCounters(&triggerCentral.triggerShape);
enginePins.triggerDecoderErrorPin.setValue(isDecodingError);

View File

@ -839,6 +839,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0)
return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 201200125;
return 201200126;
}
#endif /* EFI_UNIT_TEST */

View File

@ -331,17 +331,17 @@ void TriggerState::onSynchronizationLost(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
engine->rpmCalculator.setStopSpinning(PASS_ENGINE_PARAMETER_SIGNATURE);
}
bool TriggerState::validateEventCounters(DECLARE_ENGINE_PARAMETER_SIGNATURE) const {
bool isDecodingError = currentCycle.eventCount[0] != TRIGGER_WAVEFORM(expectedEventCount[0])
|| currentCycle.eventCount[1] != TRIGGER_WAVEFORM(expectedEventCount[1])
|| currentCycle.eventCount[2] != TRIGGER_WAVEFORM(expectedEventCount[2]);
bool TriggerState::validateEventCounters(TriggerWaveform *triggerShape) const {
bool isDecodingError = currentCycle.eventCount[0] != triggerShape->expectedEventCount[0]
|| currentCycle.eventCount[1] != triggerShape->expectedEventCount[1]
|| currentCycle.eventCount[2] != triggerShape->expectedEventCount[2];
#if EFI_UNIT_TEST
printf("sync point: isDecodingError=%d\r\n", isDecodingError);
if (isDecodingError) {
printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[0], TRIGGER_WAVEFORM(expectedEventCount[0]));
printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[1], TRIGGER_WAVEFORM(expectedEventCount[1]));
printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[2], TRIGGER_WAVEFORM(expectedEventCount[2]));
printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[0], triggerShape->expectedEventCount[0]);
printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[1], triggerShape->expectedEventCount[1]);
printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[2], triggerShape->expectedEventCount[2]);
}
#endif /* EFI_UNIT_TEST */

View File

@ -71,7 +71,7 @@ public:
TriggerStateListener * triggerStateListener,
trigger_event_e const signal, efitime_t nowUs DECLARE_CONFIG_PARAMETER_SUFFIX);
bool validateEventCounters(DECLARE_ENGINE_PARAMETER_SIGNATURE) const;
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);