rusEFI
The most advanced open source ECU
|
#include <rpm_calculator.h>
Public Member Functions | |
RpmCalculator () | |
operation_mode_e | getOperationMode () const override |
void | onSlowCallback () |
bool | isStopped () const override |
bool | isSpinningUp () const |
bool | isCranking () const override |
bool | isRunning () const |
bool | checkIfSpinning (efitick_t nowNt) const |
spinning_state_e | getState () const |
void | setSpinningUp (efitick_t nowNt) |
void | setStopSpinning () |
float | getCachedRpm () const |
void | onNewEngineCycle () |
uint32_t | getRevolutionCounterM (void) const |
void | setRpmValue (float value) |
void | assignRpmValue (float value) |
uint32_t | getRevolutionCounterSinceStart (void) const |
float | getRpmAcceleration () const |
float | getSecondsSinceEngineStart (efitick_t nowNt) const |
floatus_t | getOneDegreeUs () override |
Public Member Functions inherited from StoredValueSensor | |
SensorResult | get () const final override |
StoredValueSensor (SensorType type, efitick_t timeoutNt) | |
void | invalidate () |
void | invalidate (UnexpectedCode why) |
void | setValidValue (float value, efitick_t timestamp) |
void | showInfo (const char *sensorName) const override |
virtual void | setTimeout (int timeoutMs) |
Public Member Functions inherited from Sensor | |
bool | Register () |
const char * | getSensorName () const |
virtual bool | hasSensor () const |
virtual float | getRaw () const |
virtual bool | isRedundant () const |
void | unregister () |
SensorType | type () const |
Data Fields | |
int | previousRpmValue = 0 |
floatus_t | oneDegreeUs = NAN |
Timer | lastTdcTimer |
float | rpmRate = 0 |
Protected Member Functions | |
void | showInfo (const char *sensorName) const override |
Protected Member Functions inherited from Sensor | |
Sensor (SensorType type) | |
Private Member Functions | |
void | setStopped () |
Private Attributes | |
float | cachedRpmValue = 0 |
uint32_t | revolutionCounterSinceBoot = 0 |
uint32_t | revolutionCounterSinceStart = 0 |
spinning_state_e | state = STOPPED |
bool | isSpinning = false |
Timer | engineStartTimer |
Additional Inherited Members | |
Static Public Member Functions inherited from Sensor | |
static void | showAllSensorInfo () |
static void | showInfo (SensorType type) |
static void | resetRegistry () |
static const Sensor * | getSensorOfType (SensorType type) |
static SensorResult | get (SensorType type) |
static float | getOrZero (SensorType type) |
static float | getRaw (SensorType type) |
static bool | isRedundant (SensorType type) |
static bool | hasSensor (SensorType type) |
static void | setMockValue (SensorType type, float value, bool mockRedundant=false) |
static void | setInvalidMockValue (SensorType type) |
static void | setMockValue (int type, float value) |
static void | resetMockValue (SensorType type) |
static void | resetAllMocks () |
static void | inhibitTimeouts (bool inhibit) |
static const char * | getSensorName (SensorType type) |
Static Protected Attributes inherited from Sensor | |
static bool | s_inhibitSensorTimeouts = false |
Most consumers should access value via Sensor framework by SensorType::Rpm key
Definition at line 44 of file rpm_calculator.h.
RpmCalculator::RpmCalculator | ( | ) |
Definition at line 106 of file rpm_calculator.cpp.
void RpmCalculator::assignRpmValue | ( | float | value | ) |
The same as setRpmValue() but without state change. We need this to be public because of calling rpmState->assignRpmValue() from rpmShaftPositionCallback()
this would make sure that we have good numbers for first cranking revolution #275 cranking could be improved
Definition at line 142 of file rpm_calculator.cpp.
Referenced by RpmCalculator(), rpmShaftPositionCallback(), setRpmValue(), and setStopped().
bool RpmCalculator::checkIfSpinning | ( | efitick_t | nowNt | ) | const |
Also check if there were no trigger events
Definition at line 122 of file rpm_calculator.cpp.
Referenced by rpmShaftPositionCallback().
float RpmCalculator::getCachedRpm | ( | ) | const |
Just a quick getter for rpmValue Should be same exact value as Sensor::get(SensorType::Rpm).Value just quicker. Open question if we have any cases where this opimization is needed.
Definition at line 57 of file rpm_calculator.cpp.
Referenced by TriggerCentral::handleShaftSignal(), and mainTriggerCallback().
|
inlineoverridevirtual |
Implements EngineRotationState.
Definition at line 123 of file rpm_calculator.h.
|
overridevirtual |
Implements EngineRotationState.
Definition at line 89 of file rpm_calculator.cpp.
uint32_t RpmCalculator::getRevolutionCounterM | ( | void | ) | const |
Definition at line 208 of file rpm_calculator.cpp.
uint32_t RpmCalculator::getRevolutionCounterSinceStart | ( | void | ) | const |
Definition at line 49 of file rpm_calculator.cpp.
Referenced by getCrankingFuel(), IdleController::getCrankingTaperFraction(), EngineState::periodicFastCallback(), and updateTunerStudioState().
float RpmCalculator::getRpmAcceleration | ( | ) | const |
RPM rate of change between current RPM and RPM measured during previous engine cycle see also SC_RPM_ACCEL
Definition at line 31 of file rpm_calculator.cpp.
Referenced by updateTunerStudioState().
float RpmCalculator::getSecondsSinceEngineStart | ( | efitick_t | nowNt | ) | const |
Definition at line 337 of file rpm_calculator.cpp.
Referenced by VvtController::getSetpoint(), and LimpManager::updateState().
spinning_state_e RpmCalculator::getState | ( | ) | const |
This accessor is used in unit-tests.
Definition at line 199 of file rpm_calculator.cpp.
Referenced by configureRusefiLuaHooks().
|
overridevirtual |
Returns true if the engine is cranking OR spinning up
Implements EngineRotationState.
Definition at line 40 of file rpm_calculator.cpp.
Referenced by getAdvance(), getInjectionMass(), IgnitionState::getSparkDwell(), FanController::getState(), WallFuelController::onFastCallback(), EngineState::periodicFastCallback(), showInfo(), and tle8888startup().
bool RpmCalculator::isRunning | ( | ) | const |
Returns true if the engine is running and not cranking
Definition at line 115 of file rpm_calculator.cpp.
Referenced by IdleController::determinePhase(), disengageStarterIfNeeded(), FanController::getState(), TripOdometer::onSlowCallback(), onStartStopButtonToggle(), Engine::periodicSlowCallback(), StepperMotorBase::setInitialPosition(), shouldCorrect(), showInfo(), startKnockSampling(), and LimpManager::updateState().
bool RpmCalculator::isSpinningUp | ( | ) | const |
Returns true if the engine is spinning up
Definition at line 45 of file rpm_calculator.cpp.
Referenced by getCurrentIgnitionMode(), rpmShaftPositionCallback(), setSpinningUp(), and showInfo().
|
overridevirtual |
Returns true if the engine is not spinning (RPM==0)
Implements EngineRotationState.
Definition at line 35 of file rpm_calculator.cpp.
Referenced by doPeriodicSlowCallback(), executeTSCommand(), onStartStopButtonToggle(), setSpinningUp(), and showInfo().
void RpmCalculator::onNewEngineCycle | ( | ) |
This method is invoked once per engine cycle right after we calculate new RPM value
Definition at line 203 of file rpm_calculator.cpp.
Referenced by rpmShaftPositionCallback().
void RpmCalculator::onSlowCallback | ( | ) |
Definition at line 212 of file rpm_calculator.cpp.
Referenced by doPeriodicSlowCallback().
void RpmCalculator::setRpmValue | ( | float | value | ) |
We are here if RPM is above zero but we have not seen running RPM yet. This gives us cranking hysteresis - a drop of RPM during running is still running, not cranking.
Definition at line 163 of file rpm_calculator.cpp.
Referenced by rpmShaftPositionCallback().
void RpmCalculator::setSpinningUp | ( | efitick_t | nowNt | ) |
Should be called on every trigger event when the engine is just starting to spin up.
Definition at line 238 of file rpm_calculator.cpp.
Referenced by Engine::OnTriggerStateProperState().
|
private |
Should be called once we've realized engine is not spinning any more.
Definition at line 219 of file rpm_calculator.cpp.
Referenced by setStopSpinning().
void RpmCalculator::setStopSpinning | ( | ) |
Called if the synchronization is lost due to a trigger timeout.
Definition at line 233 of file rpm_calculator.cpp.
Referenced by onSlowCallback(), and Engine::OnTriggerSynchronizationLost().
|
overrideprotectedvirtual |
Implements Sensor.
Definition at line 60 of file sensor_info_printing.cpp.
|
private |
At this point this value is same exact value as in private m_value variable At this point all this is performance optimization? Open question is when do we need it for performance reasons.
Definition at line 142 of file rpm_calculator.h.
Referenced by assignRpmValue(), getCachedRpm(), isCranking(), isStopped(), setRpmValue(), and setStopped().
|
private |
Definition at line 167 of file rpm_calculator.h.
Referenced by getSecondsSinceEngineStart(), and setRpmValue().
|
private |
True if the engine is spinning (regardless of its state), i.e. if shaft position changes. Needed by spinning-up logic.
Definition at line 165 of file rpm_calculator.h.
Referenced by setSpinningUp(), and setStopSpinning().
Timer RpmCalculator::lastTdcTimer |
Definition at line 127 of file rpm_calculator.h.
Referenced by checkIfSpinning(), PrimaryTriggerDecoder::onTriggerError(), and rpmShaftPositionCallback().
floatus_t RpmCalculator::oneDegreeUs = NAN |
This is a performance optimization: let's pre-calculate this each time RPM changes NaN while engine is not spinning
Definition at line 121 of file rpm_calculator.h.
Referenced by assignRpmValue(), TriggerCentral::getCurrentEnginePhase(), getOneDegreeUs(), scheduleByAngle(), and startKnockSampling().
int RpmCalculator::previousRpmValue = 0 |
this is RPM on previous engine cycle.
Definition at line 115 of file rpm_calculator.h.
Referenced by assignRpmValue(), and rpmShaftPositionCallback().
|
private |
This counter is incremented with each revolution of one of the shafts. Could be crankshaft could be camshaft.
Definition at line 153 of file rpm_calculator.h.
Referenced by getRevolutionCounterM(), and onNewEngineCycle().
|
private |
Same as the above, but since the engine started spinning
Definition at line 157 of file rpm_calculator.h.
Referenced by getRevolutionCounterSinceStart(), onNewEngineCycle(), and setStopped().
float RpmCalculator::rpmRate = 0 |
Definition at line 130 of file rpm_calculator.h.
Referenced by getRpmAcceleration(), rpmShaftPositionCallback(), and setStopped().
|
private |
Definition at line 159 of file rpm_calculator.h.
Referenced by getState(), isCranking(), isRunning(), isSpinningUp(), isStopped(), setRpmValue(), setSpinningUp(), and setStopped().