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() {
|
||||
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
|
||||
*/
|
||||
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));
|
||||
|
||||
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));
|
||||
config = NULL;
|
||||
engineConfigurationPtr = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -93,11 +93,11 @@ public:
|
|||
*
|
||||
* values are in Celsius
|
||||
*/
|
||||
float iat;
|
||||
float iat = NAN;
|
||||
#if EFI_UNIT_TEST
|
||||
float mockClt = NAN;
|
||||
#endif
|
||||
float clt;
|
||||
float clt = NAN;
|
||||
|
||||
/**
|
||||
* Oil pressure in kPa
|
||||
|
@ -106,14 +106,12 @@ public:
|
|||
|
||||
Accelerometer accelerometer;
|
||||
|
||||
float vBatt;
|
||||
float vBatt = 0;
|
||||
float currentAfr;
|
||||
/**
|
||||
* that's fuel in tank - just a gauge
|
||||
*/
|
||||
percent_t fuelTankGauge;
|
||||
|
||||
void reset();
|
||||
percent_t fuelTankGauge = 0;
|
||||
};
|
||||
|
||||
class FuelConsumptionState {
|
||||
|
@ -310,8 +308,8 @@ typedef void (*configuration_callback_t)(Engine*);
|
|||
class FsioState {
|
||||
public:
|
||||
FsioState();
|
||||
float fsioTimingAdjustment;
|
||||
float fsioIdleTargetRPMAdjustment;
|
||||
float fsioTimingAdjustment = 0;
|
||||
float fsioIdleTargetRPMAdjustment = 0;
|
||||
float servoValues[SERVO_COUNT];
|
||||
float fsioLastValue[FSIO_COMMAND_COUNT];
|
||||
|
||||
|
@ -370,25 +368,25 @@ public:
|
|||
|
||||
WallFuel wallFuel;
|
||||
bool needToStopEngine(efitick_t nowNt);
|
||||
bool etbAutoTune;
|
||||
bool etbAutoTune = false;
|
||||
/**
|
||||
* That's the list of pending spark firing events
|
||||
*/
|
||||
IgnitionEvent *iHead;
|
||||
IgnitionEvent *iHead = NULL;
|
||||
/**
|
||||
* this is based on isEngineChartEnabled and engineSnifferRpmThreshold settings
|
||||
*/
|
||||
bool isEngineChartEnabled;
|
||||
bool isEngineChartEnabled = false;
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
bool isAlternatorControlEnabled;
|
||||
bool isAlternatorControlEnabled = false;
|
||||
|
||||
bool isCltBroken;
|
||||
bool isCltBroken = false;
|
||||
bool slowCallBackWasInvoked = false;
|
||||
|
||||
|
||||
|
@ -397,10 +395,10 @@ public:
|
|||
/**
|
||||
* 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
|
||||
efitime_t rpmHardLimitTimestamp;
|
||||
efitime_t rpmHardLimitTimestamp = 0;
|
||||
|
||||
// todo: should be a field on some other class, not Engine?
|
||||
bool isInitializingTrigger = false;
|
||||
|
@ -409,20 +407,20 @@ public:
|
|||
* This flag indicated a big enough problem that engine control would be
|
||||
* prohibited if this flag is set to true.
|
||||
*/
|
||||
bool withError;
|
||||
bool withError = false;
|
||||
|
||||
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
|
||||
* 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
|
||||
*/
|
||||
efitick_t stopEngineRequestTimeNt;
|
||||
efitick_t stopEngineRequestTimeNt = 0;
|
||||
|
||||
/**
|
||||
* always 360 or 720, never zero
|
||||
|
@ -439,27 +437,27 @@ public:
|
|||
* including everything including injector lag, both cranking and running
|
||||
* @see getInjectionDuration()
|
||||
*/
|
||||
floatms_t injectionDuration;
|
||||
floatms_t injectionDuration = 0;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
floatms_t actualLastInjection;
|
||||
floatms_t actualLastInjection = 0;
|
||||
|
||||
void periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
void periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
void updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
void initializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
bool clutchUpState;
|
||||
bool clutchDownState;
|
||||
bool brakePedalState;
|
||||
bool clutchUpState = false;
|
||||
bool clutchDownState = false;
|
||||
bool brakePedalState = false;
|
||||
|
||||
bool isRunningPwmTest;
|
||||
bool isRunningPwmTest = false;
|
||||
|
||||
|
||||
FsioState fsioState;
|
||||
|
@ -467,28 +465,28 @@ public:
|
|||
/**
|
||||
* Are we experiencing knock right now?
|
||||
*/
|
||||
bool knockNow;
|
||||
bool knockNow = false;
|
||||
/**
|
||||
* Have we experienced knock since engine was started?
|
||||
*/
|
||||
bool knockEver;
|
||||
bool knockEver = false;
|
||||
/**
|
||||
* KnockCount is directly proportional to the degrees of ignition
|
||||
* 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
|
||||
* some areas
|
||||
*/
|
||||
bool isTestMode;
|
||||
bool isTestMode = false;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -509,26 +507,26 @@ public:
|
|||
void onTriggerSignalEvent(efitick_t nowNt);
|
||||
EngineState engineState;
|
||||
SensorsState sensors;
|
||||
efitick_t lastTriggerToothEventTimeNt;
|
||||
efitick_t lastTriggerToothEventTimeNt = 0;
|
||||
|
||||
|
||||
/**
|
||||
* This coefficient translates ADC value directly into voltage adjusted according to
|
||||
* 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
|
||||
* see isCylinderCleanupEnabled
|
||||
*/
|
||||
bool isCylinderCleanupMode;
|
||||
bool isCylinderCleanupMode = false;
|
||||
|
||||
/**
|
||||
* value of 'triggerShape.getLength()'
|
||||
* pre-calculating this value is a performance optimization
|
||||
*/
|
||||
uint32_t engineCycleEventCount;
|
||||
uint32_t engineCycleEventCount = 0;
|
||||
|
||||
/**
|
||||
* fast spark dwell time interpolation helper
|
||||
|
@ -569,7 +567,7 @@ private:
|
|||
* 'running' means RPM are above crankingRpm
|
||||
* 'spinning' means the engine is not stopped
|
||||
*/
|
||||
bool isSpinning;
|
||||
bool isSpinning = false;
|
||||
void reset();
|
||||
};
|
||||
|
||||
|
|
|
@ -231,18 +231,12 @@ void EngineState::updateTChargeK(int rpm, float tps DECLARE_ENGINE_PARAMETER_SUF
|
|||
}
|
||||
|
||||
SensorsState::SensorsState() {
|
||||
reset();
|
||||
}
|
||||
|
||||
int MockAdcState::getMockAdcValue(int hwChannel) const {
|
||||
return fakeAdcValues[hwChannel];
|
||||
}
|
||||
|
||||
void SensorsState::reset() {
|
||||
fuelTankGauge = vBatt = 0;
|
||||
iat = clt = NAN;
|
||||
}
|
||||
|
||||
StartupFuelPumping::StartupFuelPumping() {
|
||||
isTpsAbove50 = false;
|
||||
pumpsCounter = 0;
|
||||
|
|
Loading…
Reference in New Issue