I like C++11 :)
This commit is contained in:
parent
5b18f9f360
commit
8b0f885a84
|
@ -171,46 +171,13 @@ int Engine::getGlobalConfigurationVersion(void) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::reset() {
|
void Engine::reset() {
|
||||||
withError = isEngineChartEnabled = false;
|
|
||||||
etbAutoTune = false;
|
|
||||||
sensorChartMode = SC_OFF;
|
|
||||||
actualLastInjection = 0;
|
|
||||||
fsioState.fsioTimingAdjustment = 0;
|
|
||||||
fsioState.fsioIdleTargetRPMAdjustment = 0;
|
|
||||||
isAlternatorControlEnabled = false;
|
|
||||||
callFromPitStopEndTime = 0;
|
|
||||||
rpmHardLimitTimestamp = 0;
|
|
||||||
wallFuelCorrection = 0;
|
|
||||||
/**
|
/**
|
||||||
* it's important for fixAngle() that engineCycle field never has zero
|
* it's important for fixAngle() that engineCycle field never has zero
|
||||||
*/
|
*/
|
||||||
engineCycle = getEngineCycle(FOUR_STROKE_CRANK_SENSOR);
|
engineCycle = getEngineCycle(FOUR_STROKE_CRANK_SENSOR);
|
||||||
lastTriggerToothEventTimeNt = 0;
|
|
||||||
isCylinderCleanupMode = false;
|
|
||||||
engineCycleEventCount = 0;
|
|
||||||
stopEngineRequestTimeNt = 0;
|
|
||||||
isRunningPwmTest = false;
|
|
||||||
isTestMode = false;
|
|
||||||
isSpinning = false;
|
|
||||||
isCltBroken = false;
|
|
||||||
adcToVoltageInputDividerCoefficient = NAN;
|
|
||||||
sensors.reset();
|
|
||||||
memset(&ignitionPin, 0, sizeof(ignitionPin));
|
memset(&ignitionPin, 0, sizeof(ignitionPin));
|
||||||
|
|
||||||
knockNow = false;
|
|
||||||
knockEver = false;
|
|
||||||
knockCount = 0;
|
|
||||||
knockDebug = false;
|
|
||||||
knockVolts = 0;
|
|
||||||
iHead = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
timeOfLastKnockEvent = 0;
|
|
||||||
injectionDuration = 0;
|
|
||||||
clutchDownState = clutchUpState = brakePedalState = false;
|
|
||||||
memset(&m, 0, sizeof(m));
|
memset(&m, 0, sizeof(m));
|
||||||
config = NULL;
|
|
||||||
engineConfigurationPtr = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -93,11 +93,11 @@ public:
|
||||||
*
|
*
|
||||||
* values are in Celsius
|
* values are in Celsius
|
||||||
*/
|
*/
|
||||||
float iat;
|
float iat = NAN;
|
||||||
#if EFI_UNIT_TEST
|
#if EFI_UNIT_TEST
|
||||||
float mockClt = NAN;
|
float mockClt = NAN;
|
||||||
#endif
|
#endif
|
||||||
float clt;
|
float clt = NAN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Oil pressure in kPa
|
* Oil pressure in kPa
|
||||||
|
@ -106,14 +106,12 @@ public:
|
||||||
|
|
||||||
Accelerometer accelerometer;
|
Accelerometer accelerometer;
|
||||||
|
|
||||||
float vBatt;
|
float vBatt = 0;
|
||||||
float currentAfr;
|
float currentAfr;
|
||||||
/**
|
/**
|
||||||
* that's fuel in tank - just a gauge
|
* that's fuel in tank - just a gauge
|
||||||
*/
|
*/
|
||||||
percent_t fuelTankGauge;
|
percent_t fuelTankGauge = 0;
|
||||||
|
|
||||||
void reset();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FuelConsumptionState {
|
class FuelConsumptionState {
|
||||||
|
@ -310,8 +308,8 @@ typedef void (*configuration_callback_t)(Engine*);
|
||||||
class FsioState {
|
class FsioState {
|
||||||
public:
|
public:
|
||||||
FsioState();
|
FsioState();
|
||||||
float fsioTimingAdjustment;
|
float fsioTimingAdjustment = 0;
|
||||||
float fsioIdleTargetRPMAdjustment;
|
float fsioIdleTargetRPMAdjustment = 0;
|
||||||
float servoValues[SERVO_COUNT];
|
float servoValues[SERVO_COUNT];
|
||||||
float fsioLastValue[FSIO_COMMAND_COUNT];
|
float fsioLastValue[FSIO_COMMAND_COUNT];
|
||||||
|
|
||||||
|
@ -370,25 +368,25 @@ public:
|
||||||
|
|
||||||
WallFuel wallFuel;
|
WallFuel wallFuel;
|
||||||
bool needToStopEngine(efitick_t nowNt);
|
bool needToStopEngine(efitick_t nowNt);
|
||||||
bool etbAutoTune;
|
bool etbAutoTune = false;
|
||||||
/**
|
/**
|
||||||
* That's the list of pending spark firing events
|
* That's the list of pending spark firing events
|
||||||
*/
|
*/
|
||||||
IgnitionEvent *iHead;
|
IgnitionEvent *iHead = NULL;
|
||||||
/**
|
/**
|
||||||
* this is based on isEngineChartEnabled and engineSnifferRpmThreshold settings
|
* this is based on isEngineChartEnabled and engineSnifferRpmThreshold settings
|
||||||
*/
|
*/
|
||||||
bool isEngineChartEnabled;
|
bool isEngineChartEnabled = false;
|
||||||
/**
|
/**
|
||||||
* this is based on sensorChartMode and sensorSnifferRpmThreshold settings
|
* this is based on sensorChartMode and sensorSnifferRpmThreshold settings
|
||||||
*/
|
*/
|
||||||
sensor_chart_e sensorChartMode;
|
sensor_chart_e sensorChartMode = SC_OFF;
|
||||||
/**
|
/**
|
||||||
* based on current RPM and isAlternatorControlEnabled setting
|
* based on current RPM and isAlternatorControlEnabled setting
|
||||||
*/
|
*/
|
||||||
bool isAlternatorControlEnabled;
|
bool isAlternatorControlEnabled = false;
|
||||||
|
|
||||||
bool isCltBroken;
|
bool isCltBroken = false;
|
||||||
bool slowCallBackWasInvoked = false;
|
bool slowCallBackWasInvoked = false;
|
||||||
|
|
||||||
|
|
||||||
|
@ -397,10 +395,10 @@ public:
|
||||||
/**
|
/**
|
||||||
* remote telemetry: if not zero, time to stop flashing 'CALL FROM PIT STOP' light
|
* remote telemetry: if not zero, time to stop flashing 'CALL FROM PIT STOP' light
|
||||||
*/
|
*/
|
||||||
efitime_t callFromPitStopEndTime;
|
efitime_t callFromPitStopEndTime = 0;
|
||||||
|
|
||||||
// timestamp of most recent time RPM hard limit was triggered
|
// timestamp of most recent time RPM hard limit was triggered
|
||||||
efitime_t rpmHardLimitTimestamp;
|
efitime_t rpmHardLimitTimestamp = 0;
|
||||||
|
|
||||||
// todo: should be a field on some other class, not Engine?
|
// todo: should be a field on some other class, not Engine?
|
||||||
bool isInitializingTrigger = false;
|
bool isInitializingTrigger = false;
|
||||||
|
@ -409,20 +407,20 @@ public:
|
||||||
* This flag indicated a big enough problem that engine control would be
|
* This flag indicated a big enough problem that engine control would be
|
||||||
* prohibited if this flag is set to true.
|
* prohibited if this flag is set to true.
|
||||||
*/
|
*/
|
||||||
bool withError;
|
bool withError = false;
|
||||||
|
|
||||||
RpmCalculator rpmCalculator;
|
RpmCalculator rpmCalculator;
|
||||||
persistent_config_s *config;
|
persistent_config_s *config = NULL;
|
||||||
/**
|
/**
|
||||||
* we use funny unique name to make sure that compiler is not confused between global variable and class member
|
* we use funny unique name to make sure that compiler is not confused between global variable and class member
|
||||||
* todo: this variable is probably a sign of some problem, should we even have it?
|
* todo: this variable is probably a sign of some problem, should we even have it?
|
||||||
*/
|
*/
|
||||||
engine_configuration_s *engineConfigurationPtr;
|
engine_configuration_s *engineConfigurationPtr = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this is about 'stopengine' command
|
* this is about 'stopengine' command
|
||||||
*/
|
*/
|
||||||
efitick_t stopEngineRequestTimeNt;
|
efitick_t stopEngineRequestTimeNt = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* always 360 or 720, never zero
|
* always 360 or 720, never zero
|
||||||
|
@ -439,27 +437,27 @@ public:
|
||||||
* including everything including injector lag, both cranking and running
|
* including everything including injector lag, both cranking and running
|
||||||
* @see getInjectionDuration()
|
* @see getInjectionDuration()
|
||||||
*/
|
*/
|
||||||
floatms_t injectionDuration;
|
floatms_t injectionDuration = 0;
|
||||||
/**
|
/**
|
||||||
* fuel injection time correction to account for wall wetting effect, for current cycle
|
* fuel injection time correction to account for wall wetting effect, for current cycle
|
||||||
*/
|
*/
|
||||||
floatms_t wallFuelCorrection;
|
floatms_t wallFuelCorrection = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This one with wall wetting accounted for, used for logging.
|
* This one with wall wetting accounted for, used for logging.
|
||||||
*/
|
*/
|
||||||
floatms_t actualLastInjection;
|
floatms_t actualLastInjection = 0;
|
||||||
|
|
||||||
void periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
void periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
void periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
void periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
void updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
void updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
void initializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
void initializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
bool clutchUpState;
|
bool clutchUpState = false;
|
||||||
bool clutchDownState;
|
bool clutchDownState = false;
|
||||||
bool brakePedalState;
|
bool brakePedalState = false;
|
||||||
|
|
||||||
bool isRunningPwmTest;
|
bool isRunningPwmTest = false;
|
||||||
|
|
||||||
|
|
||||||
FsioState fsioState;
|
FsioState fsioState;
|
||||||
|
@ -467,28 +465,28 @@ public:
|
||||||
/**
|
/**
|
||||||
* Are we experiencing knock right now?
|
* Are we experiencing knock right now?
|
||||||
*/
|
*/
|
||||||
bool knockNow;
|
bool knockNow = false;
|
||||||
/**
|
/**
|
||||||
* Have we experienced knock since engine was started?
|
* Have we experienced knock since engine was started?
|
||||||
*/
|
*/
|
||||||
bool knockEver;
|
bool knockEver = false;
|
||||||
/**
|
/**
|
||||||
* KnockCount is directly proportional to the degrees of ignition
|
* KnockCount is directly proportional to the degrees of ignition
|
||||||
* advance removed
|
* advance removed
|
||||||
*/
|
*/
|
||||||
int knockCount;
|
int knockCount = 0;
|
||||||
|
|
||||||
float knockVolts;
|
float knockVolts = 0;
|
||||||
|
|
||||||
bool knockDebug;
|
bool knockDebug = false;
|
||||||
|
|
||||||
efitimeus_t timeOfLastKnockEvent;
|
efitimeus_t timeOfLastKnockEvent = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* are we running any kind of functional test? this affect
|
* are we running any kind of functional test? this affect
|
||||||
* some areas
|
* some areas
|
||||||
*/
|
*/
|
||||||
bool isTestMode;
|
bool isTestMode = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -509,26 +507,26 @@ public:
|
||||||
void onTriggerSignalEvent(efitick_t nowNt);
|
void onTriggerSignalEvent(efitick_t nowNt);
|
||||||
EngineState engineState;
|
EngineState engineState;
|
||||||
SensorsState sensors;
|
SensorsState sensors;
|
||||||
efitick_t lastTriggerToothEventTimeNt;
|
efitick_t lastTriggerToothEventTimeNt = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This coefficient translates ADC value directly into voltage adjusted according to
|
* This coefficient translates ADC value directly into voltage adjusted according to
|
||||||
* voltage divider configuration with just one multiplication. This is a future (?) performance optimization.
|
* voltage divider configuration with just one multiplication. This is a future (?) performance optimization.
|
||||||
*/
|
*/
|
||||||
float adcToVoltageInputDividerCoefficient;
|
float adcToVoltageInputDividerCoefficient = NAN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This field is true if we are in 'cylinder cleanup' state right now
|
* This field is true if we are in 'cylinder cleanup' state right now
|
||||||
* see isCylinderCleanupEnabled
|
* see isCylinderCleanupEnabled
|
||||||
*/
|
*/
|
||||||
bool isCylinderCleanupMode;
|
bool isCylinderCleanupMode = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* value of 'triggerShape.getLength()'
|
* value of 'triggerShape.getLength()'
|
||||||
* pre-calculating this value is a performance optimization
|
* pre-calculating this value is a performance optimization
|
||||||
*/
|
*/
|
||||||
uint32_t engineCycleEventCount;
|
uint32_t engineCycleEventCount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fast spark dwell time interpolation helper
|
* fast spark dwell time interpolation helper
|
||||||
|
@ -569,7 +567,7 @@ private:
|
||||||
* 'running' means RPM are above crankingRpm
|
* 'running' means RPM are above crankingRpm
|
||||||
* 'spinning' means the engine is not stopped
|
* 'spinning' means the engine is not stopped
|
||||||
*/
|
*/
|
||||||
bool isSpinning;
|
bool isSpinning = false;
|
||||||
void reset();
|
void reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -231,18 +231,12 @@ void EngineState::updateTChargeK(int rpm, float tps DECLARE_ENGINE_PARAMETER_SUF
|
||||||
}
|
}
|
||||||
|
|
||||||
SensorsState::SensorsState() {
|
SensorsState::SensorsState() {
|
||||||
reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int MockAdcState::getMockAdcValue(int hwChannel) const {
|
int MockAdcState::getMockAdcValue(int hwChannel) const {
|
||||||
return fakeAdcValues[hwChannel];
|
return fakeAdcValues[hwChannel];
|
||||||
}
|
}
|
||||||
|
|
||||||
void SensorsState::reset() {
|
|
||||||
fuelTankGauge = vBatt = 0;
|
|
||||||
iat = clt = NAN;
|
|
||||||
}
|
|
||||||
|
|
||||||
StartupFuelPumping::StartupFuelPumping() {
|
StartupFuelPumping::StartupFuelPumping() {
|
||||||
isTpsAbove50 = false;
|
isTpsAbove50 = false;
|
||||||
pumpsCounter = 0;
|
pumpsCounter = 0;
|
||||||
|
|
Loading…
Reference in New Issue