2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file engine_state.h
|
|
|
|
* @brief One header which acts as gateway to current engine state
|
|
|
|
*
|
|
|
|
* @date Dec 20, 2013
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
2019-10-07 22:49:42 -07:00
|
|
|
#pragma once
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-05-27 16:05:59 -07:00
|
|
|
#include "global.h"
|
|
|
|
#include "engine_parts.h"
|
|
|
|
#include "pid.h"
|
2019-06-17 09:18:55 -07:00
|
|
|
#include "engine_state_generated.h"
|
2019-05-27 16:05:59 -07:00
|
|
|
|
2019-09-19 19:56:54 -07:00
|
|
|
#define BRAIN_PIN_COUNT (1 << sizeof(brain_pin_e))
|
|
|
|
|
2019-06-17 09:18:55 -07:00
|
|
|
class EngineState : public engine_state2_s {
|
2019-05-27 16:05:59 -07:00
|
|
|
public:
|
|
|
|
EngineState();
|
|
|
|
void periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
|
|
|
void updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
|
|
|
void updateTChargeK(int rpm, float tps DECLARE_ENGINE_PARAMETER_SUFFIX);
|
|
|
|
|
2019-09-19 19:56:54 -07:00
|
|
|
#if ! EFI_PROD_CODE
|
|
|
|
bool mockPinStates[BRAIN_PIN_COUNT];
|
|
|
|
#endif
|
|
|
|
|
2019-05-27 16:05:59 -07:00
|
|
|
FuelConsumptionState fuelConsumption;
|
|
|
|
|
|
|
|
efitick_t crankingTime = 0;
|
|
|
|
efitick_t timeSinceCranking = 0;
|
|
|
|
|
|
|
|
WarningCodeState warnings;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* speed-density logic, calculated air flow in kg/h for tCharge Air-Interp. method
|
|
|
|
*/
|
|
|
|
float airFlow = 0;
|
|
|
|
|
|
|
|
float engineNoiseHipLevel = 0;
|
|
|
|
|
|
|
|
float auxValveStart = 0;
|
|
|
|
float auxValveEnd = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MAP averaging angle start, in relation to 'mapAveragingSchedulingAtIndex' trigger index index
|
|
|
|
*/
|
|
|
|
angle_t mapAveragingStart[INJECTION_PIN_COUNT];
|
|
|
|
angle_t mapAveragingDuration = 0;
|
|
|
|
|
2019-11-23 20:42:00 -08:00
|
|
|
/**
|
|
|
|
* timing advance is angle distance before Top Dead Center (TDP), i.e. "10 degree timing advance" means "happens 10 degrees before TDC"
|
|
|
|
*/
|
2019-05-27 16:05:59 -07:00
|
|
|
angle_t timingAdvance = 0;
|
|
|
|
// fuel-related;
|
|
|
|
float fuelCutoffCorrection = 0;
|
|
|
|
efitick_t coastingFuelCutStartTime = 0;
|
|
|
|
|
|
|
|
efitick_t timeSinceLastTChargeK;
|
|
|
|
|
|
|
|
float currentRawVE = 0;
|
|
|
|
|
|
|
|
int vssEventCounter = 0;
|
|
|
|
|
2020-07-05 13:25:19 -07:00
|
|
|
float fuelingLoad = 0;
|
|
|
|
float ignitionLoad = 0;
|
2019-05-27 16:05:59 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Raw fuel injection duration produced by current fuel algorithm, without any correction
|
|
|
|
*/
|
|
|
|
floatms_t baseFuel = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TPS acceleration: extra fuel amount
|
|
|
|
*/
|
|
|
|
floatms_t tpsAccelEnrich = 0;
|
|
|
|
|
|
|
|
angle_t injectionOffset = 0;
|
|
|
|
|
|
|
|
#if EFI_ENABLE_MOCK_ADC
|
|
|
|
MockAdcState mockAdcState;
|
|
|
|
#endif /* EFI_ENABLE_MOCK_ADC */
|
2019-09-19 19:56:54 -07:00
|
|
|
|
2020-03-26 08:52:19 -07:00
|
|
|
multispark_state multispark;
|
2019-05-27 16:05:59 -07:00
|
|
|
};
|