rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
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, const char *text=nullptr)
 
bool isWarningNow () const
 
bool isWarningNow (ObdCode code) const
 
bool hasWarningMessage ()
 
const chargetWarningMessage ()
 
void refreshTs ()
 
void clear ()
 

Data Fields

int warningCounter
 
ObdCode lastErrorCode = ObdCode::None
 
const chardescription
 
Timer timeSinceLastWarning
 
critical_msg_t m_msg
 
warning_tm_msgWarning = nullptr
 
warningBuffer_t recentWarnings
 

Detailed Description

Definition at line 55 of file engine_parts.h.

Constructor & Destructor Documentation

◆ WarningCodeState()

WarningCodeState::WarningCodeState ( )

Definition at line 28 of file engine2.cpp.

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

Member Function Documentation

◆ addWarningCode()

void WarningCodeState::addWarningCode ( ObdCode  code,
const char text = nullptr 
)

Definition at line 38 of file engine2.cpp.

38 {
41
42 warning_t* existing = recentWarnings.find(code);
43 if (!existing) {
44 chibios_rt::CriticalSectionLocker csl;
45
46 // Add the code to the list
47 existing = recentWarnings.add(warning_t(code));
48 }
49
50 if (existing) {
51 // Reset the timer on the code to now
52 existing->LastTriggered.reset();
53
54 // no pending message? lets try to add this
55 if ((m_msgWarning == nullptr) && (text)) {
56 strlncpy(m_msg, text, sizeof(m_msg));
57 m_msgWarning = existing;
58 }
59 }
60
61 // Reset the "any warning" timer too
63}
uint8_t code
Definition bluetooth.cpp:40
warningBuffer_t recentWarnings
ObdCode lastErrorCode
warning_t * m_msgWarning
critical_msg_t m_msg
Timer timeSinceLastWarning
T * add(const T &value)
T * find(const TSearch &search) const
Timer LastTriggered

Referenced by firmwareErrorV(), and warningVA().

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

◆ clear()

void WarningCodeState::clear ( )

Definition at line 32 of file engine2.cpp.

Referenced by WarningCodeState().

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

◆ getWarningMessage()

const char * WarningCodeState::getWarningMessage ( )

Definition at line 107 of file engine2.cpp.

107 {
108 return m_msg;
109}

Referenced by handleGetConfigErorr().

Here is the caller graph for this function:

◆ hasWarningMessage()

bool WarningCodeState::hasWarningMessage ( )

Definition at line 102 of file engine2.cpp.

102 {
103 // Do we have any error code to show as text?
104 return (m_msgWarning != nullptr);
105}

Referenced by updateTunerStudioState().

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

114 {
116
117 return !timeSinceLastWarning.hasElapsedSec(period);
118}
beuint32_t period
static constexpr engine_configuration_s * engineConfiguration

Referenced by updateTunerStudioState(), and warningVA().

Here is the caller graph for this function:

◆ isWarningNow() [2/2]

bool WarningCodeState::isWarningNow ( ObdCode  code) const

Definition at line 121 of file engine2.cpp.

121 {
123
124 // No warning found at all
125 if (!warn) {
126 return false;
127 }
128
129 // If the warning is old, it is not active
130 return !warn->LastTriggered.hasElapsedSec(maxI(3, engineConfiguration->warningPeriod));
131}
Here is the call graph for this function:

◆ refreshTs()

void WarningCodeState::refreshTs ( )

Definition at line 65 of file engine2.cpp.

65 {
67 const int period = maxI(3, engineConfiguration->warningPeriod);
68
69 // TODO: do we neet this sticky warning code?
71 tsOutputChannels->lastErrorCode = static_cast<uint16_t>(engine->engineState.warnings.lastErrorCode);
72
73 // TODO: fix OBD codes "jumping" between positions when one of codes disapears
74
75 size_t i = 0;
76 for (size_t j = 0; j < recentWarnings.getCount(); j++) {
77 warning_t& warn = recentWarnings.get(j);
78 if (warn.Code != ObdCode::None) {
79 if (!warn.LastTriggered.hasElapsedSec(period)) {
80 if (i < efi::size(tsOutputChannels->recentErrorCode)) {
81 tsOutputChannels->recentErrorCode[i] = static_cast<uint16_t>(warn.Code);
82 i++;
83 }
84 } else {
85 // warning message is outdated, stop showing to TS
86 if (m_msgWarning == &warn) {
87 m_msg[0] = 0;
88 m_msgWarning = nullptr;
89 }
90 // TODO:
91 // reset warning as it is outdated
92 }
93 }
94 }
95
96 // reset rest
97 for ( ; i < efi::size(tsOutputChannels->recentErrorCode); i++) {
98 tsOutputChannels->recentErrorCode[i] = 0;
99 }
100}
EngineState engineState
Definition engine.h:344
TunerStudioOutputChannels outputChannels
Definition engine.h:109
WarningCodeState warnings
static EngineAccessor engine
Definition engine.h:413
T & get(size_t i)
size_t getCount() const
ObdCode Code

Referenced by updateTunerStudioState().

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

Field Documentation

◆ description

const char* WarningCodeState::description

Definition at line 67 of file engine_parts.h.

◆ lastErrorCode

ObdCode WarningCodeState::lastErrorCode = ObdCode::None

◆ m_msg

critical_msg_t WarningCodeState::m_msg

Definition at line 72 of file engine_parts.h.

Referenced by addWarningCode(), getWarningMessage(), and refreshTs().

◆ m_msgWarning

warning_t* WarningCodeState::m_msgWarning = nullptr

Definition at line 73 of file engine_parts.h.

Referenced by addWarningCode(), hasWarningMessage(), and refreshTs().

◆ recentWarnings

warningBuffer_t WarningCodeState::recentWarnings

Definition at line 76 of file engine_parts.h.

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

◆ timeSinceLastWarning

Timer WarningCodeState::timeSinceLastWarning

Definition at line 69 of file engine_parts.h.

Referenced by addWarningCode(), and isWarningNow().

◆ warningCounter

int WarningCodeState::warningCounter

Definition at line 65 of file engine_parts.h.

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


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