rusEFI
The most advanced open source ECU
Public Member Functions | Private Attributes
PrimaryTriggerDecoder Class Reference

#include <trigger_decoder.h>

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

Public Member Functions

 PrimaryTriggerDecoder (const char *name)
 
void resetState () override
 
void resetHasFullSync ()
 
angle_t syncEnginePhase (int divider, int remainder, angle_t engineCycle)
 
bool hasSynchronizedPhase () const
 
void setNeedsDisambiguation (bool needsDisambiguation)
 
void onTriggerError () override
 
void onNotEnoughTeeth (int actual, int expected) override
 
void onTooManyTeeth (int actual, int expected) override
 
- Public Member Functions inherited from TriggerDecoderBase
 TriggerDecoderBase (const char *name)
 
int getCurrentIndex () const
 
int getCrankSynchronizationCounter () 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. More...
 
void onShaftSynchronization (bool wasSynchronized, const efitick_t nowNt, const TriggerWaveform &triggerShape)
 
bool isValidIndex (const TriggerWaveform &triggerShape) const
 
void setShaftSynchronized (bool value)
 
bool getShaftSynchronized ()
 
uint32_t findTriggerZeroEventIndex (TriggerWaveform &shape, const TriggerConfiguration &triggerConfiguration)
 
bool someSortOfTriggerError () const
 

Private Attributes

bool m_needsDisambiguation = false
 

Additional Inherited Members

- Data Fields inherited from TriggerDecoderBase
float gapRatio [PWM_PHASE_MAX_COUNT *6]
 
bool shaft_is_synchronized
 
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 crankSynchronizationCounter = (uint32_t)0
 
float vvtSyncGapRatio = (float)0
 
uint32_t vvtToothDurations0 = (uint32_t)0
 
float vvtCurrentPosition = (float)0
 
float vvtToothPosition [4]
 
float triggerSyncGapRatio = (float)0
 
uint8_t triggerStateIndex = (uint8_t)0
 
uint8_t vvtStateIndex = (uint8_t)0
 
uint8_t alignmentFill_at_38 [2]
 
- Data Fields inherited from trigger_state_primary_s
uint8_t camResyncCounter = (uint8_t)0
 
uint8_t alignmentFill_at_1 [3]
 
bool m_hasSynchronizedPhase: 1 {}
 
bool unusedBit_3_1: 1 {}
 
bool unusedBit_3_2: 1 {}
 
bool unusedBit_3_3: 1 {}
 
bool unusedBit_3_4: 1 {}
 
bool unusedBit_3_5: 1 {}
 
bool unusedBit_3_6: 1 {}
 
bool unusedBit_3_7: 1 {}
 
bool unusedBit_3_8: 1 {}
 
bool unusedBit_3_9: 1 {}
 
bool unusedBit_3_10: 1 {}
 
bool unusedBit_3_11: 1 {}
 
bool unusedBit_3_12: 1 {}
 
bool unusedBit_3_13: 1 {}
 
bool unusedBit_3_14: 1 {}
 
bool unusedBit_3_15: 1 {}
 
bool unusedBit_3_16: 1 {}
 
bool unusedBit_3_17: 1 {}
 
bool unusedBit_3_18: 1 {}
 
bool unusedBit_3_19: 1 {}
 
bool unusedBit_3_20: 1 {}
 
bool unusedBit_3_21: 1 {}
 
bool unusedBit_3_22: 1 {}
 
bool unusedBit_3_23: 1 {}
 
bool unusedBit_3_24: 1 {}
 
bool unusedBit_3_25: 1 {}
 
bool unusedBit_3_26: 1 {}
 
bool unusedBit_3_27: 1 {}
 
bool unusedBit_3_28: 1 {}
 
bool unusedBit_3_29: 1 {}
 
bool unusedBit_3_30: 1 {}
 
bool unusedBit_3_31: 1 {}
 

Detailed Description

the reason for sub-class is simply to save RAM but not having statistics in the trigger initialization instance

Definition at line 190 of file trigger_decoder.h.

Constructor & Destructor Documentation

◆ PrimaryTriggerDecoder()

PrimaryTriggerDecoder::PrimaryTriggerDecoder ( const char *  name)

Definition at line 94 of file trigger_decoder.cpp.

95  : TriggerDecoderBase(p_name)
96 {
97 }
TriggerDecoderBase(const char *name)

Member Function Documentation

◆ hasSynchronizedPhase()

bool PrimaryTriggerDecoder::hasSynchronizedPhase ( ) const
inline

Definition at line 208 of file trigger_decoder.h.

208  {
209  return m_hasSynchronizedPhase;
210  }

Referenced by getCurrentIgnitionMode(), handleVvtCamSignal(), and LimpManager::updateState().

Here is the caller graph for this function:

◆ onNotEnoughTeeth()

void PrimaryTriggerDecoder::onNotEnoughTeeth ( int  actual,
int  expected 
)
overridevirtual

Reimplemented from TriggerDecoderBase.

Definition at line 251 of file trigger_decoder.cpp.

251  {
252  warning(ObdCode::CUSTOM_PRIMARY_NOT_ENOUGH_TEETH, "primary trigger error: not enough teeth between sync points: expected %d/%d got %d/%d",
253  getTriggerCentral()->triggerShape.getExpectedEventCount(TriggerWheel::T_PRIMARY),
254  getTriggerCentral()->triggerShape.getExpectedEventCount(TriggerWheel::T_SECONDARY),
257 }
current_cycle_state_s currentCycle
TriggerCentral * getTriggerCentral()
Definition: engine.cpp:589
bool warning(ObdCode code, const char *fmt,...)
@ CUSTOM_PRIMARY_NOT_ENOUGH_TEETH
size_t eventCount[PWM_PHASE_MAX_WAVE_PER_PWM]
Here is the call graph for this function:

◆ onTooManyTeeth()

void PrimaryTriggerDecoder::onTooManyTeeth ( int  actual,
int  expected 
)
overridevirtual

Reimplemented from TriggerDecoderBase.

Definition at line 259 of file trigger_decoder.cpp.

259  {
260  warning(ObdCode::CUSTOM_PRIMARY_TOO_MANY_TEETH, "primary trigger error: too many teeth between sync points: expected %d/%d got %d/%d",
261  getTriggerCentral()->triggerShape.getExpectedEventCount(TriggerWheel::T_PRIMARY),
262  getTriggerCentral()->triggerShape.getExpectedEventCount(TriggerWheel::T_SECONDARY),
265 }
@ CUSTOM_PRIMARY_TOO_MANY_TEETH
Here is the call graph for this function:

◆ onTriggerError()

void PrimaryTriggerDecoder::onTriggerError ( )
overridevirtual

Reimplemented from TriggerDecoderBase.

Definition at line 236 of file trigger_decoder.cpp.

236  {
237  // On trigger error, we've lost full sync
239 
240  // Ignore the warning that engine is never null - it might be in unit tests
241  #pragma GCC diagnostic push
242  #pragma GCC diagnostic ignored "-Waddress"
243  if (engine) {
244  // Instant RPM data is now also probably trash, discard it
247  }
248  #pragma GCC diagnostic pop
249 }
TriggerCentral triggerCentral
Definition: engine.h:285
RpmCalculator rpmCalculator
Definition: engine.h:272
InstantRpmCalculator instantRpm
Engine * engine
Here is the call graph for this function:

◆ resetHasFullSync()

void PrimaryTriggerDecoder::resetHasFullSync ( )
inline

Definition at line 195 of file trigger_decoder.h.

195  {
196  // If this trigger doesn't need disambiguation, we already have phase sync
198  }

Referenced by onTriggerError(), resetState(), and setNeedsDisambiguation().

Here is the caller graph for this function:

◆ resetState()

void PrimaryTriggerDecoder::resetState ( )
overridevirtual

Reimplemented from TriggerDecoderBase.

Definition at line 175 of file trigger_decoder.cpp.

175  {
177 
179 }
virtual void resetState()

Referenced by Engine::OnTriggerSynchronizationLost(), and TriggerCentral::TriggerCentral().

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

◆ setNeedsDisambiguation()

void PrimaryTriggerDecoder::setNeedsDisambiguation ( bool  needsDisambiguation)
inline

Definition at line 212 of file trigger_decoder.h.

212  {
213  m_needsDisambiguation = needsDisambiguation;
214 
216  }

Referenced by TriggerCentral::updateWaveform().

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

◆ syncEnginePhase()

angle_t PrimaryTriggerDecoder::syncEnginePhase ( int  divider,
int  remainder,
angle_t  engineCycle 
)

returns zero if we were lucky to have correct engine phase, otherwise angle of engine phase correction which was applied.

we are here if we've detected the cam sensor within the wrong crank phase let's increase the trigger event counter, that would adjust the state of virtual crank-based trigger

Definition at line 208 of file trigger_decoder.cpp.

208  {
209  efiAssert(ObdCode::OBD_PCM_Processor_Fault, divider > 1, "syncEnginePhase divider", false);
210  efiAssert(ObdCode::OBD_PCM_Processor_Fault, remainder < divider, "syncEnginePhase remainder", false);
211  angle_t totalShift = 0;
212  while (getCrankSynchronizationCounter() % divider != remainder) {
213  /**
214  * we are here if we've detected the cam sensor within the wrong crank phase
215  * let's increase the trigger event counter, that would adjust the state of
216  * virtual crank-based trigger
217  */
219  totalShift += engineCycle / divider;
220  }
221 
222  // Allow injection/ignition to happen, we've now fully sync'd the crank based on new cam information
223  m_hasSynchronizedPhase = true;
224 
225  if (totalShift > 0) {
227  }
228 
229  return totalShift;
230 }
void incrementShaftSynchronizationCounter()
int getCrankSynchronizationCounter() const
@ OBD_PCM_Processor_Fault
float angle_t
Definition: rusefi_types.h:58

Referenced by TriggerCentral::syncEnginePhaseAndReport().

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

Field Documentation

◆ m_needsDisambiguation

bool PrimaryTriggerDecoder::m_needsDisambiguation = false
private

Definition at line 225 of file trigger_decoder.h.

Referenced by resetHasFullSync(), and setNeedsDisambiguation().


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