2020-08-17 02:22:25 -07:00
|
|
|
#pragma once
|
|
|
|
|
2020-11-10 20:11:22 -08:00
|
|
|
#include "expected.h"
|
2020-08-17 02:22:25 -07:00
|
|
|
|
2020-08-17 14:03:59 -07:00
|
|
|
struct IInjectorModel {
|
|
|
|
virtual void prepare() = 0;
|
|
|
|
virtual floatms_t getInjectionDuration(float fuelMassGram) const = 0;
|
2021-03-03 04:30:56 -08:00
|
|
|
virtual float getFuelMassForDuration(floatms_t duration) const = 0;
|
2020-08-17 14:03:59 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class InjectorModelBase : public IInjectorModel {
|
2020-08-17 02:22:25 -07:00
|
|
|
public:
|
2020-08-17 14:03:59 -07:00
|
|
|
void prepare() override;
|
|
|
|
floatms_t getInjectionDuration(float fuelMassGram) const override;
|
2021-03-03 04:30:56 -08:00
|
|
|
float getFuelMassForDuration(floatms_t duration) const override;
|
2020-08-17 02:22:25 -07:00
|
|
|
|
|
|
|
virtual floatms_t getDeadtime() const = 0;
|
|
|
|
virtual float getInjectorMassFlowRate() const = 0;
|
2020-11-10 20:11:22 -08:00
|
|
|
virtual float getInjectorFlowRatio() const = 0;
|
|
|
|
virtual expected<float> getAbsoluteRailPressure() const = 0;
|
2021-07-07 20:46:44 -07:00
|
|
|
virtual float correctShortPulse(float baseDuration) const = 0;
|
2020-08-17 02:22:25 -07:00
|
|
|
|
2020-10-26 04:23:13 -07:00
|
|
|
virtual void postState(float deadTime) const { (void)deadTime; };
|
2020-10-23 17:25:47 -07:00
|
|
|
|
2020-08-17 02:22:25 -07:00
|
|
|
private:
|
|
|
|
float m_deadtime = 0;
|
|
|
|
float m_massFlowRate = 0;
|
|
|
|
};
|
|
|
|
|
2021-11-16 13:52:11 -08:00
|
|
|
class InjectorModel : public InjectorModelBase {
|
2020-08-17 02:22:25 -07:00
|
|
|
public:
|
2020-10-23 17:25:47 -07:00
|
|
|
void postState(float deadtime) const override;
|
2020-08-17 02:22:25 -07:00
|
|
|
floatms_t getDeadtime() const override;
|
|
|
|
float getInjectorMassFlowRate() const override;
|
2020-11-10 20:11:22 -08:00
|
|
|
float getInjectorFlowRatio() const override;
|
|
|
|
expected<float> getAbsoluteRailPressure() const override;
|
2021-07-07 20:46:44 -07:00
|
|
|
|
|
|
|
// Small pulse correction logic
|
|
|
|
float correctShortPulse(float baseDuration) const override;
|
|
|
|
virtual float correctInjectionPolynomial(float baseDuration) const;
|
2020-08-17 02:22:25 -07:00
|
|
|
};
|