refactoring: reducing outputChannels copy
This commit is contained in:
parent
ea1d2b848f
commit
7e340cceb3
|
@ -90,6 +90,7 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 5, 0
|
|||
int16_t autoscale tCharge;;"deg C",{1/@@PACK_MULT_TEMPERATURE@@}, 0, 0, 0, 0
|
||||
|
||||
! Corrections
|
||||
! todo: inline this further to injectorModel deadTime
|
||||
uint16_t autoscale injectorLagMs;@@GAUGE_NAME_INJECTOR_LAG@@;"ms",{1/@@PACK_MULT_MS@@}, 0, 0, 0, 0
|
||||
uint16_t autoscale iatCorrection;@@GAUGE_NAME_FUEL_IAT_CORR@@;"%",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0
|
||||
uint16_t autoscale cltCorrection;@@GAUGE_NAME_FUEL_CLT_CORR@@;"%",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0
|
||||
|
|
|
@ -314,7 +314,7 @@ static void showFuelInfo2(float rpm, float engineLoad) {
|
|||
if (!engine->rpmCalculator.isStopped()) {
|
||||
float iatCorrection = engine->engineState.running.intakeTemperatureCoefficient;
|
||||
float cltCorrection = engine->engineState.running.coolantTemperatureCoefficient;
|
||||
floatms_t injectorLag = engine->engineState.running.injectorLag;
|
||||
floatms_t injectorLag = engine->module<InjectorModel>()->getDeadtime();
|
||||
efiPrintf("rpm=%.2f engineLoad=%.2f", rpm, engineLoad);
|
||||
|
||||
efiPrintf("iatCorrection=%.2f cltCorrection=%.2f injectorLag=%.2f", iatCorrection, cltCorrection,
|
||||
|
@ -627,7 +627,8 @@ static void updateFuelCorrections() {
|
|||
engine->outputChannels.fuelPidCorrection[0] = 100.0f * (engine->stftCorrection[0] - 1.0f);
|
||||
engine->outputChannels.fuelPidCorrection[1] = 100.0f * (engine->stftCorrection[1] - 1.0f);
|
||||
|
||||
engine->outputChannels.injectorLagMs = engine->engineState.running.injectorLag;
|
||||
// get rid of this, have gauges use injector model info directly
|
||||
engine->outputChannels.injectorLagMs = engine->module<InjectorModel>()->getDeadtime();
|
||||
}
|
||||
|
||||
static void updateFuelLoads() {
|
||||
|
|
|
@ -73,9 +73,6 @@ float postCrankingFuelCorrection
|
|||
float intakeTemperatureCoefficient
|
||||
float coolantTemperatureCoefficient
|
||||
float timeSinceCrankingInSecs
|
||||
|
||||
|
||||
floatms_t injectorLag;injectorLag(VBatt)\nthis value depends on a slow-changing VBatt value, so\nwe update it once in a while
|
||||
|
||||
floatms_t baseFuel;
|
||||
floatms_t fuel;Actual injection duration with CLT, IAT and TPS acceleration corrections per cycle, as squirt duration.\nWithout injector lag.\n@see baseFuel\n@see actualLastInjection
|
||||
|
|
|
@ -5,10 +5,7 @@
|
|||
|
||||
void InjectorModelBase::prepare() {
|
||||
m_massFlowRate = getInjectorMassFlowRate();
|
||||
float deadtime = getDeadtime();
|
||||
m_deadtime = deadtime;
|
||||
|
||||
postState(deadtime);
|
||||
m_deadtime = getDeadtime();
|
||||
}
|
||||
|
||||
constexpr float convertToGramsPerSecond(float ccPerMinute) {
|
||||
|
@ -93,10 +90,6 @@ float InjectorModel::getDeadtime() const {
|
|||
);
|
||||
}
|
||||
|
||||
void InjectorModel::postState(float deadtime) const {
|
||||
engine->engineState.running.injectorLag = deadtime;
|
||||
}
|
||||
|
||||
float InjectorModelBase::getInjectionDuration(float fuelMassGram) const {
|
||||
// TODO: support injector nonlinearity correction
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ struct IInjectorModel : public EngineModule {
|
|||
virtual void prepare() = 0;
|
||||
virtual floatms_t getInjectionDuration(float fuelMassGram) const = 0;
|
||||
virtual float getFuelMassForDuration(floatms_t duration) const = 0;
|
||||
virtual floatms_t getDeadtime() const = 0;
|
||||
};
|
||||
|
||||
class InjectorModelBase : public IInjectorModel, public injector_model_s {
|
||||
|
@ -15,21 +16,18 @@ public:
|
|||
floatms_t getInjectionDuration(float fuelMassGram) const override;
|
||||
float getFuelMassForDuration(floatms_t duration) const override;
|
||||
|
||||
virtual floatms_t getDeadtime() const = 0;
|
||||
virtual float getInjectorMassFlowRate() = 0;
|
||||
virtual float getInjectorFlowRatio() = 0;
|
||||
virtual expected<float> getAbsoluteRailPressure() const = 0;
|
||||
virtual float correctShortPulse(float baseDuration) const = 0;
|
||||
|
||||
virtual void postState(float deadTime) const { (void)deadTime; };
|
||||
|
||||
private:
|
||||
float m_massFlowRate = 0;
|
||||
};
|
||||
|
||||
class InjectorModel : public InjectorModelBase {
|
||||
public:
|
||||
void postState(float deadtime) const override;
|
||||
|
||||
floatms_t getDeadtime() const override;
|
||||
float getInjectorMassFlowRate() override;
|
||||
float getInjectorFlowRatio() override;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
struct_no_prefix injector_model_s
|
||||
float m_deadtime
|
||||
float m_deadtime;injectorLag(VBatt)\nthis value depends on a slow-changing VBatt value, so\nwe update it once in a while
|
||||
|
||||
float pressureDelta;fuel: injector pressureDelta;"kPa", 1, 0, -10000, 10000, 1
|
||||
float pressureRatio;fuel: injector pressureRatio;"", 1, 0, -10000, 10000, 3
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ static void showLine(lcd_line_e line, int /*screenY*/) {
|
|||
lcdPrintf("IAT corr %.2f", getIatFuelCorrection());
|
||||
return;
|
||||
case LL_FUEL_INJECTOR_LAG:
|
||||
lcdPrintf("ING LAG %.2f", engine->engineState.running.injectorLag);
|
||||
lcdPrintf("ING LAG %.2f", engine->module<InjectorModel>()->m_deadtime);
|
||||
return;
|
||||
case LL_VBATT:
|
||||
lcdPrintf("Battery %.2fv", Sensor::getOrZero(SensorType::BatteryVoltage));
|
||||
|
|
|
@ -113,8 +113,6 @@ float getOutputValueByName(const char *name) {
|
|||
return engine->outputChannels.injectionOffset;
|
||||
if (strEqualCaseInsensitive(name, "tCharge"))
|
||||
return engine->outputChannels.tCharge;
|
||||
if (strEqualCaseInsensitive(name, "injectorLagMs"))
|
||||
return engine->outputChannels.injectorLagMs;
|
||||
if (strEqualCaseInsensitive(name, "iatCorrection"))
|
||||
return engine->outputChannels.iatCorrection;
|
||||
if (strEqualCaseInsensitive(name, "cltCorrection"))
|
||||
|
|
|
@ -101,6 +101,7 @@ public:
|
|||
MOCK_METHOD(void, prepare, (), (override));
|
||||
MOCK_METHOD(floatms_t, getInjectionDuration, (float fuelMassGram), (const, override));
|
||||
MOCK_METHOD(float, getFuelMassForDuration, (floatms_t duration), (const, override));
|
||||
MOCK_METHOD(floatms_t, getDeadtime, (), (const, override));
|
||||
};
|
||||
|
||||
class MockStepperHardware : public StepperHw {
|
||||
|
|
|
@ -612,7 +612,7 @@ static void setTestBug299(EngineTestHelper *eth) {
|
|||
|
||||
ASSERT_EQ( 1, engine->engineState.running.intakeTemperatureCoefficient) << "iatC";
|
||||
ASSERT_EQ( 1, engine->engineState.running.coolantTemperatureCoefficient) << "cltC";
|
||||
ASSERT_EQ( 0, engine->engineState.running.injectorLag) << "lag";
|
||||
ASSERT_EQ( 0, engine->module<InjectorModel>()->getDeadtime()) << "lag";
|
||||
|
||||
ASSERT_EQ( 3000, round(Sensor::getOrZero(SensorType::Rpm))) << "setTestBug299: RPM";
|
||||
|
||||
|
|
Loading…
Reference in New Issue