refactoring

This commit is contained in:
rusefi 2020-01-22 01:22:44 -05:00
parent 8a88c90f3b
commit 06cdb7cde6
4 changed files with 12 additions and 16 deletions

View File

@ -56,6 +56,8 @@ public:
IEtbController *etbControllers[ETB_COUNT]; IEtbController *etbControllers[ETB_COUNT];
cyclic_buffer<int> triggerErrorDetection;
void OnTriggerStateDecodingError() override; void OnTriggerStateDecodingError() override;
void OnTriggerStateProperState(efitick_t nowNt) override; void OnTriggerStateProperState(efitick_t nowNt) override;

View File

@ -818,10 +818,10 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX)
// help to notice when RAM usage goes up - if a code change adds to RAM usage these variables would fail // help to notice when RAM usage goes up - if a code change adds to RAM usage these variables would fail
// linking process which is the way to raise the alarm // linking process which is the way to raise the alarm
#ifndef RAM_UNUSED_SIZE #ifndef RAM_UNUSED_SIZE
#define RAM_UNUSED_SIZE 14000 #define RAM_UNUSED_SIZE 14500
#endif #endif
#ifndef CCM_UNUSED_SIZE #ifndef CCM_UNUSED_SIZE
#define CCM_UNUSED_SIZE 4600 #define CCM_UNUSED_SIZE 4100
#endif #endif
static char UNUSED_RAM_SIZE[RAM_UNUSED_SIZE]; static char UNUSED_RAM_SIZE[RAM_UNUSED_SIZE];
static char UNUSED_CCM_SIZE[CCM_UNUSED_SIZE] CCM_OPTIONAL; static char UNUSED_CCM_SIZE[CCM_UNUSED_SIZE] CCM_OPTIONAL;
@ -839,6 +839,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0) if (initBootloader() != 0)
return 123; return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */ #endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 201200119; return 201200122;
} }
#endif /* EFI_UNIT_TEST */ #endif /* EFI_UNIT_TEST */

View File

@ -100,24 +100,18 @@ TriggerStateWithRunningStatistics::TriggerStateWithRunningStatistics() :
EXTERN_ENGINE EXTERN_ENGINE
; ;
// todo: this should become a field on some class
// no reason to make this a field on TriggerState since we have two instances of that one
// and only one needs this data structure. we probably need a virtual method of .addError() and
// only TriggerStateWithRunningStatistics would have the field?
static cyclic_buffer<int> errorDetection;
#if ! EFI_PROD_CODE #if ! EFI_PROD_CODE
bool printTriggerDebug = false; bool printTriggerDebug = false;
float actualSynchGap; float actualSynchGap;
#endif /* ! EFI_PROD_CODE */ #endif /* ! EFI_PROD_CODE */
static Logging * logger = NULL; static Logging * logger = nullptr;
/** /**
* @return TRUE is something is wrong with trigger decoding * @return TRUE is something is wrong with trigger decoding
*/ */
bool isTriggerDecoderError(void) { bool isTriggerDecoderError(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
return errorDetection.sum(6) > 4; return engine->triggerErrorDetection.sum(6) > 4;
} }
void calculateTriggerSynchPoint(TriggerWaveform *shape, TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX) { void calculateTriggerSynchPoint(TriggerWaveform *shape, TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX) {
@ -661,9 +655,9 @@ void TriggerState::decodeTriggerEvent(const TriggerStateCallback triggerCycleCal
triggerStateListener->OnTriggerStateDecodingError(); triggerStateListener->OnTriggerStateDecodingError();
} }
errorDetection.add(isDecodingError); engine->triggerErrorDetection.add(isDecodingError);
if (isTriggerDecoderError()) { if (isTriggerDecoderError(PASS_ENGINE_PARAMETER_SIGNATURE)) {
warning(CUSTOM_OBD_TRG_DECODING, "trigger decoding issue. expected %d/%d/%d got %d/%d/%d", warning(CUSTOM_OBD_TRG_DECODING, "trigger decoding issue. expected %d/%d/%d got %d/%d/%d",
TRIGGER_WAVEFORM(expectedEventCount[0]), TRIGGER_WAVEFORM(expectedEventCount[1]), TRIGGER_WAVEFORM(expectedEventCount[0]), TRIGGER_WAVEFORM(expectedEventCount[1]),
TRIGGER_WAVEFORM(expectedEventCount[2]), currentCycle.eventCount[0], currentCycle.eventCount[1], TRIGGER_WAVEFORM(expectedEventCount[2]), currentCycle.eventCount[0], currentCycle.eventCount[1],
@ -725,7 +719,7 @@ uint32_t TriggerState::findTriggerZeroEventIndex(TriggerWaveform * shape,
#if EFI_PROD_CODE #if EFI_PROD_CODE
efiAssert(CUSTOM_ERR_ASSERT, getCurrentRemainingStack() > 128, "findPos", -1); efiAssert(CUSTOM_ERR_ASSERT, getCurrentRemainingStack() > 128, "findPos", -1);
#endif #endif
errorDetection.clear(); engine->triggerErrorDetection.clear();
resetTriggerState(); resetTriggerState();

View File

@ -179,7 +179,7 @@ class Engine;
void initTriggerDecoder(DECLARE_ENGINE_PARAMETER_SIGNATURE); void initTriggerDecoder(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void initTriggerDecoderLogger(Logging *sharedLogger); void initTriggerDecoderLogger(Logging *sharedLogger);
bool isTriggerDecoderError(void); bool isTriggerDecoderError(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void calculateTriggerSynchPoint(TriggerWaveform *shape, TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX); void calculateTriggerSynchPoint(TriggerWaveform *shape, TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX);