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

#include <main_relay.h>

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

Public Member Functions

void onSlowCallback () override
 
bool needsDelayedShutoff () override
 
- Public Member Functions inherited from EngineModule
virtual void onConfigurationChange (engine_configuration_s const *)
 
virtual void onFastCallback ()
 
virtual void onIgnitionStateChanged (bool)
 

Private Attributes

Timer m_lastIgnitionTime
 

Additional Inherited Members

- Data Fields inherited from main_relay_s
bool isBenchTest: 1 {}
 
bool hasIgnitionVoltage: 1 {}
 
bool mainRelayState: 1 {}
 
bool delayedShutoffRequested: 1 {}
 
bool unusedBit_4_4: 1 {}
 
bool unusedBit_4_5: 1 {}
 
bool unusedBit_4_6: 1 {}
 
bool unusedBit_4_7: 1 {}
 
bool unusedBit_4_8: 1 {}
 
bool unusedBit_4_9: 1 {}
 
bool unusedBit_4_10: 1 {}
 
bool unusedBit_4_11: 1 {}
 
bool unusedBit_4_12: 1 {}
 
bool unusedBit_4_13: 1 {}
 
bool unusedBit_4_14: 1 {}
 
bool unusedBit_4_15: 1 {}
 
bool unusedBit_4_16: 1 {}
 
bool unusedBit_4_17: 1 {}
 
bool unusedBit_4_18: 1 {}
 
bool unusedBit_4_19: 1 {}
 
bool unusedBit_4_20: 1 {}
 
bool unusedBit_4_21: 1 {}
 
bool unusedBit_4_22: 1 {}
 
bool unusedBit_4_23: 1 {}
 
bool unusedBit_4_24: 1 {}
 
bool unusedBit_4_25: 1 {}
 
bool unusedBit_4_26: 1 {}
 
bool unusedBit_4_27: 1 {}
 
bool unusedBit_4_28: 1 {}
 
bool unusedBit_4_29: 1 {}
 
bool unusedBit_4_30: 1 {}
 
bool unusedBit_4_31: 1 {}
 

Detailed Description

Definition at line 6 of file main_relay.h.

Member Function Documentation

◆ needsDelayedShutoff()

bool MainRelayController::needsDelayedShutoff ( )
overridevirtual

Reimplemented from EngineModule.

Definition at line 38 of file main_relay.cpp.

38  {
39  // Prevent main relay from turning off if we had ignition voltage in the past 1 second
40  // This avoids accidentally killing the car during a transient, for example
41  // right when the starter is engaged.
42  return !m_lastIgnitionTime.hasElapsedSec(1);
43 }
Timer m_lastIgnitionTime
Definition: main_relay.h:12

◆ onSlowCallback()

void MainRelayController::onSlowCallback ( )
overridevirtual

Reimplemented from EngineModule.

Definition at line 6 of file main_relay.cpp.

6  {
7 #if EFI_MAIN_RELAY_CONTROL
8 #if defined(IGN_KEY_DIVIDER)
11  } else
12 #endif // IGN_KEY_DIVIDER
14  // separate digital input pin just for main relay logic since it's preferred to read voltage from main relay
15  // key-on is usually a bit smaller voltage than main relay but sometimes even 1v off!
17  } else {
19  }
20 
21  if (hasIgnitionVoltage) {
22  m_lastIgnitionTime.reset();
23  }
24 
25  // Query whether any engine modules want to keep the lights on
26  delayedShutoffRequested = engine->engineModules.aggregate([](auto& m, bool prev) { return m.needsDelayedShutoff() | prev; }, false);
27 
28  // TODO: delayed shutoff timeout?
29 
31 #else // not EFI_MAIN_RELAY_CONTROL
32  mainRelayState = true;
33 #endif
34 
36 }
bool isAdcChannelValid(adc_channel_e hwChannel)
Definition: adc_inputs.h:20
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, 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 EngineModule > engineModules
Definition: engine.h:168
RegisteredOutputPin mainRelay
Definition: efi_gpio.h:73
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition: efi_gpio.cpp:583
static float getOrZero(SensorType type)
Definition: sensor.h:92
@ Unassigned
EnginePins enginePins
Definition: efi_gpio.cpp:24
Engine * engine
bool isIgnVoltage()
bool efiReadPin(brain_pin_e pin)
Definition: io_pins.cpp:89
engine_configuration_s * engineConfiguration
auto aggregate(func_t const &accumulator, return_t seed)
Definition: type_list.h:52
Here is the call graph for this function:

Field Documentation

◆ m_lastIgnitionTime

Timer MainRelayController::m_lastIgnitionTime
private

Definition at line 12 of file main_relay.h.

Referenced by needsDelayedShutoff(), and onSlowCallback().


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