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

#include <prime_injection.h>

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

Public Member Functions

void onIgnitionStateChanged (bool ignitionOn) override
 
void onSlowCallback () override
 
floatms_t getPrimeDuration () const
 
void onPrimeStart ()
 
void onPrimeEnd ()
 
bool isPriming () const
 
- Public Member Functions inherited from EngineModule
virtual void onConfigurationChange (engine_configuration_s const *)
 
virtual void onFastCallback ()
 
virtual bool needsDelayedShutoff ()
 

Private Member Functions

uint32_t getKeyCycleCounter () const
 
void setKeyCycleCounter (uint32_t count)
 

Static Private Member Functions

static void onPrimeStartAdapter (PrimeController *instance)
 
static void onPrimeEndAdapter (PrimeController *instance)
 

Private Attributes

bool m_isPriming = false
 

Detailed Description

Definition at line 12 of file prime_injection.h.

Member Function Documentation

◆ getKeyCycleCounter()

uint32_t PrimeController::getKeyCycleCounter ( ) const
private

Definition at line 78 of file prime_injection.cpp.

78  {
79 #if EFI_BACKUP_SRAM
81 #else // not EFI_BACKUP_SRAM
82  return 0;
83 #endif // EFI_BACKUP_SRAM
84 }
uint32_t backupRamLoad(backup_ram_e idx)
Definition: backup_ram.cpp:43

Referenced by onIgnitionStateChanged().

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

◆ getPrimeDuration()

floatms_t PrimeController::getPrimeDuration ( ) const

Definition at line 11 of file prime_injection.cpp.

11  {
13 
14  // If the coolant sensor is dead, skip the prime. The engine will still start fine, but may take a little longer.
15  if (!clt) {
16  return 0;
17  }
18 
19  auto primeMass =
20  0.001f * // convert milligram to gram
22 
23  return engine->module<InjectorModelPrimary>()->getInjectionDuration(primeMass);
24 }
constexpr auto & module()
Definition: engine.h:174
virtual SensorResult get() const =0
Engine * engine
static CCM_OPTIONAL FunctionalSensor clt(SensorType::Clt, MS2NT(10))
engine_configuration_s * engineConfiguration
scaled_channel< uint8_t, 1, 5 > primeValues[PRIME_CURVE_COUNT]

Referenced by onPrimeStart().

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

◆ isPriming()

bool PrimeController::isPriming ( ) const
inline

Definition at line 22 of file prime_injection.h.

22  {
23  return m_isPriming;
24  }

◆ onIgnitionStateChanged()

void PrimeController::onIgnitionStateChanged ( bool  ignitionOn)
overridevirtual

Reimplemented from EngineModule.

Definition at line 37 of file prime_injection.cpp.

37  {
38  if (!ignitionOn) {
39  // don't prime on ignition-off
40  return;
41  }
42 
43  // First, we need a protection against 'fake' ignition switch on and off (i.e. no engine started), to avoid repeated prime pulses.
44  // So we check and update the ignition switch counter in non-volatile backup-RAM
45  uint32_t ignSwitchCounter = getKeyCycleCounter();
46 
47  // if we're just toying with the ignition switch, give it another chance eventually...
48  if (ignSwitchCounter > 10) {
49  ignSwitchCounter = 0;
50  }
51 
52  // If we're going to skip this pulse, then save the counter as 0.
53  // That's because we'll definitely need the prime pulse next time (either due to the cylinder cleanup or the engine spinning)
55  ignSwitchCounter = -1;
56  }
57 
58  // start prime injection if this is a 'fresh start'
59  if (ignSwitchCounter == 0) {
60  auto primeDelayMs = engineConfiguration->primingDelay * 1000;
61 
62  auto startTime = getTimeNowNt() + MS2NT(primeDelayMs);
63  getExecutorInterface()->scheduleByTimestampNt("prime", nullptr, startTime, { PrimeController::onPrimeStartAdapter, this });
64  } else {
65  efiPrintf("Skipped priming pulse since ignSwitchCounter = %d", ignSwitchCounter);
66  }
67 
68  // we'll reset it later when the engine starts
69  setKeyCycleCounter(ignSwitchCounter + 1);
70 }
void setKeyCycleCounter(uint32_t count)
uint32_t getKeyCycleCounter() const
static void onPrimeStartAdapter(PrimeController *instance)
efitick_t getTimeNowNt()
Definition: efitime.cpp:19
ExecutorInterface * getExecutorInterface()
Definition: engine.cpp:584
static bool isPrimeInjectionPulseSkipped()
virtual void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action)=0
Here is the call graph for this function:

◆ onPrimeEnd()

void PrimeController::onPrimeEnd ( )

Definition at line 105 of file prime_injection.cpp.

105  {
107 
108  m_isPriming = false;
109 }
void endSimultaneousInjectionOnlyTogglePins()
Here is the call graph for this function:

◆ onPrimeEndAdapter()

static void PrimeController::onPrimeEndAdapter ( PrimeController instance)
inlinestaticprivate

Definition at line 33 of file prime_injection.h.

33  {
34  instance->onPrimeEnd();
35  }
HIP9011 instance

Referenced by onPrimeStart().

Here is the caller graph for this function:

◆ onPrimeStart()

void PrimeController::onPrimeStart ( )

Definition at line 86 of file prime_injection.cpp.

86  {
87  auto durationMs = getPrimeDuration();
88 
89  // Don't prime a zero-duration pulse
90  if (durationMs <= 0) {
91  efiPrintf("Skipped zero-duration priming pulse.");
92  return;
93  }
94 
95  efiPrintf("Firing priming pulse of %.2f ms", durationMs);
96 
97  auto endTime = getTimeNowNt() + MS2NT(durationMs);
98 
99  // Open all injectors, schedule closing later
100  m_isPriming = true;
102  getExecutorInterface()->scheduleByTimestampNt("prime", nullptr, endTime, { onPrimeEndAdapter, this });
103 }
floatms_t getPrimeDuration() const
static void onPrimeEndAdapter(PrimeController *instance)
void startSimultaneousInjection(void *)
Here is the call graph for this function:

◆ onPrimeStartAdapter()

static void PrimeController::onPrimeStartAdapter ( PrimeController instance)
inlinestaticprivate

Definition at line 29 of file prime_injection.h.

29  {
30  instance->onPrimeStart();
31  }

Referenced by onIgnitionStateChanged().

Here is the caller graph for this function:

◆ onSlowCallback()

void PrimeController::onSlowCallback ( )
overridevirtual

Reimplemented from EngineModule.

Definition at line 111 of file prime_injection.cpp.

111  {
112  if (!getEngineRotationState()->isStopped()) {
113 #if EFI_BACKUP_SRAM
115 #endif /* EFI_BACKUP_SRAM */
116  }
117 }
void backupRamSave(backup_ram_e idx, uint32_t value)
Definition: backup_ram.cpp:52
EngineRotationState * getEngineRotationState()
Definition: engine.cpp:572
Here is the call graph for this function:

◆ setKeyCycleCounter()

void PrimeController::setKeyCycleCounter ( uint32_t  count)
private

Definition at line 72 of file prime_injection.cpp.

72  {
73 #if EFI_BACKUP_SRAM
75 #endif // EFI_BACKUP_SRAM
76 }

Referenced by onIgnitionStateChanged().

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

Field Documentation

◆ m_isPriming

bool PrimeController::m_isPriming = false
private

Definition at line 27 of file prime_injection.h.

Referenced by isPriming(), onPrimeEnd(), and onPrimeStart().


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