rusEFI
The most advanced open source ECU
Public Member Functions | Data Fields
WarningCodeState Class Reference

#include <engine_parts.h>

Collaboration diagram for WarningCodeState:
Collaboration graph
[legend]

Public Member Functions

 WarningCodeState ()
 
void addWarningCode (ObdCode code)
 
bool isWarningNow () const
 
bool isWarningNow (ObdCode code) const
 
void clear ()
 

Data Fields

int warningCounter
 
ObdCode lastErrorCode = ObdCode::None
 
Timer timeSinceLastWarning
 
warningBuffer_t recentWarnings
 

Detailed Description

Definition at line 55 of file engine_parts.h.

Constructor & Destructor Documentation

◆ WarningCodeState()

WarningCodeState::WarningCodeState ( )

Definition at line 26 of file engine2.cpp.

26  {
27  clear();
28 }
Here is the call graph for this function:

Member Function Documentation

◆ addWarningCode()

void WarningCodeState::addWarningCode ( ObdCode  code)

Definition at line 36 of file engine2.cpp.

36  {
39 
40  warning_t* existing = recentWarnings.find(code);
41 
42  if (!existing) {
43  chibios_rt::CriticalSectionLocker csl;
44 
45  // Add the code to the list
46  existing = recentWarnings.add(warning_t(code));
47  }
48 
49  if (existing) {
50  // Reset the timer on the code to now
51  existing->LastTriggered.reset();
52  }
53 
54  // Reset the "any warning" timer too
55  timeSinceLastWarning.reset();
56 }
uint8_t code
Definition: bluetooth.cpp:40
warningBuffer_t recentWarnings
Definition: engine_parts.h:68
ObdCode lastErrorCode
Definition: engine_parts.h:63
Timer timeSinceLastWarning
Definition: engine_parts.h:65
T * find(const TSearch &search) const
Definition: static_vector.h:11
T * add(const T &value)
Definition: static_vector.h:21
Timer LastTriggered
Definition: engine_parts.h:32

Referenced by firmwareError(), and warning().

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

◆ clear()

void WarningCodeState::clear ( )

Definition at line 30 of file engine2.cpp.

30  {
31  warningCounter = 0;
34 }

Referenced by WarningCodeState().

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

◆ isWarningNow() [1/2]

bool WarningCodeState::isWarningNow ( ) const
Parameters
forIndicatorif we want to retrieving value for TS indicator, this case a minimal period is applued

Definition at line 61 of file engine2.cpp.

61  {
63 
64  return !timeSinceLastWarning.hasElapsedSec(period);
65 }
beuint32_t period
engine_configuration_s * engineConfiguration

Referenced by updateTunerStudioState(), and warning().

Here is the caller graph for this function:

◆ isWarningNow() [2/2]

bool WarningCodeState::isWarningNow ( ObdCode  code) const

Definition at line 68 of file engine2.cpp.

68  {
70 
71  // No warning found at all
72  if (!warn) {
73  return false;
74  }
75 
76  // If the warning is old, it is not active
77  return !warn->LastTriggered.hasElapsedSec(maxI(3, engineConfiguration->warningPeriod));
78 }
Here is the call graph for this function:

Field Documentation

◆ lastErrorCode

ObdCode WarningCodeState::lastErrorCode = ObdCode::None

◆ recentWarnings

warningBuffer_t WarningCodeState::recentWarnings

Definition at line 68 of file engine_parts.h.

Referenced by addWarningCode(), clear(), isWarningNow(), and updateWarningCodes().

◆ timeSinceLastWarning

Timer WarningCodeState::timeSinceLastWarning

Definition at line 65 of file engine_parts.h.

Referenced by addWarningCode(), and isWarningNow().

◆ warningCounter

int WarningCodeState::warningCounter

Definition at line 62 of file engine_parts.h.

Referenced by addWarningCode(), clear(), populateFrame(), and updateWarningCodes().


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