rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
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)
 
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
 
void setShaftSynchronized (bool value)
 
bool getShaftSynchronized () const
 
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 = 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] = {}
 
- 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 198 of file trigger_decoder.h.

Constructor & Destructor Documentation

◆ PrimaryTriggerDecoder()

PrimaryTriggerDecoder::PrimaryTriggerDecoder ( const char name)

Definition at line 102 of file trigger_decoder.cpp.

103 : TriggerDecoderBase(p_name)
104{
105}

Member Function Documentation

◆ hasSynchronizedPhase()

bool PrimaryTriggerDecoder::hasSynchronizedPhase ( ) const
inline

Definition at line 216 of file trigger_decoder.h.

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 260 of file trigger_decoder.cpp.

260 {
261 warning(ObdCode::CUSTOM_PRIMARY_NOT_ENOUGH_TEETH, "primary trigger error: not enough teeth between sync points: expected %d/%d got %d/%d",
262 getTriggerCentral()->triggerShape.getExpectedEventCount(TriggerWheel::T_PRIMARY),
263 getTriggerCentral()->triggerShape.getExpectedEventCount(TriggerWheel::T_SECONDARY),
266}
current_cycle_state_s currentCycle
TriggerCentral * getTriggerCentral()
Definition engine.cpp:590
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 268 of file trigger_decoder.cpp.

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

◆ onTriggerError()

void PrimaryTriggerDecoder::onTriggerError ( )
overridevirtual

Reimplemented from TriggerDecoderBase.

Definition at line 245 of file trigger_decoder.cpp.

245 {
246 // On trigger error, we've lost full sync
248
249 // Ignore the warning that engine is never null - it might be in unit tests
250 #pragma GCC diagnostic push
251 #pragma GCC diagnostic ignored "-Waddress"
252 if (engine) {
253 // Instant RPM data is now also probably trash, discard it
256 }
257 #pragma GCC diagnostic pop
258}
TriggerCentral triggerCentral
Definition engine.h:318
RpmCalculator rpmCalculator
Definition engine.h:306
InstantRpmCalculator instantRpm
static EngineAccessor engine
Definition engine.h:413
Here is the call graph for this function:

◆ resetHasFullSync()

void PrimaryTriggerDecoder::resetHasFullSync ( )
inline

Definition at line 203 of file trigger_decoder.h.

203 {
204 // If this trigger doesn't need disambiguation, we already have phase sync
206 }

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 183 of file trigger_decoder.cpp.

183 {
185
187}
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 220 of file trigger_decoder.h.

220 {
221 m_needsDisambiguation = needsDisambiguation;
222
224 }

Referenced by TriggerCentral::applyShapesConfiguration().

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 216 of file trigger_decoder.cpp.

216 {
217 efiAssert(ObdCode::OBD_PCM_Processor_Fault, divider > 1, "syncEnginePhase divider", false);
218 efiAssert(ObdCode::OBD_PCM_Processor_Fault, remainder < divider, "syncEnginePhase remainder", false);
219 angle_t totalShift = 0;
220 while (getSynchronizationCounter() % divider != remainder) {
221 /**
222 * we are here if we've detected the cam sensor within the wrong crank phase
223 * let's increase the trigger event counter, that would adjust the state of
224 * virtual crank-based trigger
225 */
227 totalShift += engineCycle / divider;
228 }
229
230 // Allow injection/ignition to happen, we've now fully sync'd the crank based on new cam information
232
233 if (totalShift > 0) {
236 }
237
238 return totalShift;
239}
void incrementShaftSynchronizationCounter()
int getSynchronizationCounter() const
@ OBD_PCM_Processor_Fault
float angle_t
void onTransitionEvent(TransitionEvent event)

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 233 of file trigger_decoder.h.

Referenced by resetHasFullSync(), and setNeedsDisambiguation().


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