enjoying C++11
This commit is contained in:
parent
c459020fdd
commit
c7f5581382
|
@ -54,16 +54,11 @@ RpmCalculator::RpmCalculator() {
|
|||
mockRpm = MOCK_UNDEFINED;
|
||||
#endif /* EFI_PROD_CODE */
|
||||
// todo: reuse assignRpmValue() method which needs PASS_ENGINE_PARAMETER_SUFFIX
|
||||
// which we cannot provide inside this parameter-less consutructor. need a solution for this minor mess
|
||||
previousRpmValue = rpmValue = 0;
|
||||
oneDegreeUs = NAN;
|
||||
state = STOPPED;
|
||||
isSpinning = false;
|
||||
// which we cannot provide inside this parameter-less constructor. need a solution for this minor mess
|
||||
|
||||
// we need this initial to have not_running at first invocation
|
||||
lastRpmEventTimeNt = (efitime_t) -10 * US2NT(US_PER_SECOND_LL);
|
||||
revolutionCounterSinceStart = 0;
|
||||
revolutionCounterSinceBootForUnitTest = revolutionCounterSinceBoot = 0;
|
||||
revolutionCounterSinceBootForUnitTest = 0;
|
||||
|
||||
lastRpmEventTimeNt = 0;
|
||||
oneDegreeUs = NAN;
|
||||
|
|
|
@ -121,16 +121,16 @@ public:
|
|||
* This is public because sometimes we cannot afford to call isRunning() and the value is good enough
|
||||
* Zero if engine is not running
|
||||
*/
|
||||
volatile int rpmValue;
|
||||
volatile int rpmValue = 0;
|
||||
/**
|
||||
* this is RPM on previous engine cycle.
|
||||
*/
|
||||
int previousRpmValue;
|
||||
int previousRpmValue = 0;
|
||||
/**
|
||||
* This is a performance optimization: let's pre-calculate this each time RPM changes
|
||||
* NaN while engine is not spinning
|
||||
*/
|
||||
volatile floatus_t oneDegreeUs;
|
||||
volatile floatus_t oneDegreeUs = NAN;
|
||||
volatile efitime_t lastRpmEventTimeNt;
|
||||
private:
|
||||
/**
|
||||
|
@ -142,19 +142,19 @@ private:
|
|||
* This counter is incremented with each revolution of one of the shafts. Could be
|
||||
* crankshaft could be camshaft.
|
||||
*/
|
||||
volatile uint32_t revolutionCounterSinceBoot;
|
||||
volatile uint32_t revolutionCounterSinceBoot = 0;
|
||||
/**
|
||||
* Same as the above, but since the engine started spinning
|
||||
*/
|
||||
volatile uint32_t revolutionCounterSinceStart;
|
||||
volatile uint32_t revolutionCounterSinceStart = 0;
|
||||
|
||||
spinning_state_e state;
|
||||
spinning_state_e state = STOPPED;
|
||||
|
||||
/**
|
||||
* True if the engine is spinning (regardless of its state), i.e. if shaft position changes.
|
||||
* Needed by spinning-up logic.
|
||||
*/
|
||||
bool isSpinning;
|
||||
bool isSpinning = false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -126,8 +126,6 @@ int TriggerState::getTotalRevolutionCounter() {
|
|||
}
|
||||
|
||||
TriggerStateWithRunningStatistics::TriggerStateWithRunningStatistics() {
|
||||
instantRpm = 0;
|
||||
prevInstantRpmValue = 0;
|
||||
// avoid ill-defined instant RPM when the data is not gathered yet
|
||||
efitime_t nowNt = getTimeNowNt();
|
||||
for (int i = 0; i < PWM_PHASE_MAX_COUNT; i++) {
|
||||
|
|
|
@ -122,7 +122,7 @@ private:
|
|||
class TriggerStateWithRunningStatistics : public TriggerState {
|
||||
public:
|
||||
TriggerStateWithRunningStatistics();
|
||||
float instantRpm;
|
||||
float instantRpm = 0;
|
||||
/**
|
||||
* timestamp of each trigger wheel tooth
|
||||
*/
|
||||
|
@ -134,7 +134,7 @@ public:
|
|||
/**
|
||||
* Stores last non-zero instant RPM value to fix early instability
|
||||
*/
|
||||
float prevInstantRpmValue;
|
||||
float prevInstantRpmValue = 0;
|
||||
float calculateInstantRpm(int *prevIndex, efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
virtual void runtimeStatistics(efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue