rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Protected Member Functions | Private Member Functions | Private Attributes
TriggerDecoderBase Class Reference

#include <trigger_decoder.h>

Inheritance diagram for TriggerDecoderBase:
Inheritance graph
[legend]
Collaboration diagram for TriggerDecoderBase:
Collaboration graph
[legend]

Public Member Functions

 TriggerDecoderBase (const char *name)
 
void printGaps (const char *prefix, const TriggerConfiguration &triggerConfiguration, const TriggerWaveform &triggerShape)
 
int getCurrentIndex () const
 
int getSynchronizationCounter () const
 
void incrementShaftSynchronizationCounter ()
 
int64_t getTotalEventCounter () const
 
expected< TriggerDecodeResultdecodeTriggerEvent (const char *msg, const TriggerWaveform &triggerShape, TriggerStateListener *triggerStateListener, const TriggerConfiguration &triggerConfiguration, const trigger_event_e signal, const efitick_t nowNt)
 Trigger decoding happens here VR falls are filtered out and some VR noise detection happens prior to invoking this method, for Hall this method is invoked every time we have a fall or rise on one of the trigger sensors. This method changes the state of trigger_state_s data structure according to the trigger event.
 
void onShaftSynchronization (bool wasSynchronized, const efitick_t nowNt, const TriggerWaveform &triggerShape)
 
bool isValidIndex (const TriggerWaveform &triggerShape) const
 
virtual void resetState ()
 
void setShaftSynchronized (bool value)
 
bool getShaftSynchronized () const
 
uint32_t findTriggerZeroEventIndex (TriggerWaveform &shape, const TriggerConfiguration &triggerConfiguration)
 
bool someSortOfTriggerError () const
 

Data Fields

float gapRatio [PWM_PHASE_MAX_COUNT *6]
 
bool shaft_is_synchronized = false
 
efitick_t mostRecentSyncTime
 
Timer previousEventTimer
 
uint32_t toothDurations [GAP_TRACKING_LENGTH+1]
 
efitick_t toothed_previous_time
 
current_cycle_state_s currentCycle
 
const char *const name
 
uint32_t totalTriggerErrorCounter
 
uint32_t orderingErrorCounter
 
efitick_t startOfCycleNt
 
- Data Fields inherited from trigger_state_s
uint32_t synchronizationCounter = (uint32_t)0
 
uint32_t vvtToothDurations0 = (uint32_t)0
 
float vvtCurrentPosition = (float)0
 
float vvtToothPosition [4] = {}
 
float triggerSyncGapRatio = (float)0
 
uint8_t triggerStateIndex = (uint8_t)0
 
int8_t triggerCountersError = (int8_t)0
 
uint8_t alignmentFill_at_34 [2] = {}
 

Protected Member Functions

virtual void onTriggerError ()
 
virtual void onNotEnoughTeeth (int, int)
 
virtual void onTooManyTeeth (int, int)
 

Private Member Functions

void setTriggerErrorState (int errorIncrement=1)
 
void resetCurrentCycleState ()
 
bool isSyncPoint (const TriggerWaveform &triggerShape, trigger_type_e triggerType) const
 
int getEventCountersError (const TriggerWaveform &triggerShape) const
 

Private Attributes

trigger_event_e prevSignal
 
int64_t totalEventCountBase
 
bool isFirstEvent
 
Timer m_timeSinceDecodeError
 

Detailed Description

See also
TriggerWaveform for trigger wheel shape definition

Definition at line 85 of file trigger_decoder.h.

Constructor & Destructor Documentation

◆ TriggerDecoderBase()

TriggerDecoderBase::TriggerDecoderBase ( const char name)

Definition at line 40 of file trigger_decoder.cpp.

41 : name(p_name)
42{
44}
virtual void resetState()
const char *const name
Here is the call graph for this function:

Member Function Documentation

◆ decodeTriggerEvent()

expected< TriggerDecodeResult > TriggerDecoderBase::decodeTriggerEvent ( const char msg,
const TriggerWaveform triggerShape,
TriggerStateListener triggerStateListener,
const TriggerConfiguration triggerConfiguration,
const trigger_event_e  signal,
const efitick_t  nowNt 
)

Trigger decoding happens here VR falls are filtered out and some VR noise detection happens prior to invoking this method, for Hall this method is invoked every time we have a fall or rise on one of the trigger sensors. This method changes the state of trigger_state_s data structure according to the trigger event.

Parameters
signaltype of event which just happened
nowNtcurrent time

We are here if there is a time gap between now and previous shaft event - that means the engine is not running. That means we have lost synchronization since the engine is not running :)

For performance reasons, we want to work with 32 bit values. If there has been more then 10 seconds since previous trigger event we do not really care.

todo: technically we can afford detailed logging even with 60/2 as long as low RPM todo: figure out exact threshold as a function of RPM and tooth count? Open question what is 'triggerShape.getSize()' for 60/2 is it 58 or 58*2 or 58*4?

We are here in case of a wheel without synchronization - we just need to count events, synchronization point simply happens once we have the right number of events

in case of noise the counter could be above the expected number of events, that's why 'more or equals' and not just 'equals'

Definition at line 433 of file trigger_decoder.cpp.

439 {
441
442#if EFI_PROD_CODE
444#endif
445
446 if (previousEventTimer.getElapsedSecondsAndReset(nowNt) > 1) {
447 /**
448 * We are here if there is a time gap between now and previous shaft event - that means the engine is not running.
449 * That means we have lost synchronization since the engine is not running :)
450 */
452 if (triggerStateListener) {
453 triggerStateListener->OnTriggerSynchronizationLost();
454 }
455 }
456
457 bool useOnlyRisingEdgeForTrigger = triggerShape.useOnlyRisingEdges;
458
459 efiAssert(ObdCode::CUSTOM_TRIGGER_UNEXPECTED, signal <= SHAFT_SECONDARY_RISING, "unexpected signal", unexpected);
460
461 TriggerWheel triggerWheel = eventIndex[signal];
462 TriggerValue type = eventType[signal];
463
464 // Check that we didn't get the same edge twice in a row - that should be impossible
465 if (!useOnlyRisingEdgeForTrigger && prevSignal == signal) {
467 }
468
469 prevSignal = signal;
470
471 currentCycle.eventCount[(int)triggerWheel]++;
472
473 if (toothed_previous_time > nowNt) {
474 firmwareError(ObdCode::CUSTOM_OBD_93, "[%s] toothed_previous_time after nowNt prev=%lu now=%lu", msg, (uint32_t)toothed_previous_time, (uint32_t)nowNt);
475 }
476
477 efidur_t currentDurationLong = isFirstEvent ? 0 : (nowNt - toothed_previous_time);
478
479 /**
480 * For performance reasons, we want to work with 32 bit values. If there has been more then
481 * 10 seconds since previous trigger event we do not really care.
482 */
483 toothDurations[0] =
484 currentDurationLong > 10 * NT_PER_SECOND ? 10 * NT_PER_SECOND : currentDurationLong;
485
486 if (!shouldConsiderEdge(triggerShape, triggerWheel, type)) {
487#if EFI_UNIT_TEST
488 if (printTriggerTrace) {
489 printf("%s isLessImportant %s now=%d index=%d\r\n",
490 getTrigger_type_e(triggerConfiguration.TriggerType.type),
491 getTrigger_event_e(signal),
492 (int)nowNt,
494 }
495#endif /* EFI_UNIT_TEST */
496
497 // For less important events we simply increment the index.
498 nextTriggerEvent();
499 } else {
500#if !EFI_PROD_CODE
501 if (printTriggerTrace) {
502 printf("%s event %s %lld\r\n",
503 getTrigger_type_e(triggerConfiguration.TriggerType.type),
504 getTrigger_event_e(signal),
505 nowNt);
506 printf("decodeTriggerEvent ratio %.2f: current=%d previous=%d\r\n", 1.0 * toothDurations[0] / toothDurations[1],
508 }
509#endif
510
511 isFirstEvent = false;
512 bool isSynchronizationPoint;
513 bool wasSynchronized = getShaftSynchronized();
514
515 if (triggerShape.isSynchronizationNeeded) {
517
518 if (wasSynchronized && triggerSyncGapRatio > NOISE_RATIO_THRESHOLD) {
520 }
521
522 isSynchronizationPoint = isSyncPoint(triggerShape, triggerConfiguration.TriggerType.type);
523 if (isSynchronizationPoint) {
525 }
526
527 /**
528 * todo: technically we can afford detailed logging even with 60/2 as long as low RPM
529 * todo: figure out exact threshold as a function of RPM and tooth count?
530 * Open question what is 'triggerShape.getSize()' for 60/2 is it 58 or 58*2 or 58*4?
531 */
532 bool silentTriggerError = triggerShape.getSize() > 40 && engineConfiguration->silentTriggerError;
533
534#if EFI_PROD_CODE || EFI_SIMULATOR
535 bool verbose = getTriggerCentral()->isEngineSnifferEnabled && triggerConfiguration.VerboseTriggerSynchDetails;
536
537 if (verbose || (someSortOfTriggerError() && !silentTriggerError)) {
538 const char * prefix = verbose ? "[vrb]" : "[err]";
539 printGaps(prefix, triggerConfiguration, triggerShape);
540 }
541#else
542 if (printTriggerTrace) {
543 for (int i = 0;i<triggerShape.gapTrackingLength;i++) {
544 float gap = 1.0 * toothDurations[i] / toothDurations[i + 1];
545 printf("%sindex=%d: gap=%.2f expected from %.2f to %.2f error=%s\r\n",
546 triggerConfiguration.PrintPrefix,
547 i,
548 gap,
549 triggerShape.synchronizationRatioFrom[i],
550 triggerShape.synchronizationRatioTo[i],
552 }
553 }
554#endif /* EFI_PROD_CODE */
555 } else {
556 /**
557 * We are here in case of a wheel without synchronization - we just need to count events,
558 * synchronization point simply happens once we have the right number of events
559 *
560 * in case of noise the counter could be above the expected number of events, that's why 'more or equals' and not just 'equals'
561 */
562
563 unsigned int endOfCycleIndex = triggerShape.getSize() - (useOnlyRisingEdgeForTrigger ? 2 : 1);
564
565 isSynchronizationPoint = !getShaftSynchronized() || (currentCycle.current_index >= endOfCycleIndex);
566
567#if EFI_UNIT_TEST
568 if (printTriggerTrace) {
569 printf("decodeTriggerEvent sync=%d isSynchronizationPoint=%d index=%d size=%d\r\n",
571 isSynchronizationPoint,
573 triggerShape.getSize());
574 }
575#endif /* EFI_UNIT_TEST */
576 }
577#if EFI_UNIT_TEST
578 if (printTriggerTrace) {
579 printf("decodeTriggerEvent gap %s isSynchronizationPoint=%d index=%d %s\r\n",
580 getTrigger_type_e(triggerConfiguration.TriggerType.type),
581 isSynchronizationPoint, currentCycle.current_index,
582 getTrigger_event_e(signal));
583 }
584#endif /* EFI_UNIT_TEST */
585
586 if (isSynchronizationPoint) {
588 bool isDecodingError = isTriggerCounterError(triggerCountersError);
589
590 if (triggerStateListener) {
591 triggerStateListener->OnTriggerSynchronization(wasSynchronized, isDecodingError);
592 }
593
594 // If we got a sync point, but the wrong number of events since the last sync point
595 // One of two things has happened:
596 // - We missed a tooth, and this is the real sync point
597 // - Due to some mistake in timing, we found what looks like a sync point but actually isn't
598 // In either case, we should wait for another sync point before doing anything to try and run an engine,
599 // so we clear the synchronized flag.
600 if (wasSynchronized && isDecodingError) {
603
604 // Something wrong, no longer synchronized
606
607 // This is a decoding error
609 printGaps("newerr", triggerConfiguration, triggerShape);
610 } else {
611 // If this was the first sync point OR no decode error, we're synchronized!
613 }
614
615 // this call would update duty cycle values
616 nextTriggerEvent();
617
618 onShaftSynchronization(wasSynchronized, nowNt, triggerShape);
619 } else { /* if (!isSynchronizationPoint) */
620 nextTriggerEvent();
621 }
622
623 for (int i = triggerShape.gapTrackingLength; i > 0; i--) {
624 toothDurations[i] = toothDurations[i - 1];
625 }
626
627 toothed_previous_time = nowNt;
628
629#if EFI_UNIT_TEST
630 if (wasSynchronized) {
631 int uiGapIndex = (currentCycle.current_index) % triggerShape.getLength();
632 gapRatio[uiGapIndex] = triggerSyncGapRatio;
633 }
634#endif // EFI_UNIT_TEST
635 }
636
637 if (getShaftSynchronized() && !isValidIndex(triggerShape)) {
638 // We've had too many events since the last sync point, we should have seen a sync point by now.
639 // This is a trigger error.
640
641 // let's not show a warning if we are just starting to spin
645 }
646
648
650
651 return unexpected;
652 } else if (!isValidIndex(triggerShape)) {
653#if EFI_UNIT_TEST
655#endif // EFI_UNIT_TEST
656 }
657
659
660 // Needed for early instant-RPM detection
661 TriggerStateListener * l = triggerStateListener;
662 while (l) {
664 l = l->nextListener();
665 }
666
667 if (getShaftSynchronized()) {
669 } else {
670 return unexpected;
671 }
672}
const char * getTrigger_type_e(trigger_type_e value)
OutputPin debugTriggerSync
Definition efi_gpio.h:110
void toggle()
Definition efi_gpio.cpp:572
static float getOrZero(SensorType type)
Definition sensor.h:87
const char *const PrintPrefix
trigger_config_s TriggerType
void printGaps(const char *prefix, const TriggerConfiguration &triggerConfiguration, const TriggerWaveform &triggerShape)
virtual void onTriggerError()
float gapRatio[PWM_PHASE_MAX_COUNT *6]
void onShaftSynchronization(bool wasSynchronized, const efitick_t nowNt, const TriggerWaveform &triggerShape)
virtual void onNotEnoughTeeth(int, int)
virtual void onTooManyTeeth(int, int)
efitick_t toothed_previous_time
int getEventCountersError(const TriggerWaveform &triggerShape) const
void setShaftSynchronized(bool value)
trigger_event_e prevSignal
bool isValidIndex(const TriggerWaveform &triggerShape) const
current_cycle_state_s currentCycle
bool someSortOfTriggerError() const
void setTriggerErrorState(int errorIncrement=1)
uint32_t toothDurations[GAP_TRACKING_LENGTH+1]
bool isSyncPoint(const TriggerWaveform &triggerShape, trigger_type_e triggerType) const
bool getShaftSynchronized() const
float synchronizationRatioFrom[GAP_TRACKING_LENGTH]
size_t getLength() const
float synchronizationRatioTo[GAP_TRACKING_LENGTH]
size_t getSize() const
EnginePins enginePins
Definition efi_gpio.cpp:24
const char * boolToString(bool value)
Definition efilib.cpp:19
TriggerCentral * getTriggerCentral()
Definition engine.cpp:592
static constexpr engine_configuration_s * engineConfiguration
void firmwareError(ObdCode code, const char *fmt,...)
@ CUSTOM_OBD_93
@ CUSTOM_TRIGGER_UNEXPECTED
@ DecodeTriggerEvent
TriggerWheel
efitick_t efidur_t
@ SHAFT_SECONDARY_RISING
TriggerValue
virtual void OnTriggerStateProperState(efitick_t nowNt, size_t triggerStateIndex)=0
virtual void OnTriggerSynchronization(bool wasSynchronized, bool isDecodingError)=0
virtual void OnTriggerSynchronizationLost()=0
virtual TriggerStateListener * nextListener()=0
size_t eventCount[PWM_PHASE_MAX_WAVE_PER_PWM]
static bool shouldConsiderEdge(const TriggerWaveform &triggerShape, TriggerWheel triggerWheel, TriggerValue edge)
PUBLIC_API_WEAK bool isTriggerCounterError(int8_t triggerCountersError)
static TriggerValue eventType[4]
int tooManyTeethCounter
bool printTriggerTrace
static TriggerWheel eventIndex[4]
const char * getTrigger_event_e(trigger_event_e value)
printf("\n")

Referenced by TriggerCentral::handleShaftSignal(), and handleVvtCamSignal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findTriggerZeroEventIndex()

uint32_t TriggerDecoderBase::findTriggerZeroEventIndex ( TriggerWaveform shape,
const TriggerConfiguration triggerConfiguration 
)

Trigger shape is defined in a way which is convenient for trigger shape definition On the other hand, trigger decoder indexing begins from synchronization event.

This function finds the index of synchronization event within TriggerWaveform

Definition at line 732 of file trigger_decoder.cpp.

734 {
735#if EFI_PROD_CODE
736 efiAssert(ObdCode::CUSTOM_ERR_ASSERT, hasLotsOfRemainingStack(), "findPos", -1);
737#endif
738
739
740 resetState();
741
742 if (shape.shapeDefinitionError) {
743 return 0;
744 }
745
746 expected<uint32_t> syncIndex = TriggerStimulatorHelper::findTriggerSyncPoint(shape,
747 triggerConfiguration,
748 *this);
749 if (!syncIndex) {
750 return EFI_ERROR_CODE;
751 }
752
753 // Assert that we found the sync point on the very first revolution
754 efiAssert(ObdCode::CUSTOM_ERR_ASSERT, getSynchronizationCounter() == 0, "findZero_revCounter", EFI_ERROR_CODE);
755
756#if EFI_UNIT_TEST
757 if (printTriggerDebug) {
758 printf("findTriggerZeroEventIndex: syncIndex located %lu!\r\n", syncIndex.Value);
759 }
760#endif /* EFI_UNIT_TEST */
761
763 syncIndex.Value, *this, shape);
764
765 return syncIndex.Value % shape.getSize();
766}
int getSynchronizationCounter() const
static expected< uint32_t > findTriggerSyncPoint(TriggerWaveform &shape, const TriggerConfiguration &triggerConfiguration, TriggerDecoderBase &state)
static void assertSyncPosition(const TriggerConfiguration &triggerConfiguration, const uint32_t index, TriggerDecoderBase &state, TriggerWaveform &shape)
@ CUSTOM_ERR_ASSERT
bool printTriggerDebug
Here is the call graph for this function:

◆ getCurrentIndex()

int TriggerDecoderBase::getCurrentIndex ( ) const

current trigger processing index, between zero and size

Definition at line 221 of file trigger_decoder.cpp.

221 {
223}

◆ getEventCountersError()

int TriggerDecoderBase::getEventCountersError ( const TriggerWaveform triggerShape) const
private

Definition at line 325 of file trigger_decoder.cpp.

325 {
326 // We can check if things are fine by comparing the number of events in a cycle with the expected number of event.
327 int countersError = 0;
328 for (int i = 0;i < PWM_PHASE_MAX_WAVE_PER_PWM;i++) {
329 countersError = currentCycle.eventCount[i] - triggerShape.getExpectedEventCount((TriggerWheel)i);
330 if (countersError != 0) {
331 break;
332 }
333 }
334
335#if EFI_DETAILED_LOGGING
336 printf("getEventCountersError: isDecodingError=%d\n", (countersError != 0));
337 if (countersError != 0) {
338 for (int i = 0;i < PWM_PHASE_MAX_WAVE_PER_PWM;i++) {
339 printf(" count: cur=%d exp=%d\n", currentCycle.eventCount[i], triggerShape.getExpectedEventCount((TriggerWheel)i));
340 }
341 }
342#endif /* EFI_UNIT_TEST */
343
344 return countersError;
345}
size_t getExpectedEventCount(TriggerWheel channelIndex) const

Referenced by decodeTriggerEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getShaftSynchronized()

bool TriggerDecoderBase::getShaftSynchronized ( ) const

Definition at line 46 of file trigger_decoder.cpp.

46 {
48}

Referenced by decodeTriggerEvent(), handleVvtCamSignal(), TriggerNoiseFilter::noiseFilter(), SetNextCompositeEntry(), and RpmCalculator::setSpinningUp().

Here is the caller graph for this function:

◆ getSynchronizationCounter()

int TriggerDecoderBase::getSynchronizationCounter ( ) const

◆ getTotalEventCounter()

int64_t TriggerDecoderBase::getTotalEventCounter ( ) const

Definition at line 184 of file trigger_decoder.cpp.

Referenced by updateDevConsoleState().

Here is the caller graph for this function:

◆ incrementShaftSynchronizationCounter()

void TriggerDecoderBase::incrementShaftSynchronizationCounter ( )

this is important for crank-based virtual trigger and VVT magic

Definition at line 250 of file trigger_decoder.cpp.

250 {
252}

Referenced by onShaftSynchronization(), and PrimaryTriggerDecoder::syncEnginePhase().

Here is the caller graph for this function:

◆ isSyncPoint()

bool TriggerDecoderBase::isSyncPoint ( const TriggerWaveform triggerShape,
trigger_type_e  triggerType 
) const
private

Definition at line 674 of file trigger_decoder.cpp.

674 {
675 // Miata NB needs a special decoder.
676 // The problem is that the crank wheel only has 4 teeth, also symmetrical, so the pattern
677 // is long-short-long-short for one crank rotation.
678 // A quick acceleration can result in two successive "short gaps", so we see
679 // long-short-short-short-long instead of the correct long-short-long-short-long
680 // This logic expands the lower bound on a "long" tooth, then compares the last
681 // tooth to the current one.
682
683 // Instead of detecting short/long, this logic first checks for "maybe short" and "maybe long",
684 // then simply tests longer vs. shorter instead of absolute value.
686 auto secondGap = (float)toothDurations[1] / toothDurations[2];
687
688 bool currentGapOk = isInRange(triggerShape.synchronizationRatioFrom[0], (float)triggerSyncGapRatio, triggerShape.synchronizationRatioTo[0]);
689 bool secondGapOk = isInRange(triggerShape.synchronizationRatioFrom[1], secondGap, triggerShape.synchronizationRatioTo[1]);
690
691 // One or both teeth was impossible range, this is not the sync point
692 if (!currentGapOk || !secondGapOk) {
693 return false;
694 }
695
696 // If both teeth are in the range of possibility, return whether this gap is
697 // shorter than the last or not. If it is, this is the sync point.
698 return triggerSyncGapRatio < secondGap;
699 }
700
701 for (int i = 0; i < triggerShape.gapTrackingLength; i++) {
702 auto from = triggerShape.synchronizationRatioFrom[i];
703 auto to = triggerShape.synchronizationRatioTo[i];
704
705 if (std::isnan(from)) {
706 // don't check this gap, skip it
707 continue;
708 }
709
710 // This is transformed to avoid a division and use a cheaper multiply instead
711 // toothDurations[i] / toothDurations[i+1] > from
712 // is an equivalent comparison to
713 // toothDurations[i] > toothDurations[i+1] * from
714 bool isGapCondition =
715 (toothDurations[i] > toothDurations[i + 1] * from
716 && toothDurations[i] < toothDurations[i + 1] * to);
717
718 if (!isGapCondition) {
719 return false;
720 }
721 }
722
723 return true;
724}
bool isInRange(T min, T val, T max)
Definition efilib.h:82
triggerType

Referenced by decodeTriggerEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValidIndex()

bool TriggerDecoderBase::isValidIndex ( const TriggerWaveform triggerShape) const

Definition at line 199 of file trigger_decoder.cpp.

199 {
200 return currentCycle.current_index < triggerShape.getSize();
201}

Referenced by decodeTriggerEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onNotEnoughTeeth()

virtual void TriggerDecoderBase::onNotEnoughTeeth ( int  ,
int   
)
inlineprotectedvirtual

Reimplemented in PrimaryTriggerDecoder, and VvtTriggerDecoder.

Definition at line 177 of file trigger_decoder.h.

177{ }

Referenced by decodeTriggerEvent().

Here is the caller graph for this function:

◆ onShaftSynchronization()

void TriggerDecoderBase::onShaftSynchronization ( bool  wasSynchronized,
const efitick_t  nowNt,
const TriggerWaveform triggerShape 
)

Definition at line 347 of file trigger_decoder.cpp.

350 {
351 startOfCycleNt = nowNt;
353
354 if (wasSynchronized) {
356 } else {
357 // We have just synchronized, this is the zeroth revolution
359 }
360
361 totalEventCountBase += triggerShape.getSize();
362
363#if EFI_UNIT_TEST
364 if (printTriggerDebug) {
365 printf("onShaftSynchronization index=%d %d\r\n",
368 }
369#endif /* EFI_UNIT_TEST */
370}
void incrementShaftSynchronizationCounter()

Referenced by decodeTriggerEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onTooManyTeeth()

virtual void TriggerDecoderBase::onTooManyTeeth ( int  ,
int   
)
inlineprotectedvirtual

Reimplemented in PrimaryTriggerDecoder, and VvtTriggerDecoder.

Definition at line 178 of file trigger_decoder.h.

178{ }

Referenced by decodeTriggerEvent().

Here is the caller graph for this function:

◆ onTriggerError()

virtual void TriggerDecoderBase::onTriggerError ( )
inlineprotectedvirtual

Reimplemented in PrimaryTriggerDecoder.

Definition at line 175 of file trigger_decoder.h.

175{ }

Referenced by decodeTriggerEvent().

Here is the caller graph for this function:

◆ printGaps()

void TriggerDecoderBase::printGaps ( const char prefix,
const TriggerConfiguration triggerConfiguration,
const TriggerWaveform triggerShape 
)

Definition at line 391 of file trigger_decoder.cpp.

393 {
394 for (int i = 0;i<triggerShape.gapTrackingLength;i++) {
395 float ratioFrom = triggerShape.synchronizationRatioFrom[i];
396 if (std::isnan(ratioFrom)) {
397 // we do not track gap at this depth
398 continue;
399 }
400
401 float gap = 1.0 * toothDurations[i] / toothDurations[i + 1];
402 if (std::isnan(gap)) {
403 efiPrintf("%s index=%d NaN gap, you have noise issues?", prefix, i);
404 } else {
405 float ratioTo = triggerShape.synchronizationRatioTo[i];
406
407 bool gapOk = isInRange(ratioFrom, gap, ratioTo);
408
409 efiPrintf("%s %srpm=%d time=%d eventIndex=%lu gapIndex=%d: %s gap=%.3f expected from %.3f to %.3f error=%s",
410 prefix,
411 triggerConfiguration.PrintPrefix,
413 /* cast is needed to make sure we do not put 64 bit value to stack*/ (int)getTimeNowS(),
415 i,
416 gapOk ? "Y" : "n",
417 gap,
418 ratioFrom,
419 ratioTo,
421 }
422 }
423}
efitimesec_t getTimeNowS()
Current system time in seconds (32 bits)
Definition efitime.cpp:42

Referenced by decodeTriggerEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetCurrentCycleState()

void TriggerDecoderBase::resetCurrentCycleState ( )
private

Definition at line 95 of file trigger_decoder.cpp.

95 {
98}
void setArrayValues(TValue(&array)[TSize], float value)

Referenced by onShaftSynchronization(), and resetState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetState()

void TriggerDecoderBase::resetState ( )
virtual

Reimplemented in PrimaryTriggerDecoder.

Definition at line 69 of file trigger_decoder.cpp.

Referenced by findTriggerZeroEventIndex(), Engine::OnTriggerSynchronizationLost(), PrimaryTriggerDecoder::resetState(), and TriggerDecoderBase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setShaftSynchronized()

void TriggerDecoderBase::setShaftSynchronized ( bool  value)

Definition at line 50 of file trigger_decoder.cpp.

50 {
51#if EFI_UNIT_TEST
52 if (value != shaft_is_synchronized) {
54 }
55#endif
56
57 if (value) {
59 // just got synchronized
61 }
62 } else {
63 // sync loss
65 }
67}
efitick_t getTimeNowNt()
Definition efitime.cpp:19
void LogTriggerSync(bool isSync, efitick_t timestamp)

Referenced by decodeTriggerEvent(), and resetState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTriggerErrorState()

void TriggerDecoderBase::setTriggerErrorState ( int  errorIncrement = 1)
private

Definition at line 89 of file trigger_decoder.cpp.

89 {
91 totalTriggerErrorCounter += errorIncrement;
93}
void onTransitionEvent(TransitionEvent event)

Referenced by decodeTriggerEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ someSortOfTriggerError()

bool TriggerDecoderBase::someSortOfTriggerError ( ) const
inline

Definition at line 166 of file trigger_decoder.h.

166 {
167 return !m_timeSinceDecodeError.hasElapsedSec(0.3);
168 }

Referenced by decodeTriggerEvent(), isTriggerErrorNow(), Engine::OnTriggerSynchronization(), and printGaps().

Here is the caller graph for this function:

Field Documentation

◆ currentCycle

current_cycle_state_s TriggerDecoderBase::currentCycle

◆ gapRatio

float TriggerDecoderBase::gapRatio[PWM_PHASE_MAX_COUNT *6]

used only for trigger export

Definition at line 107 of file trigger_decoder.h.

Referenced by decodeTriggerEvent().

◆ isFirstEvent

bool TriggerDecoderBase::isFirstEvent
private

Definition at line 190 of file trigger_decoder.h.

Referenced by decodeTriggerEvent(), and resetState().

◆ m_timeSinceDecodeError

Timer TriggerDecoderBase::m_timeSinceDecodeError
private

Definition at line 192 of file trigger_decoder.h.

Referenced by resetState(), setTriggerErrorState(), and someSortOfTriggerError().

◆ mostRecentSyncTime

efitick_t TriggerDecoderBase::mostRecentSyncTime

Definition at line 131 of file trigger_decoder.h.

Referenced by setShaftSynchronized().

◆ name

const char* const TriggerDecoderBase::name

◆ orderingErrorCounter

uint32_t TriggerDecoderBase::orderingErrorCounter

◆ previousEventTimer

Timer TriggerDecoderBase::previousEventTimer

Definition at line 133 of file trigger_decoder.h.

Referenced by decodeTriggerEvent().

◆ prevSignal

trigger_event_e TriggerDecoderBase::prevSignal
private

Definition at line 187 of file trigger_decoder.h.

Referenced by decodeTriggerEvent(), and resetState().

◆ shaft_is_synchronized

bool TriggerDecoderBase::shaft_is_synchronized = false

TRUE if we know where we are

Definition at line 130 of file trigger_decoder.h.

Referenced by getShaftSynchronized(), and setShaftSynchronized().

◆ startOfCycleNt

efitick_t TriggerDecoderBase::startOfCycleNt

this is start of real trigger cycle for virtual double trigger see timeAtVirtualZeroNt

Definition at line 159 of file trigger_decoder.h.

Referenced by onShaftSynchronization(), and resetState().

◆ toothDurations

uint32_t TriggerDecoderBase::toothDurations[GAP_TRACKING_LENGTH+1]

current duration at index zero and previous durations are following

Definition at line 138 of file trigger_decoder.h.

Referenced by decodeTriggerEvent(), handleVvtCamSignal(), isSyncPoint(), printGaps(), and resetState().

◆ toothed_previous_time

efitick_t TriggerDecoderBase::toothed_previous_time

Definition at line 140 of file trigger_decoder.h.

Referenced by decodeTriggerEvent(), and resetState().

◆ totalEventCountBase

int64_t TriggerDecoderBase::totalEventCountBase
private

Definition at line 188 of file trigger_decoder.h.

Referenced by getTotalEventCounter(), onShaftSynchronization(), and resetState().

◆ totalTriggerErrorCounter

uint32_t TriggerDecoderBase::totalTriggerErrorCounter

how many times since ECU reboot we had unexpected number of teeth in trigger cycle

Definition at line 148 of file trigger_decoder.h.

Referenced by canDashboardHaltech(), resetState(), setTriggerErrorState(), triggerInfo(), and updateTunerStudioState().


The documentation for this class was generated from the following files: