rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
closed_loop_fuel_cell.h
Go to the documentation of this file.
1#pragma once
2
3#include "sensor.h"
4
6public:
7 // Update the cell's internal state - adjusting fuel up/down as appropriate
8 void update(float lambdaDeadband, bool ignoreErrorMagnitude);
9
10 // Get the current adjustment amount, without altering internal state.
11 float getAdjustment() const;
12
13 virtual float getLambdaError() const = 0;
14protected:
15 // Helpers - virtual for mocking
16 virtual float getMaxAdjustment() const = 0;
17 virtual float getMinAdjustment() const = 0;
18 virtual float getIntegratorGain() const = 0;
19
20private:
21 // Current fueling adjustment.
22 // 0 = no adjustment.
23 // 0.1 = add 10% fuel.
24 float m_adjustment = 0;
25};
26
27struct stft_cell_cfg_s;
28
30public:
31 void configure(const stft_cell_cfg_s* configuration, SensorType lambdaSensor) {
32 m_config = configuration;
34 }
35
36 float getLambdaError() const override;
37private:
38 const stft_cell_cfg_s *m_config = nullptr;
40
41protected:
42 float getMaxAdjustment() const override;
43 float getMinAdjustment() const override;
44 float getIntegratorGain() const override;
45};
virtual float getMaxAdjustment() const =0
virtual float getLambdaError() const =0
virtual float getIntegratorGain() const =0
virtual float getMinAdjustment() const =0
void update(float lambdaDeadband, bool ignoreErrorMagnitude)
const stft_cell_cfg_s * m_config
float getIntegratorGain() const override
float getMaxAdjustment() const override
void configure(const stft_cell_cfg_s *configuration, SensorType lambdaSensor)
float getMinAdjustment() const override
float getLambdaError() const override
static FunctionPointerSensor lambdaSensor(SensorType::Lambda1, []() { return afrWrapper.getLambda();})
Base class for sensors. Inherit this class to implement a new type of sensor.
SensorType
Definition sensor_type.h:18