lambda monitor live data (#5469)
Co-authored-by: Matthew Kennedy <matthewkennedy@outlook.com>
This commit is contained in:
parent
13e54c006f
commit
99f4c04192
|
@ -180,6 +180,11 @@ const throttle_model_s* getLiveData(size_t) {
|
|||
#endif
|
||||
}
|
||||
|
||||
template<>
|
||||
const lambda_monitor_s* getLiveData(size_t) {
|
||||
return &engine->lambdaMonitor;
|
||||
}
|
||||
|
||||
static const FragmentEntry fragments[] = {
|
||||
// This header is generated - do not edit by hand!
|
||||
#include "live_data_fragments.h"
|
||||
|
|
|
@ -13,23 +13,27 @@ float LambdaMonitor::getMaxAllowedLambda(float rpm, float load) const {
|
|||
}
|
||||
|
||||
bool LambdaMonitorBase::isCut() const {
|
||||
return m_isCut;
|
||||
return lambdaMonitorCut;
|
||||
}
|
||||
|
||||
void LambdaMonitorBase::update(float rpm, float load) {
|
||||
if (isCurrentlyGood(rpm, load)) {
|
||||
bool isGood = isCurrentlyGood(rpm, load);
|
||||
lambdaCurrentlyGood = isGood;
|
||||
if (isGood) {
|
||||
m_timeSinceGoodLambda.reset();
|
||||
}
|
||||
|
||||
lambdaTimeSinceGood = m_timeSinceGoodLambda.getElapsedSeconds();
|
||||
|
||||
if (m_timeSinceGoodLambda.hasElapsedSec(engineConfiguration->lambdaProtectionTimeout)) {
|
||||
// Things have been bad long enough, cut!
|
||||
m_isCut = true;
|
||||
lambdaMonitorCut = true;
|
||||
}
|
||||
|
||||
if (m_isCut) {
|
||||
if (lambdaMonitorCut) {
|
||||
// If things are back to normal, cancel the cut and force a reset
|
||||
if (restoreConditionsMet(rpm, load)) {
|
||||
m_isCut = false;
|
||||
lambdaMonitorCut = false;
|
||||
m_timeSinceGoodLambda.reset();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
struct LambdaMonitorBase {
|
||||
#include "lambda_monitor_generated.h"
|
||||
|
||||
struct LambdaMonitorBase : public lambda_monitor_s {
|
||||
void update(float rpm, float load);
|
||||
bool isCut() const;
|
||||
|
||||
|
@ -19,7 +21,6 @@ protected:
|
|||
|
||||
private:
|
||||
Timer m_timeSinceGoodLambda;
|
||||
bool m_isCut = false;
|
||||
};
|
||||
|
||||
class LambdaMonitor : public LambdaMonitorBase {
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
struct_no_prefix lambda_monitor_s
|
||||
bit lambdaCurrentlyGood
|
||||
bit lambdaMonitorCut
|
||||
uint16_t autoscale lambdaTimeSinceGood;;"sec", 0.01, 0, 0, 1, 2
|
||||
end_struct
|
|
@ -176,3 +176,8 @@ Usages:
|
|||
- name: vvt
|
||||
java: VvtState.java
|
||||
folder: controllers/actuators
|
||||
|
||||
- name: lambda_monitor
|
||||
java: LambdaMonitor.java
|
||||
folder: controllers/math
|
||||
constexpr: "___engine.lambdaMonitor"
|
||||
|
|
Loading…
Reference in New Issue