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 30 of file engine2.cpp.

30  {
31  clear();
32 }
Here is the call graph for this function:

Member Function Documentation

◆ addWarningCode()

void WarningCodeState::addWarningCode ( ObdCode  code)

Definition at line 40 of file engine2.cpp.

40  {
43 
44  warning_t* existing = recentWarnings.find(code);
45 
46  if (!existing) {
47  chibios_rt::CriticalSectionLocker csl;
48 
49  // Add the code to the list
50  existing = recentWarnings.add(warning_t(code));
51  }
52 
53  if (existing) {
54  // Reset the timer on the code to now
55  existing->LastTriggered.reset();
56  }
57 
58  // Reset the "any warning" timer too
59  timeSinceLastWarning.reset();
60 }
uint8_t code
Definition: bluetooth.cpp:39
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 34 of file engine2.cpp.

34  {
35  warningCounter = 0;
38 }

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 65 of file engine2.cpp.

65  {
67 
68  return !timeSinceLastWarning.hasElapsedSec(period);
69 }
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 72 of file engine2.cpp.

72  {
74 
75  // No warning found at all
76  if (!warn) {
77  return false;
78  }
79 
80  // If the warning is old, it is not active
81  return !warn->LastTriggered.hasElapsedSec(maxI(3, engineConfiguration->warningPeriod));
82 }
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: