refactoring: 'const' modifier
This commit is contained in:
parent
14199080b1
commit
1b74b722d2
|
@ -297,7 +297,7 @@ static void periodicSlowCallback(Engine *engine) {
|
||||||
/**
|
/**
|
||||||
* Update engine RPM state if needed (check timeouts).
|
* Update engine RPM state if needed (check timeouts).
|
||||||
*/
|
*/
|
||||||
bool isSpinning = engine->rpmCalculator.checkIfSpinning(PASS_ENGINE_PARAMETER_SIGNATURE);
|
bool isSpinning = engine->rpmCalculator.checkIfSpinning(getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
if (!isSpinning) {
|
if (!isSpinning) {
|
||||||
engine->rpmCalculator.setStopSpinning(PASS_ENGINE_PARAMETER_SIGNATURE);
|
engine->rpmCalculator.setStopSpinning(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,16 +61,16 @@ RpmCalculator::RpmCalculator() {
|
||||||
revolutionCounterSinceBootForUnitTest = 0;
|
revolutionCounterSinceBootForUnitTest = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RpmCalculator::isStopped(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
bool RpmCalculator::isStopped(DECLARE_ENGINE_PARAMETER_SIGNATURE) const {
|
||||||
// Spinning-up with zero RPM means that the engine is not ready yet, and is treated as 'stopped'.
|
// Spinning-up with zero RPM means that the engine is not ready yet, and is treated as 'stopped'.
|
||||||
return state == STOPPED || (state == SPINNING_UP && rpmValue == 0);
|
return state == STOPPED || (state == SPINNING_UP && rpmValue == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RpmCalculator::isSpinningUp(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
bool RpmCalculator::isSpinningUp(DECLARE_ENGINE_PARAMETER_SIGNATURE) const {
|
||||||
return state == SPINNING_UP;
|
return state == SPINNING_UP;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RpmCalculator::isCranking(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
bool RpmCalculator::isCranking(DECLARE_ENGINE_PARAMETER_SIGNATURE) const {
|
||||||
// Spinning-up with non-zero RPM is suitable for all engine math, as good as cranking
|
// Spinning-up with non-zero RPM is suitable for all engine math, as good as cranking
|
||||||
return state == CRANKING || (state == SPINNING_UP && rpmValue > 0);
|
return state == CRANKING || (state == SPINNING_UP && rpmValue > 0);
|
||||||
}
|
}
|
||||||
|
@ -78,15 +78,14 @@ bool RpmCalculator::isCranking(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
/**
|
/**
|
||||||
* @return true if there was a full shaft revolution within the last second
|
* @return true if there was a full shaft revolution within the last second
|
||||||
*/
|
*/
|
||||||
bool RpmCalculator::isRunning(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
bool RpmCalculator::isRunning(DECLARE_ENGINE_PARAMETER_SIGNATURE) const {
|
||||||
return state == RUNNING;
|
return state == RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if engine is spinning (cranking or running)
|
* @return true if engine is spinning (cranking or running)
|
||||||
*/
|
*/
|
||||||
bool RpmCalculator::checkIfSpinning(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
bool RpmCalculator::checkIfSpinning(efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) const {
|
||||||
efitick_t nowNt = getTimeNowNt();
|
|
||||||
if (ENGINE(needToStopEngine(nowNt))) {
|
if (ENGINE(needToStopEngine(nowNt))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +147,7 @@ void RpmCalculator::setRpmValue(int value DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
spinning_state_e RpmCalculator::getState(void) {
|
spinning_state_e RpmCalculator::getState() const {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +236,7 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType,
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
ENGINE(m.beforeRpmCb) = GET_TIMESTAMP();
|
ENGINE(m.beforeRpmCb) = GET_TIMESTAMP();
|
||||||
|
|
||||||
bool hadRpmRecently = rpmState->checkIfSpinning(PASS_ENGINE_PARAMETER_SIGNATURE);
|
bool hadRpmRecently = rpmState->checkIfSpinning(nowNt PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
if (hadRpmRecently) {
|
if (hadRpmRecently) {
|
||||||
efitime_t diffNt = nowNt - rpmState->lastRpmEventTimeNt;
|
efitime_t diffNt = nowNt - rpmState->lastRpmEventTimeNt;
|
||||||
|
|
|
@ -62,26 +62,26 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns true if the engine is not spinning (RPM==0)
|
* Returns true if the engine is not spinning (RPM==0)
|
||||||
*/
|
*/
|
||||||
bool isStopped(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
bool isStopped(DECLARE_ENGINE_PARAMETER_SIGNATURE) const;
|
||||||
/**
|
/**
|
||||||
* Returns true if the engine is spinning up
|
* Returns true if the engine is spinning up
|
||||||
*/
|
*/
|
||||||
bool isSpinningUp(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
bool isSpinningUp(DECLARE_ENGINE_PARAMETER_SIGNATURE) const;
|
||||||
/**
|
/**
|
||||||
* Returns true if the engine is cranking OR spinning up
|
* Returns true if the engine is cranking OR spinning up
|
||||||
*/
|
*/
|
||||||
bool isCranking(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
bool isCranking(DECLARE_ENGINE_PARAMETER_SIGNATURE) const;
|
||||||
/**
|
/**
|
||||||
* Returns true if the engine is running and not cranking
|
* Returns true if the engine is running and not cranking
|
||||||
*/
|
*/
|
||||||
bool isRunning(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
bool isRunning(DECLARE_ENGINE_PARAMETER_SIGNATURE) const;
|
||||||
|
|
||||||
bool checkIfSpinning(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
bool checkIfSpinning(efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This accessor is used in unit-tests.
|
* This accessor is used in unit-tests.
|
||||||
*/
|
*/
|
||||||
spinning_state_e getState(void);
|
spinning_state_e getState() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should be called on every trigger event when the engine is just starting to spin up.
|
* Should be called on every trigger event when the engine is just starting to spin up.
|
||||||
|
|
Loading…
Reference in New Issue