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

#include <engine.h>

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

Public Member Functions

 Engine ()
 
template<typename get_t >
constexpr auto & module ()
 
void resetLua ()
 
void OnTriggerStateProperState (efitick_t nowNt) override
 
void OnTriggerSynchronization (bool wasSynchronized, bool isDecodingError) override
 
void OnTriggerSynchronizationLost () override
 
void setConfig ()
 
int getBailedOnDwellCount () const
 
void incrementBailedOnDwellCount ()
 
int getGlobalConfigurationVersion (void) const
 
void periodicFastCallback ()
 
void periodicSlowCallback ()
 
void updateSlowSensors ()
 
void updateSwitchInputs ()
 
void updateTriggerConfiguration ()
 
void resetEngineSnifferIfInTestMode ()
 
void preCalculate ()
 
void efiWatchdog ()
 
void onEngineHasStopped ()
 
void checkShutdown ()
 
bool isInShutdownMode () const
 
bool isMainRelayEnabled () const
 
void onSparkFireKnockSense (uint8_t cylinderIndex, efitick_t nowNt)
 

Data Fields

StartStopState startStopState
 
TunerStudioOutputChannels outputChannels
 
bool allowCanTx = true
 
bool isPwmEnabled = true
 
bool pauseCANdueToSerial = false
 
IEtbControlleretbControllers [ETB_COUNT] = {nullptr}
 
FuelComputer fuelComputer
 
type_list< Mockable< InjectorModelPrimary >, Mockable< InjectorModelSecondary >,#if EFI_IDLE_CONTROL Mockable< IdleController >,#endif TriggerScheduler,#if EFI_HPFP &&EFI_ENGINE_CONTROL HpfpController,#endif #if EFI_ENGINE_CONTROL Mockable< ThrottleModel >,#endif #if EFI_ALTERNATOR_CONTROL AlternatorController,#endif FuelPumpController, MainRelayController, Mockable< IgnitionController >, Mockable< AcController >, FanControl1, FanControl2, PrimeController, DfcoController,#if EFI_HD_ACR HarleyAcr,#endif Mockable< WallFuelController >,#if EFI_VEHICLE_SPEED GearDetector, TripOdometer,#endif KnockController, SensorChecker,#if EFI_ENGINE_CONTROL LimpManager,#endif #if EFI_VVT_PID VvtController1, VvtController2, VvtController3, VvtController4,#endif #if EFI_BOOST_CONTROL BoostController,#endif TpsAccelEnrichment,#if EFI_LAUNCH_CONTROL NitrousController,#endif #if EFI_LTFT_CONTROL LongTermFuelTrim,#endif EngineModuleengineModules
 
GearControllerBasegearController = nullptr
 
SwitchedState clutchUpSwitchedState
 
SwitchedState brakePedalSwitchedState
 
SwitchedState acButtonSwitchedState
 
SimpleSwitchedState luaDigitalInputState [LUA_DIGITAL_INPUT_COUNT]
 
LaunchControlBase launchController
 
ShiftTorqueReductionController shiftTorqueReductionController
 
SoftSparkLimiter softSparkLimiter
 
SoftSparkLimiter hardSparkLimiter
 
AntilagSystemBase antilagController
 
LambdaMonitor lambdaMonitor
 
IgnitionState ignitionState
 
AuxActor auxValves [AUX_DIGITAL_VALVE_COUNT][2]
 
bool needTdcCallback = true
 
SingleTimerExecutor scheduler
 
SleepExecutor scheduler
 
TestExecutor scheduler
 
std::function< void(IgnitionEvent *, bool)> onIgnitionEvent
 
std::function< void(const IgnitionEvent &, efitick_t, angle_t, efitick_t)> onScheduleTurnSparkPinHighStartCharging = [](const IgnitionEvent&, efitick_t, angle_t, efitick_t) -> void {}
 
std::function< void(const IgnitionEvent &, efitick_t)> onScheduleOverFireSparkAndPrepareNextSchedule = [](const IgnitionEvent&, efitick_t) -> void {}
 
FuelSchedule injectionEvents
 
IgnitionEventList ignitionEvents
 
scheduling_s tdcScheduler [2]
 
bool etbAutoTune = false
 
bool etbIgnoreJamProtection = false
 
bool tdcMarkEnabled = true
 
bool slowCallBackWasInvoked = false
 
RpmCalculator rpmCalculator
 
Timer configBurnTimer
 
Timer engineTypeChangeTimer
 
int globalConfigurationVersion = 0
 
TriggerCentral triggerCentral
 
bool isRunningPwmTest = false
 
bool isFunctionalTestMode = false
 
EngineState engineState
 
dc_motors_s dc_motors
 
sent_state_s sent_state
 
percent_t blipIdlePosition
 
efitimeus_t timeToStopBlip = 0
 
efitimeus_t timeToStopIdleTest = 0
 
SensorsState sensors
 
AirmassModelBasemockAirmassModel = nullptr
 

Private Member Functions

void reset ()
 
void injectEngineReferences ()
 

Private Attributes

int bailedOnDwellCount = 0
 

Detailed Description

Definition at line 95 of file engine.h.

Constructor & Destructor Documentation

◆ Engine()

Engine::Engine ( )

Definition at line 268 of file engine.cpp.

271 acButtonSwitchedState(&module<AcController>().unmock().acButtonState)
272
273#if EFI_LAUNCH_CONTROL
274
275 , softSparkLimiter(false), hardSparkLimiter(true)
276
277#if EFI_ANTILAG_SYSTEM
278// , ALSsoftSparkLimiter(false)
279#endif /* EFI_ANTILAG_SYSTEM */
280
281#endif // EFI_LAUNCH_CONTROL
282{
283 reset();
284}
SoftSparkLimiter softSparkLimiter
Definition engine.h:204
EngineState engineState
Definition engine.h:325
SwitchedState brakePedalSwitchedState
Definition engine.h:197
SwitchedState clutchUpSwitchedState
Definition engine.h:196
SwitchedState acButtonSwitchedState
Definition engine.h:198
SoftSparkLimiter hardSparkLimiter
Definition engine.h:206
void reset()
Definition engine.cpp:290
acButtonState("AC switch", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1184, 1.0, -1.0, -1.0, "")
Here is the call graph for this function:

Member Function Documentation

◆ checkShutdown()

void Engine::checkShutdown ( )

Needed by EFI_MAIN_RELAY_CONTROL to shut down the engine correctly. This method cancels shutdown if the ignition voltage is detected.

Definition at line 459 of file engine.cpp.

459 {
460#if EFI_MAIN_RELAY_CONTROL
461 // if we are already in the "ignition_on" mode, then do nothing
462/* this logic is not alive
463 if (ignitionOnTimeNt > 0) {
464 return;
465 }
466todo: move to shutdown_controller.cpp
467*/
468
469 // here we are in the shutdown (the ignition is off) or initial mode (after the firmware fresh start)
470/* this needs work or tests
471 const efitick_t engineStopWaitTimeoutUs = 500000LL; // 0.5 sec
472 // in shutdown mode, we need a small cooldown time between the ignition off and on
473todo: move to shutdown_controller.cpp
474 if (stopEngineRequestTimeNt == 0 || (getTimeNowNt() - stopEngineRequestTimeNt) > US2NT(engineStopWaitTimeoutUs)) {
475 // if the ignition key is turned on again,
476 // we cancel the shutdown mode, but only if all shutdown procedures are complete
477 const float vBattThresholdOn = 8.0f;
478 // we fallback into zero instead of VBAT_FALLBACK_VALUE because it's not safe to false-trigger the "ignition on" event,
479 // and we want to turn on the main relay only when 100% sure.
480 if ((Sensor::getOrZero(SensorType::BatteryVoltage) > vBattThresholdOn) && !isInShutdownMode()) {
481 ignitionOnTimeNt = getTimeNowNt();
482 efiPrintf("Ignition voltage detected!");
483 if (stopEngineRequestTimeNt != 0) {
484 efiPrintf("Cancel the engine shutdown!");
485 stopEngineRequestTimeNt = 0;
486 }
487 }
488 }
489*/
490#endif /* EFI_MAIN_RELAY_CONTROL */
491}

Referenced by periodicSlowCallback().

Here is the caller graph for this function:

◆ efiWatchdog()

void Engine::efiWatchdog ( )

todo: better watch dog implementation should be implemented - see http://sourceforge.net/p/rusefi/tickets/96/

Definition at line 418 of file engine.cpp.

418 {
421 return;
422
423#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
424 if (module<PrimeController>()->isPriming() || triggerCentral.engineMovedRecently()) {
425 // do not invoke check in priming or if engine moved recently, no need to assert safe pin state.
426 return;
427 }
428
431 // todo: make this a firmwareError assuming functional tests would run
432 warning(ObdCode::CUSTOM_ERR_2ND_WATCHDOG, "Some pins were turned off by 2nd pass watchdog");
433 }
434 return;
435 }
436
437 /**
438 * todo: better watch dog implementation should be implemented - see
439 * http://sourceforge.net/p/rusefi/tickets/96/
440 */
443#endif // EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
444}
bool isRunningBenchTest()
TriggerCentral triggerCentral
Definition engine.h:299
void onEngineHasStopped()
Definition engine.cpp:446
bool isRunningPwmTest
Definition engine.h:315
bool stopPins()
Definition efi_gpio.cpp:217
bool engineMovedRecently(efitick_t nowNt) const
EnginePins enginePins
Definition efi_gpio.cpp:24
static void assertTimeIsLinear()
Definition engine.cpp:400
bool warning(ObdCode code, const char *fmt,...)
@ CUSTOM_ERR_2ND_WATCHDOG

Referenced by periodicSlowCallback().

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

◆ getBailedOnDwellCount()

int Engine::getBailedOnDwellCount ( ) const
inline

Definition at line 241 of file engine.h.

241{ return bailedOnDwellCount; }
int bailedOnDwellCount
Definition engine.h:239

◆ getGlobalConfigurationVersion()

int Engine::getGlobalConfigurationVersion ( void  ) const

Definition at line 286 of file engine.cpp.

286 {
288}
int globalConfigurationVersion
Definition engine.h:296

Referenced by TriggerCentral::checkIfTriggerConfigChanged(), configureRusefiLuaHooks(), printConfiguration(), and updateTriggerWaveformIfNeeded().

Here is the caller graph for this function:

◆ incrementBailedOnDwellCount()

void Engine::incrementBailedOnDwellCount ( )
inline

Definition at line 242 of file engine.h.

Referenced by turnSparkPinHighStartCharging().

Here is the caller graph for this function:

◆ injectEngineReferences()

void Engine::injectEngineReferences ( )
private

Definition at line 379 of file engine.cpp.

379 {
380#if EFI_SHAFT_POSITION_INPUT
382 for (int camIndex = 0;camIndex < CAMS_PER_BANK;camIndex++) {
384 }
385#endif // EFI_SHAFT_POSITION_INPUT
386}
VvtTriggerConfiguration vvtTriggerConfiguration[CAMS_PER_BANK]
PrimaryTriggerConfiguration primaryTriggerConfiguration

Referenced by setConfig().

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

◆ isInShutdownMode()

bool Engine::isInShutdownMode ( ) const

Allows to finish some long-term shutdown procedures (stepper motor parking etc.) Called when the ignition switch is turned off (vBatt is too low). Returns true if some operations are in progress on background.

Definition at line 493 of file engine.cpp.

493 {
494 // TODO: this logic is currently broken
495#if 0 && EFI_MAIN_RELAY_CONTROL && EFI_PROD_CODE
496 // if we are in "ignition_on" mode and not in shutdown mode
497 if (stopEngineRequestTimeNt == 0 && ignitionOnTimeNt > 0) {
498 const float vBattThresholdOff = 5.0f;
499 // start the shutdown process if the ignition voltage dropped low
500 if (Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE) <= vBattThresholdOff) {
502 }
503 }
504
505 // we are not in the shutdown mode?
506 if (stopEngineRequestTimeNt == 0) {
507 return false;
508 }
509
510 const efitick_t turnOffWaitTimeoutNt = NT_PER_SECOND;
511 // We don't want any transients to step in, so we wait at least 1 second whatever happens.
512 // Also it's good to give the stepper motor some time to start moving to the initial position (or parking)
513 if ((getTimeNowNt() - stopEngineRequestTimeNt) < turnOffWaitTimeoutNt)
514 return true;
515
516 const efitick_t engineSpinningWaitTimeoutNt = 5 * NT_PER_SECOND;
517 // The engine is still spinning! Give it some time to stop (but wait no more than 5 secs)
518 if (isSpinning && (getTimeNowNt() - stopEngineRequestTimeNt) < engineSpinningWaitTimeoutNt)
519 return true;
520
521 // The idle motor valve is still moving! Give it some time to park (but wait no more than 10 secs)
522 // Usually it can move to the initial 'cranking' position or zero 'parking' position.
523 const efitick_t idleMotorWaitTimeoutNt = 10 * NT_PER_SECOND;
524 if (isIdleMotorBusy() && (getTimeNowNt() - stopEngineRequestTimeNt) < idleMotorWaitTimeoutNt)
525 return true;
526#endif /* EFI_MAIN_RELAY_CONTROL */
527 return false;
528}
virtual SensorResult get() const =0
efitick_t getTimeNowNt()
Definition efitime.cpp:19
bool isIdleMotorBusy()
void scheduleStopEngine()
Definition settings.cpp:458
Here is the call graph for this function:

◆ isMainRelayEnabled()

bool Engine::isMainRelayEnabled ( ) const

The stepper does not work if the main relay is turned off (it requires +12V). Needed by the stepper motor code to detect if it works.

Definition at line 530 of file engine.cpp.

530 {
531#if EFI_MAIN_RELAY_CONTROL
533#else
534 // if no main relay control, we assume it's always turned on
535 return true;
536#endif /* EFI_MAIN_RELAY_CONTROL */
537}
RegisteredOutputPin mainRelay
Definition efi_gpio.h:76
bool getLogicValue() const
Definition efi_gpio.cpp:653

Referenced by StepDirectionStepper::pulse(), and LimpManager::updateState().

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

◆ module()

template<typename get_t >
constexpr auto & Engine::module ( )
inlineconstexpr

Slightly shorter helper function to keep the code looking clean.

Definition at line 187 of file engine.h.

187 {
188 return engineModules.get<get_t>();
189 }
type_list< Mockable< InjectorModelPrimary >, Mockable< InjectorModelSecondary >,#if EFI_IDLE_CONTROL Mockable< IdleController >,#endif TriggerScheduler,#if EFI_HPFP &&EFI_ENGINE_CONTROL HpfpController,#endif #if EFI_ENGINE_CONTROL Mockable< ThrottleModel >,#endif #if EFI_ALTERNATOR_CONTROL AlternatorController,#endif FuelPumpController, MainRelayController, Mockable< IgnitionController >, Mockable< AcController >, FanControl1, FanControl2, PrimeController, DfcoController,#if EFI_HD_ACR HarleyAcr,#endif Mockable< WallFuelController >,#if EFI_VEHICLE_SPEED GearDetector, TripOdometer,#endif KnockController, SensorChecker,#if EFI_ENGINE_CONTROL LimpManager,#endif #if EFI_VVT_PID VvtController1, VvtController2, VvtController3, VvtController4,#endif #if EFI_BOOST_CONTROL BoostController,#endif TpsAccelEnrichment,#if EFI_LAUNCH_CONTROL NitrousController,#endif #if EFI_LTFT_CONTROL LongTermFuelTrim,#endif EngineModule > engineModules
Definition engine.h:181
constexpr auto get() -> std::enable_if_t< decltype(first)::template has< get_t >(), decltype(first.template get< get_t >())>
Definition type_list.h:66

Referenced by WallFuel::adjust(), applyPidSettings(), auxPlainPinTurnOn(), canDashboardHaltech(), EtbController::checkJam(), EtbController::checkStatus(), configureRusefiLuaHooks(), flashWriteThread(), getAdvanceCorrections(), AlternatorController::getClosedLoop(), IdleController::getClosedLoop(), getIdlePosition(), getInjectionMass(), getLimpManager(), getLiveData(), getLiveData(), getOutputValueByName(), PrimeController::getPrimeDuration(), getRunningAdvance(), getRunningFuel(), IdleController::getRunningOpenLoop(), IdleController::getTargetRpm(), AirmassVeModelBase::getVe(), handleGetDataRequest(), TriggerCentral::handleShaftSignal(), hipThread(), initAccelEnrichment(), initAlternatorCtrl(), initBoostCtrl(), initSoftwareKnock(), initVvtActuators(), LambdaMonitorBase::isCurrentlyGood(), LtftState::load(), lua_getDigital(), mainTriggerCallback(), FanController::onSlowCallback(), InjectionEvent::onTriggerTooth(), EngineState::periodicFastCallback(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), processLastKnockEvent(), resetAccel(), resetLua(), HpfpController::scheduleNextCycle(), scheduleOpen(), scheduleSparkEvent(), setAltPFactor(), shouldUpdateCorrection(), startIdleThread(), updateFlags(), updateFuelResults(), LimpManager::updateState(), updateSwitchInputs(), and updateVehicleSpeed().

Here is the call graph for this function:

◆ onEngineHasStopped()

void Engine::onEngineHasStopped ( )

Definition at line 446 of file engine.cpp.

446 {
447#if EFI_ENGINE_CONTROL
448 ignitionEvents.isReady = false;
449#endif // EFI_ENGINE_CONTROL
450
451#if EFI_PROD_CODE || EFI_SIMULATOR
452 efiPrintf("Engine has stopped spinning.");
453#endif
454
455 // this invocation should be the last layer of defence in terms of making sure injectors/coils are not active
457}
IgnitionEventList ignitionEvents
Definition engine.h:270

Referenced by efiWatchdog().

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

◆ onSparkFireKnockSense()

void Engine::onSparkFireKnockSense ( uint8_t  cylinderIndex,
efitick_t  nowNt 
)

Definition at line 192 of file knock_controller.cpp.

192 {
193#if EFI_HIP_9011 || EFI_SOFTWARE_KNOCK
194 cylinderNumberCopy = cylinderNumber;
195 scheduleByAngle(nullptr, nowNt,
196 /*angle*/engineConfiguration->knockDetectionWindowStart, { startKnockSampling, engine });
197#else
198 UNUSED(cylinderNumber);
199 UNUSED(nowNt);
200#endif
201
202#if EFI_HIP_9011
203 hip9011_onFireEvent(cylinderNumber, nowNt);
204#endif
205}
static constexpr engine_configuration_s * engineConfiguration
void hip9011_onFireEvent(uint8_t cylinderNumber, efitick_t nowNt)
Definition hip9011.cpp:283
UNUSED(samplingTimeSeconds)
static uint8_t cylinderNumberCopy
efitick_t scheduleByAngle(scheduling_s *timer, efitick_t nowNt, angle_t angle, action_s action)

Referenced by fireSparkAndPrepareNextSchedule().

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

◆ OnTriggerStateProperState()

void Engine::OnTriggerStateProperState ( efitick_t  nowNt)
overridevirtual

Implements TriggerStateListener.

Definition at line 332 of file engine.cpp.

332 {
334}
RpmCalculator rpmCalculator
Definition engine.h:287
void setSpinningUp(efitick_t nowNt)
Here is the call graph for this function:

◆ OnTriggerSynchronization()

void Engine::OnTriggerSynchronization ( bool  wasSynchronized,
bool  isDecodingError 
)
overridevirtual

Implements TriggerStateListener.

Definition at line 350 of file engine.cpp.

350 {
351 // TODO: this logic probably shouldn't be part of engine.cpp
352
353 // We only care about trigger shape once we have synchronized trigger. Anything could happen
354 // during first revolution and it's fine
355 if (wasSynchronized) {
357
358 // 'triggerStateListener is not null' means we are running a real engine and now just preparing trigger shape
359 // that's a bit of a hack, a sweet OOP solution would be a real callback or at least 'needDecodingErrorLogic' method?
360 if (isDecodingError) {
361#if EFI_PROD_CODE
363 efiPrintf("error: synchronizationPoint @ index %lu expected %d/%d got %d/%d",
369 }
370#endif /* EFI_PROD_CODE */
371 }
372
373 engine->triggerCentral.triggerErrorDetection.add(isDecodingError);
374 }
375
376}
RegisteredOutputPin triggerDecoderErrorPin
Definition efi_gpio.h:120
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition efi_gpio.cpp:590
PrimaryTriggerDecoder triggerState
TriggerWaveform triggerShape
cyclic_buffer< int > triggerErrorDetection
current_cycle_state_s currentCycle
bool someSortOfTriggerError() const
size_t getExpectedEventCount(TriggerWheel channelIndex) const
static Engine *const engine
Definition engine.h:389
size_t eventCount[PWM_PHASE_MAX_WAVE_PER_PWM]
Here is the call graph for this function:

◆ OnTriggerSynchronizationLost()

void Engine::OnTriggerSynchronizationLost ( )
overridevirtual

Implements TriggerStateListener.

Definition at line 336 of file engine.cpp.

336 {
337 // Needed for early instant-RPM detection
339
342
343 for (size_t i = 0; i < efi::size(triggerCentral.vvtState); i++) {
344 for (size_t j = 0; j < efi::size(triggerCentral.vvtState[0]); j++) {
346 }
347 }
348}
VvtTriggerDecoder vvtState[BANKS_COUNT][CAMS_PER_BANK]
InstantRpmCalculator instantRpm
virtual void resetState()
Here is the call graph for this function:

◆ periodicFastCallback()

void Engine::periodicFastCallback ( )

See FAST_CALLBACK_PERIOD_MS

The idea of this method is to execute all heavy calculations in a lower-priority thread, so that trigger event handler/IO scheduler tasks are faster.

Definition at line 547 of file engine.cpp.

547 {
549
550#if EFI_MAP_AVERAGING
552#endif
553
555
556 tachUpdate();
557 speedoUpdate();
558
559 engineModules.apply_all([](auto & m) { m.onFastCallback(); });
560}
void periodicFastCallback()
Definition engine2.cpp:101
void refreshMapAveragingPreCalc()
@ EnginePeriodicFastCallback
void speedoUpdate()
void apply_all(func_t const &f)
Definition type_list.h:43
void tachUpdate()

Referenced by RpmCalculator::assignRpmValue(), and mainTriggerCallback().

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

◆ periodicSlowCallback()

void Engine::periodicSlowCallback ( )

See SLOW_CALLBACK_PERIOD_MS

Definition at line 141 of file engine.cpp.

141 {
143
144#if EFI_CAN_SUPPORT
146 static Timer canBusWboSetIndex;
147 if (canBusWboSetIndex.getElapsedSeconds() > 1) {
148 canBusWboSetIndex.reset();
150 }
151 }
152#endif // EFI_CAN_SUPPORT
153
154#if EFI_SHAFT_POSITION_INPUT
155 // Re-read config in case it's changed
157 for (int camIndex = 0;camIndex < CAMS_PER_BANK;camIndex++) {
159 }
160
162 enginePins.o2heater.setValue(getEngineState()->heaterControlEnabled);
164#endif // EFI_SHAFT_POSITION_INPUT
165
166 efiWatchdog();
169
170 module<TpsAccelEnrichment>()->onNewValue(Sensor::getOrZero(SensorType::Tps1));
171
173
174 updateGppwm();
175
176 engine->engineModules.apply_all([](auto & m) { m.onSlowCallback(); });
177
178#if (BOARD_TLE8888_COUNT > 0)
180#endif
181
182#if EFI_DYNO_VIEW
184#endif
185
187
188#if EFI_PROD_CODE
189 void baroLps25Update();
191#endif // EFI_PROD_CODE
192}
void updateSlowSensors()
Definition engine.cpp:198
void checkShutdown()
Definition engine.cpp:459
bool slowCallBackWasInvoked
Definition engine.h:285
void efiWatchdog()
Definition engine.cpp:418
OutputPin o2heater
Definition efi_gpio.h:98
RegisteredOutputPin starterRelayDisable
Definition efi_gpio.h:84
bool isRunning() const
static float getOrZero(SensorType type)
Definition sensor.h:83
void updateDynoView()
Definition dynoview.cpp:147
EngineState * getEngineState()
Definition engine.cpp:566
void updateGppwm()
Definition gppwm.cpp:58
void baroLps25Update()
Definition init_baro.cpp:19
@ EnginePeriodicSlowCallback
void setWidebandOffset(uint8_t index)
void tle8888startup()
void updateVrThresholdPwm()
Definition vr_pwm.cpp:31

Referenced by doPeriodicSlowCallback().

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

◆ preCalculate()

void Engine::preCalculate ( )

Here we have a bunch of stuff which should invoked after configuration change so that we can prepare some helper structures

Definition at line 321 of file engine.cpp.

321 {
322#if EFI_TUNER_STUDIO
323 // we take 2 bytes of crc32, no idea if it's right to call it crc16 or not
324 // we have a hack here - we rely on the fact that engineMake is the first of three relevant fields
326
328#endif /* EFI_TUNER_STUDIO */
329}
TunerStudioOutputChannels outputChannels
Definition engine.h:102
static constexpr persistent_config_s * config

Referenced by incrementGlobalConfigurationVersion(), and readFromFlash().

Here is the caller graph for this function:

◆ reset()

void Engine::reset ( )
private

it's important for wrapAngle() that engineCycle field never has zero

Definition at line 290 of file engine.cpp.

290 {
291 /**
292 * it's important for wrapAngle() that engineCycle field never has zero
293 */
295 resetLua();
296}
void resetLua()
Definition engine.cpp:298
angle_t engineCycle
@ FOUR_STROKE_CRANK_SENSOR
angle_t getEngineCycle(operation_mode_e operationMode)

Referenced by Engine().

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

◆ resetEngineSnifferIfInTestMode()

void Engine::resetEngineSnifferIfInTestMode ( )

Definition at line 57 of file engine.cpp.

57 {
58#if EFI_ENGINE_SNIFFER
60 // TODO: what is the exact reasoning for the exact engine sniffer pause time I wonder
63 }
64#endif /* EFI_ENGINE_SNIFFER */
65}
bool isFunctionalTestMode
Definition engine.h:321
efitick_t pauseEngineSnifferUntilNt
WaveChart waveChart

Referenced by setEngineType(), setTriggerEmulatorRPM(), setTriggerType(), setValue(), and setWholeTimingMapCmd().

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

◆ resetLua()

void Engine::resetLua ( )

Definition at line 298 of file engine.cpp.

298 {
299 // todo: https://github.com/rusefi/rusefi/issues/4308
300 engineState.lua = {};
304 engineState.lua.luaIgnCut = false;
305 engineState.lua.luaFuelCut = false;
307#if EFI_BOOST_CONTROL
308 module<BoostController>().unmock().resetLua();
309#endif // EFI_BOOST_CONTROL
312#if EFI_IDLE_CONTROL
313 module<IdleController>().unmock().luaAdd = 0;
314#endif // EFI_IDLE_CONTROL
315}
IgnitionState ignitionState
Definition engine.h:221

Referenced by reset().

Here is the caller graph for this function:

◆ setConfig()

void Engine::setConfig ( )

Definition at line 388 of file engine.cpp.

388 {
389#if !EFI_UNIT_TEST
390// huh should this be happy? static_assert(config != nullptr);
391#endif
392 efi::clear(config);
393
395}
void injectEngineReferences()
Definition engine.cpp:379

Referenced by runRusEfi().

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

◆ updateSlowSensors()

void Engine::updateSlowSensors ( )

We are executing these heavy (logarithm) methods from outside the trigger callbacks for performance reasons. See also periodicFastCallback

Definition at line 198 of file engine.cpp.

Referenced by periodicSlowCallback(), and testRusefiMethods().

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

◆ updateSwitchInputs()

void Engine::updateSwitchInputs ( )

Definition at line 239 of file engine.cpp.

239 {
240 // this value is not used yet
244#if EFI_GPIO_HARDWARE
245 {
246 bool currentState;
247 if (hasAcToggle()) {
248 currentState = getAcToggle();
249#ifdef EFI_KLINE
250 } else if (engineConfiguration->hondaK) {
251extern bool kAcRequestState;
252 currentState = kAcRequestState;
253#endif // EFI_KLINE
254 } else {
255 currentState = engine->engineState.lua.acRequestState;
256 }
257 AcController & acController = engine->module<AcController>().unmock();
258 if (engine->acButtonSwitchedState.update(currentState)) {
259 acController.timeSinceStateChange.reset();
260 }
261 }
262
264
265#endif // EFI_GPIO_HARDWARE
266}
bool getAcToggle()
bool hasAcToggle()
Timer timeSinceStateChange
Definition ac_control.h:16
constexpr auto & module()
Definition engine.h:187
bool update(bool newState)
bool getBrakePedalState()
Definition engine.cpp:228
static bool getClutchUpState()
Definition engine.cpp:218
bool getClutchDownState()
Definition engine.cpp:208
void pokeAuxDigital()
bool kAcRequestState
Definition kline.cpp:31

Referenced by updateSlowSensors().

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

◆ updateTriggerConfiguration()

void Engine::updateTriggerConfiguration ( )

Definition at line 125 of file engine.cpp.

125 {
126
127
128#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
129 // we have a confusing threading model so some synchronization would not hurt
130 chibios_rt::CriticalSectionLocker csl;
131
133
134
137 }
138#endif /* EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT */
139}
void prepareOutputSignals()

Referenced by applyNonPersistentConfiguration(), and onConfigurationChangeTriggerCallback().

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

Field Documentation

◆ acButtonSwitchedState

SwitchedState Engine::acButtonSwitchedState

Definition at line 198 of file engine.h.

Referenced by sendQcBenchButtonCounters(), and updateSwitchInputs().

◆ allowCanTx

bool Engine::allowCanTx = true

Sometimes for instance during shutdown we need to completely supress CAN TX

Definition at line 107 of file engine.h.

Referenced by configureRusefiLuaHooks(), and CanTxMessage::~CanTxMessage().

◆ antilagController

AntilagSystemBase Engine::antilagController

◆ auxValves

AuxActor Engine::auxValves[AUX_DIGITAL_VALVE_COUNT][2]

Definition at line 233 of file engine.h.

Referenced by initAuxValves().

◆ bailedOnDwellCount

int Engine::bailedOnDwellCount = 0
private

Definition at line 239 of file engine.h.

Referenced by getBailedOnDwellCount(), and incrementBailedOnDwellCount().

◆ blipIdlePosition

percent_t Engine::blipIdlePosition

idle blip is a development tool: alternator PID research for instance have benefited from a repetitive change of RPM

Definition at line 335 of file engine.h.

Referenced by blipIdle(), and IdleController::getIdlePosition().

◆ brakePedalSwitchedState

SwitchedState Engine::brakePedalSwitchedState

◆ clutchUpSwitchedState

SwitchedState Engine::clutchUpSwitchedState

Definition at line 196 of file engine.h.

Referenced by sendQcBenchButtonCounters(), and updateSwitchInputs().

◆ configBurnTimer

Timer Engine::configBurnTimer

Definition at line 289 of file engine.h.

Referenced by assertTimeIsLinear(), and writeToFlashNow().

◆ dc_motors

dc_motors_s Engine::dc_motors

Definition at line 327 of file engine.h.

Referenced by getLiveData(), getOutputValueByName(), and updateTunerStudioState().

◆ engineModules

type_list< Mockable<InjectorModelPrimary>, Mockable<InjectorModelSecondary>,#if EFI_IDLE_CONTROL Mockable<IdleController>,#endif TriggerScheduler,#if EFI_HPFP && EFI_ENGINE_CONTROL HpfpController,#endif #if EFI_ENGINE_CONTROL Mockable<ThrottleModel>,#endif #if EFI_ALTERNATOR_CONTROL AlternatorController,#endif FuelPumpController, MainRelayController, Mockable<IgnitionController>, Mockable<AcController>, FanControl1, FanControl2, PrimeController, DfcoController,#if EFI_HD_ACR HarleyAcr,#endif Mockable<WallFuelController>,#if EFI_VEHICLE_SPEED GearDetector, TripOdometer,#endif KnockController, SensorChecker,#if EFI_ENGINE_CONTROL LimpManager,#endif #if EFI_VVT_PID VvtController1, VvtController2, VvtController3, VvtController4,#endif #if EFI_BOOST_CONTROL BoostController,#endif TpsAccelEnrichment,#if EFI_LAUNCH_CONTROL NitrousController,#endif #if EFI_LTFT_CONTROL LongTermFuelTrim,#endif EngineModule > Engine::engineModules

◆ engineState

EngineState Engine::engineState

Definition at line 325 of file engine.h.

Referenced by auxPlainPinTurnOn(), HpfpQuantity::calcFuelPercent(), canDashboardHaltech(), EtbController::checkStatus(), configureRusefiLuaHooks(), AemXSeriesWideband::decodeRusefiDiag(), detectHellenBoardType(), fireSparkAndPrepareNextSchedule(), firmwareError(), getAcrState(), getAdvanceCorrections(), SpeedDensityAirmass::getAirmass(), AngleBasedEvent::getAngleFromNow(), getBaseFuelMass(), getBoardId(), getBrakePedalState(), getClutchDownState(), getClutchUpState(), getCrankingFuel3(), getEngineState(), getInjectionMass(), getInjectorDutyCycle(), getInjectorDutyCycleStage2(), getLiveData(), getMultiSparkCount(), getOutputValueByName(), getPerCylinderFiringOrderOffset(), getRunningAdvance(), getRunningFuel(), DfcoController::getState(), AirmassVeModelBase::getVe(), handleGetDataRequest(), handleTestCommand(), initDataStructures(), initializeIgnitionActions(), is_F_OrOlder(), isMegaModuleRevision(), lua_getDigital(), mapAveragingTriggerCallback(), obdOnCanPacketRx(), KnockControllerBase::onKnockSenseCompleted(), HarleyAcr::onSlowCallback(), onStartStopButtonToggle(), onTriggerEventSparkLogic(), overFireSparkAndPrepareNextSchedule(), periodicFastCallback(), EngineState::periodicFastCallback(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), prepareCylinderIgnitionSchedule(), recalculateAuxValveTiming(), refreshMapAveragingPreCalc(), AemXSeriesWideband::refreshState(), reset(), resetLua(), runOneLua(), sayHello(), scheduleOpen(), scheduleSparkEvent(), sendWidebandInfo(), setBoardConfigOverrides(), Generic4TransmissionController::setPcState(), slowStartStopButtonCallback(), startAveraging(), startDwellByTurningSparkPinHigh(), testRusefiMethods(), THD_FUNCTION(), turnSparkPinHighStartCharging(), updateFuelCorrections(), updateFuelInfo(), LimpManager::updateState(), updateSwitchInputs(), ShiftTorqueReductionController::updateTriggerPinState(), updateTunerStudioState(), updateWarningCodes(), and warning().

◆ engineTypeChangeTimer

Timer Engine::engineTypeChangeTimer

Definition at line 290 of file engine.h.

Referenced by onApplyPreset(), and wasPresetJustApplied().

◆ etbAutoTune

bool Engine::etbAutoTune = false

◆ etbControllers

IEtbController* Engine::etbControllers[ETB_COUNT] = {nullptr}

◆ etbIgnoreJamProtection

bool Engine::etbIgnoreJamProtection = false

Definition at line 277 of file engine.h.

Referenced by LimpManager::allowElectronicThrottle(), and handleCommandX14().

◆ fuelComputer

FuelComputer Engine::fuelComputer

◆ gearController

GearControllerBase* Engine::gearController = nullptr

Definition at line 192 of file engine.h.

Referenced by doPeriodicSlowCallback(), getLiveData(), and initGearController().

◆ globalConfigurationVersion

int Engine::globalConfigurationVersion = 0

This counter is incremented every time user adjusts ECU parameters online (either via rusEfi console or other tuning software)

Definition at line 296 of file engine.h.

Referenced by getGlobalConfigurationVersion(), and incrementGlobalConfigurationVersion().

◆ hardSparkLimiter

SoftSparkLimiter Engine::hardSparkLimiter

Definition at line 206 of file engine.h.

Referenced by onTriggerEventSparkLogic(), and EngineState::updateSparkSkip().

◆ ignitionEvents

IgnitionEventList Engine::ignitionEvents

◆ ignitionState

IgnitionState Engine::ignitionState

◆ injectionEvents

FuelSchedule Engine::injectionEvents

◆ isFunctionalTestMode

bool Engine::isFunctionalTestMode = false

are we running any kind of functional test? this affect some areas

Definition at line 321 of file engine.h.

Referenced by enableOrDisable(), and resetEngineSnifferIfInTestMode().

◆ isPwmEnabled

bool Engine::isPwmEnabled = true

Definition at line 110 of file engine.h.

Referenced by applyPinState(), and enableOrDisable().

◆ isRunningPwmTest

bool Engine::isRunningPwmTest = false

Definition at line 315 of file engine.h.

Referenced by efiWatchdog().

◆ lambdaMonitor

LambdaMonitor Engine::lambdaMonitor

◆ launchController

LaunchControlBase Engine::launchController

◆ luaDigitalInputState

SimpleSwitchedState Engine::luaDigitalInputState[LUA_DIGITAL_INPUT_COUNT]

Definition at line 199 of file engine.h.

Referenced by pokeAuxDigital(), and sendQcBenchAuxDigitalCounters().

◆ mockAirmassModel

AirmassModelBase* Engine::mockAirmassModel = nullptr

Definition at line 368 of file engine.h.

Referenced by getAirmassModel().

◆ needTdcCallback

bool Engine::needTdcCallback = true

Definition at line 237 of file engine.h.

Referenced by onTdcCallback().

◆ onIgnitionEvent

std::function<void(IgnitionEvent*, bool)> Engine::onIgnitionEvent

Definition at line 261 of file engine.h.

Referenced by fireSparkAndPrepareNextSchedule(), and turnSparkPinHighStartCharging().

◆ onScheduleOverFireSparkAndPrepareNextSchedule

std::function<void(const IgnitionEvent&, efitick_t)> Engine::onScheduleOverFireSparkAndPrepareNextSchedule = [](const IgnitionEvent&, efitick_t) -> void {}

Definition at line 264 of file engine.h.

265{};

◆ onScheduleTurnSparkPinHighStartCharging

std::function<void(const IgnitionEvent&, efitick_t, angle_t, efitick_t)> Engine::onScheduleTurnSparkPinHighStartCharging = [](const IgnitionEvent&, efitick_t, angle_t, efitick_t) -> void {}

Definition at line 262 of file engine.h.

263{};

Referenced by scheduleSparkEvent().

◆ outputChannels

TunerStudioOutputChannels Engine::outputChannels

Definition at line 102 of file engine.h.

Referenced by attachMsdSdCard(), canInfo(), EtbController::checkStatus(), TunerStudio::cmdOutputChannels(), completionCallback(), TriggerCentral::decodeMapCam(), executorStatistics(), fastAdcErrorCB(), fireSparkAndPrepareNextSchedule(), fuelClosedLoopCorrection(), getAdvanceCorrections(), VvtController::getClosedLoop(), BoostController::getClosedLoop(), AlternatorController::getClosedLoop(), EtbController::getClosedLoopAutotune(), IdleController::getIdlePosition(), getLiveData(), SpeedDensityAirmass::getMap(), BoostController::getOpenLoop(), getOutputValueByName(), getRunningAdvance(), BoostController::getSetpoint(), VvtController::getSetpoint(), FuelComputer::getTargetLambda(), getTunerStudioOutputChannels(), AirmassVeModelBase::getVe(), grabPedalIsUp(), grabPedalIsWideOpen(), handleCommandX14(), handleFuel(), handleShaftSignal(), handleVvtCamSignal(), initElectronicThrottle(), lua_setDebug(), mapAveragingAdcCallback(), mountMmc(), myAlloc(), PrimeController::onPrimeStart(), onTriggerEventSparkLogic(), InjectionEvent::onTriggerTooth(), populateFrame(), populateFrame(), StepperMotorBase::postCurrentPosition(), GearControllerBase::postState(), preCalculate(), prepareCylinderIgnitionSchedule(), printErrorCounters(), printUid(), processLastKnockEvent(), readGppwmChannel(), reportLogicAnalyzerToTS(), runBench(), runOneLua(), IgnitionOutputPin::setHigh(), IgnitionOutputPin::setLow(), EtbController::setOutput(), setToothLogReady(), slowAdcErrorCB(), AdcDevice::startConversionI(), startLua(), THD_FUNCTION(), tle8888PostState(), triggerScopeDisable(), triggerScopeGetBuffer(), InjectionEvent::update(), SimpleTransmissionController::update(), DynoView::update(), updateDevConsoleState(), updateEgtSensors(), updateFlags(), updateFuelCorrections(), updateFuelInfo(), updateFuelResults(), updateFuelSensors(), updateGppwm(), updateIgnition(), updateLambda(), updateMiscSensors(), updatePressures(), updateRawSensors(), updateSdCardLiveFlags(), updateTempSensors(), updateThrottles(), updateTunerStudioState(), updateVehicleSpeed(), updateVvtSensors(), updateWarningCodes(), and CanTxMessage::~CanTxMessage().

◆ pauseCANdueToSerial

bool Engine::pauseCANdueToSerial = false

ELM327 cannot handle both RX and TX at the same time, we have to stay quite once first ISO/TP packet was detected this is a pretty temporary hack only while we are trying ELM327, long term ISO/TP and rusEFI broadcast should find a way to coexists

Definition at line 116 of file engine.h.

Referenced by CanWrite::PeriodicTask(), and CanStreamerState::receiveFrame().

◆ rpmCalculator

RpmCalculator Engine::rpmCalculator

◆ scheduler [1/3]

SingleTimerExecutor Engine::scheduler

◆ scheduler [2/3]

SleepExecutor Engine::scheduler

Definition at line 256 of file engine.h.

◆ scheduler [3/3]

TestExecutor Engine::scheduler

Definition at line 259 of file engine.h.

◆ sensors

SensorsState Engine::sensors

◆ sent_state

sent_state_s Engine::sent_state

Definition at line 329 of file engine.h.

Referenced by getLiveData(), and SentDecoderThread().

◆ shiftTorqueReductionController

ShiftTorqueReductionController Engine::shiftTorqueReductionController

◆ slowCallBackWasInvoked

bool Engine::slowCallBackWasInvoked = false

Definition at line 285 of file engine.h.

Referenced by EngineState::periodicFastCallback(), and periodicSlowCallback().

◆ softSparkLimiter

SoftSparkLimiter Engine::softSparkLimiter

Definition at line 204 of file engine.h.

Referenced by onTriggerEventSparkLogic(), and EngineState::updateSparkSkip().

◆ startStopState

StartStopState Engine::startStopState

◆ tdcMarkEnabled

bool Engine::tdcMarkEnabled = true

Definition at line 281 of file engine.h.

Referenced by tdcMarkCallback().

◆ tdcScheduler

scheduling_s Engine::tdcScheduler[2]

Definition at line 271 of file engine.h.

Referenced by tdcMarkCallback().

◆ timeToStopBlip

efitimeus_t Engine::timeToStopBlip = 0

Definition at line 336 of file engine.h.

Referenced by blipIdle(), IdleController::getIdlePosition(), and undoIdleBlipIfNeeded().

◆ timeToStopIdleTest

efitimeus_t Engine::timeToStopIdleTest = 0

Definition at line 337 of file engine.h.

Referenced by applyIACposition(), finishIdleTestIfNeeded(), and startIdleBench().

◆ triggerCentral

TriggerCentral Engine::triggerCentral

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