rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes
Sensor Class Referenceabstract

#include <sensor.h>

Inheritance diagram for Sensor:
Inheritance graph
[legend]
Collaboration diagram for Sensor:
Collaboration graph
[legend]

Public Member Functions

bool Register ()
 
virtual void showInfo (const char *sensorName) const =0
 
const chargetSensorName () const
 
virtual SensorResult get () const =0
 
virtual bool hasSensor () const
 
virtual float getRaw () const
 
virtual bool isRedundant () const
 
void unregister ()
 
SensorType type () const
 

Static Public Member Functions

static void showAllSensorInfo ()
 
static void showInfo (SensorType type)
 
static void resetRegistry ()
 
static const SensorgetSensorOfType (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 resetMockValue (SensorType type)
 
static void resetAllMocks ()
 
static void inhibitTimeouts (bool inhibit)
 
static const chargetSensorName (SensorType type)
 

Protected Member Functions

 Sensor (SensorType type)
 

Static Protected Attributes

static bool s_inhibitSensorTimeouts = false
 

Private Member Functions

constexpr size_t getIndex ()
 

Static Private Member Functions

static constexpr size_t getIndex (SensorType type)
 
static SensorRegistryEntry * getEntryForType (SensorType type)
 

Private Attributes

const SensorType m_type
 

Detailed Description

Definition at line 51 of file sensor.h.

Constructor & Destructor Documentation

◆ Sensor()

Sensor::Sensor ( SensorType  type)
inlineexplicitprotected

Definition at line 168 of file sensor.h.

169 : m_type(type) {}
const SensorType m_type
Definition sensor.h:174
SensorType type() const
Definition sensor.h:162

Member Function Documentation

◆ get() [1/2]

virtual SensorResult Sensor::get ( ) const
pure virtual

Implemented in FunctionPointerSensor, LuaOverrideSensor, StoredValueSensor, GearDetector, FallbackSensor, ProxySensor, RedundantFordTps, and RedundantSensor.

Referenced by HpfpQuantity::calcPI(), canDashboardHaltech(), canMazdaRX8(), check(), NitrousController::checkLuaGauge(), EtbController::checkStatus(), WallFuelController::computeBeta(), WallFuelController::computeTau(), ThrottleModelBase::estimateThrottleFlow(), SensorReader< TSensorType >::get(), LuaOverrideSensor::get(), FallbackSensor::get(), ProxySensor::get(), RedundantFordTps::get(), RedundantSensor::get(), AcController::getAcState(), getAdvanceCorrections(), AlphaNAirmass::getAirmass(), getBaroCorrection(), BoostController::getBoostTemperatureCorrection(), getCltFuelCorrection(), getCltTimingCorrection(), ShortTermFuelTrim::getCorrectionState(), getCrankingFuel3(), InjectorModelWithConfig::getDeadtime(), InjectorModelWithConfig::getFuelDifferentialPressure(), InjectorModelWithConfig::getFuelPressure(), getIatFuelCorrection(), IdleController::getIdlePosition(), InjectorModelWithConfig::getInjectionDuration(), ClosedLoopFuelCellImpl::getLambdaError(), IFuelComputer::getLoadOverride(), MafAirmass::getMaf(), SpeedDensityAirmass::getMap(), getOrZero(), PrimeController::getPrimeDuration(), getRunningAdvance(), getSanitizedPedal(), getSensor(), BoostController::getSetpoint(), DfcoController::getState(), FanController::getState(), FuelComputer::getStoichiometricRatio(), IFuelComputer::getTCharge(), getThrottleInletPressure(), AirmassVeModelBase::getVe(), initMapDecoder(), LambdaMonitorBase::isCurrentlyGood(), Engine::isInShutdownMode(), LaunchControlBase::isInsideTpsCondition(), TransmissionControllerBase::isShiftCompleted(), kLineThread(), AlternatorController::observePlant(), BoostController::observePlant(), EtbController::observePlant(), HpfpController::onFastCallback(), EngineState::periodicFastCallback(), populateFrame(), populateFrame(), populateFrame(), TransmissionControllerBase::postState(), printMAPInfo(), readGppwmChannel(), recalculateAuxValveTiming(), TwoPinDcMotor::set(), Gm4l6xTransmissionController::set32State(), Generic4TransmissionController::setTccState(), AutomaticGearController::update(), NitrousController::updateAfrConditionSatisfied(), VvlController::updateAfrConditionSatisfied(), ShiftTorqueReductionController::updateAppConditionSatisfied(), NitrousController::updateCltConditionSatisfied(), VvlController::updateCltConditionSatisfied(), NitrousController::updateMapConditionSatisfied(), VvlController::updateMapConditionSatisfied(), NitrousController::updateRpmConditionSatisfied(), VvlController::updateRpmConditionSatisfied(), NitrousController::updateSpeedConditionSatisfied(), LimpManager::updateState(), updateTempSensors(), updateThrottles(), NitrousController::updateTpsConditionSatisfied(), VvlController::updateTpsConditionSatisfied(), and updateTunerStudioState().

◆ get() [2/2]

SensorResult Sensor::get ( SensorType  type)
static
Returns
NotNull: sensor result or UnexpectedCode::Configuration if sensor is not registered

Definition at line 166 of file sensor.cpp.

166 {
167 const auto entry = getEntryForType(type);
168
169 // Check if this is a valid sensor entry
170 if (!entry) {
171 return UnexpectedCode::Configuration;
172 }
173
174 return entry->get();
175}
static SensorRegistryEntry * getEntryForType(SensorType type)
Definition sensor.cpp:148
Here is the call graph for this function:

◆ getEntryForType()

SensorRegistryEntry * Sensor::getEntryForType ( SensorType  type)
staticprivate

Definition at line 148 of file sensor.cpp.

148 {
149 size_t index = getIndex(type);
150 // Check that we didn't get garbage
151 if (index >= efi::size(s_sensorRegistry)) {
152 return nullptr;
153 }
154
155 return &s_sensorRegistry[index];
156}
constexpr size_t getIndex()
Definition sensor.h:177
static SensorRegistryEntry s_sensorRegistry[static_cast< size_t >(SensorType::PlaceholderLast)]
Definition sensor.cpp:129

Referenced by get(), getRaw(), getSensorOfType(), hasSensor(), isRedundant(), resetMockValue(), setInvalidMockValue(), setMockValue(), and showInfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getIndex() [1/2]

constexpr size_t Sensor::getIndex ( )
inlineconstexprprivate

Definition at line 177 of file sensor.h.

177 {
178 return getIndex(m_type);
179 }

Referenced by getEntryForType(), getIndex(), Register(), and unregister().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getIndex() [2/2]

static constexpr size_t Sensor::getIndex ( SensorType  type)
inlinestaticconstexprprivate

Definition at line 182 of file sensor.h.

182 {
183 return static_cast<size_t>(type);
184 }
Here is the call graph for this function:

◆ getOrZero()

static float Sensor::getOrZero ( SensorType  type)
inlinestatic

Definition at line 83 of file sensor.h.

83 {
84 return Sensor::get(type).value_or(0);
85 }
virtual SensorResult get() const =0

Referenced by adjustCrankPhase(), canDashboardBmwE46(), canDashboardBmwE90(), canDashboardFiat(), canDashboardGenesisCoupe(), canDashboardHaltech(), canDashboardHondaK(), canDashboardNissanVQ(), canDashboardVAG(), canDashboardVagMqb(), canDashboardW202(), canMazdaRX8(), EtbController::checkStatus(), GearDetector::computeGearboxRatio(), configureRusefiLuaHooks(), TriggerCentral::decodeMapCam(), TriggerDecoderBase::decodeTriggerEvent(), EtbImpl< TBase >::doAutocal(), AcController::getAcState(), getBaroCorrection(), BoostController::getClosedLoopImpl(), getCrankingFuel3(), GearDetector::getDriveshaftRpm(), getFuelALSCorrection(), IdleController::getIdlePosition(), KnockController::getKnockThreshold(), ShortTermFuelTrim::getLearningState(), getLoad(), getMaxAirflowAtMap(), KnockController::getMaximumRetard(), BoostController::getOpenLoop(), getPostCrankingFuelCorrection(), getRunningAdvance(), AlternatorController::getSetpoint(), BoostController::getSetpoint(), VvtController::getSetpoint(), EtbController::getSetpointEtb(), IgnitionState::getSparkDwell(), ShiftTorqueReductionController::getSparkSkipRatio(), DfcoController::getState(), ShiftTorqueReductionController::getTorqueReductionIgnitionRetard(), TpsAccelEnrichment::getTpsEnrichment(), getVeLoadAxis(), handleGetDataRequest(), initElectronicThrottle(), initNewSensors(), AntilagSystemBase::isALSMaxCLTCondition(), AntilagSystemBase::isALSMaxThrottleIntentCondition(), AntilagSystemBase::isALSMinCLTCondition(), LambdaMonitorBase::isCurrentlyGood(), isIgnVoltage(), LaunchControlBase::isInsideSpeedCondition(), LaunchControlBase::isLaunchRpmRetardCondition(), isPrimeInjectionPulseSkipped(), isShiftTorqueBelowTemperatureThreshold(), TriggerCentral::isToothExpectedNow(), SpeedDensityAirmass::logAndGetFallback(), lua_getAirmass(), HpfpController::onFastCallback(), BoostController::onFastCallback(), VvtController::onFastCallback(), WallFuelController::onFastCallback(), KnockControllerBase::onFastCallback(), LimpManager::onFastCallback(), MapAveragingModule::onFastCallback(), TachometerModule::onFastCallback(), ThrottleModelBase::onSlowCallback(), TripOdometer::onSlowCallback(), onTdcCallback(), InjectionEvent::onTriggerTooth(), EngineState::periodicFastCallback(), Engine::periodicSlowCallback(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), populateFrame(), TriggerDecoderBase::printGaps(), printMAPInfo(), readGppwmChannel(), reportWave(), LambdaMonitorBase::restoreConditionsMet(), sendWidebandInfo(), StepperMotorBase::setInitialPosition(), speedoUpdate(), startDwellByTurningSparkPinHigh(), tdcMarkCallback(), AntilagSystemBase::update(), DynoView::update(), LaunchControlBase::update(), GenericGearController::update(), updateEgtSensors(), updateFuelSensors(), updateLambda(), updateMiscSensors(), updatePressures(), updateRawSensors(), LimpManager::updateRevLimit(), ShiftTorqueReductionController::updateRpmConditionSatisfied(), Engine::updateSlowSensors(), LimpManager::updateState(), updateThrottles(), ShiftTorqueReductionController::updateTimeConditionSatisfied(), updateTunerStudioState(), updateVehicleSpeed(), and updateVrThresholdPwm().

Here is the call graph for this function:

◆ getRaw() [1/2]

virtual float Sensor::getRaw ( ) const
inlinevirtual

◆ getRaw() [2/2]

float Sensor::getRaw ( SensorType  type)
static

Definition at line 177 of file sensor.cpp.

177 {
178 const auto entry = getEntryForType(type);
179
180 return entry ? entry->getRaw() : 0;
181}
Here is the call graph for this function:

◆ getSensorName() [1/2]

const char * Sensor::getSensorName ( ) const
inline

Definition at line 130 of file sensor.h.

130{ return getSensorName(m_type); }
const char * getSensorName() const
Definition sensor.h:130

Referenced by check(), getSensorName(), HellaOilLevelSensor::init(), FrequencySensor::initIfValid(), AdcSubscription::PrintInfo(), FallbackSensor::showInfo(), ProxySensor::showInfo(), RedundantFordTps::showInfo(), RedundantSensor::showInfo(), and showInfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSensorName() [2/2]

const char * Sensor::getSensorName ( SensorType  type)
static

Definition at line 226 of file sensor.cpp.

226 {
227 return getSensorType(type);
228}
const char * getSensorType(SensorType value)
Here is the call graph for this function:

◆ getSensorOfType()

const Sensor * Sensor::getSensorOfType ( SensorType  type)
static

Definition at line 158 of file sensor.cpp.

158 {
159 auto entry = getEntryForType(type);
160 return entry ? entry->getSensor() : nullptr;
161}

Referenced by ProxySensor::isRedundant().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasSensor() [1/2]

virtual bool Sensor::hasSensor ( ) const
inlinevirtual

◆ hasSensor() [2/2]

bool Sensor::hasSensor ( SensorType  type)
static

Definition at line 189 of file sensor.cpp.

189 {
190 const auto entry = getEntryForType(type);
191
192 return entry ? entry->hasSensor() : false;
193}
Here is the call graph for this function:

◆ inhibitTimeouts()

void Sensor::inhibitTimeouts ( bool  inhibit)
static

Definition at line 232 of file sensor.cpp.

232 {
234}
static bool s_inhibitSensorTimeouts
Definition sensor.h:171

◆ isRedundant() [1/2]

virtual bool Sensor::isRedundant ( ) const
inlinevirtual

Reimplemented in ProxySensor, RedundantFordTps, RedundantSensor, and SentTps.

Definition at line 155 of file sensor.h.

155 {
156 // By default sensors are not redundant
157 return false;
158 }

Referenced by EtbController::checkStatus(), and EtbController::init().

Here is the caller graph for this function:

◆ isRedundant() [2/2]

bool Sensor::isRedundant ( SensorType  type)
static

Definition at line 183 of file sensor.cpp.

183 {
184 const auto entry = getEntryForType(type);
185
186 return entry ? entry->isRedundant() : false;
187}

Referenced by ProxySensor::isRedundant().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Register()

bool Sensor::Register ( )

◆ resetAllMocks()

void Sensor::resetAllMocks ( )
static

Definition at line 219 of file sensor.cpp.

219 {
220 // Reset all mocks
221 for (size_t i = 0; i < efi::size(s_sensorRegistry); i++) {
222 s_sensorRegistry[i].resetMock();
223 }
224}

Referenced by initSensorCli().

Here is the caller graph for this function:

◆ resetMockValue()

void Sensor::resetMockValue ( SensorType  type)
static

Definition at line 211 of file sensor.cpp.

211 {
212 auto entry = getEntryForType(type);
213
214 if (entry) {
215 entry->resetMock();
216 }
217}
Here is the call graph for this function:

◆ resetRegistry()

void Sensor::resetRegistry ( )
static

Definition at line 139 of file sensor.cpp.

139 {
140 // Clear all entries
141 for (size_t i = 0; i < efi::size(s_sensorRegistry); i++) {
142 auto &entry = s_sensorRegistry[i];
143
144 entry.reset();
145 }
146}

◆ setInvalidMockValue()

void Sensor::setInvalidMockValue ( SensorType  type)
static

Definition at line 195 of file sensor.cpp.

195 {
196 auto entry = getEntryForType(type);
197
198 if (entry) {
199 entry->setInvalidMockValue();
200 }
201}
Here is the call graph for this function:

◆ setMockValue()

void Sensor::setMockValue ( SensorType  type,
float  value,
bool  mockRedundant = false 
)
static

Definition at line 203 of file sensor.cpp.

203 {
204 auto entry = getEntryForType(type);
205
206 if (entry) {
207 entry->setMockValue(value, mockRedundant);
208 }
209}

Referenced by initMapDecoder(), initNewSensors(), and initSensorCli().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showAllSensorInfo()

void Sensor::showAllSensorInfo ( )
static

Definition at line 237 of file sensor.cpp.

237 {
238 for (size_t i = 1; i < efi::size(s_sensorRegistry); i++) {
239 auto& entry = s_sensorRegistry[i];
240 const char* name = getSensorType((SensorType)i);
241
242 entry.showInfo(name);
243 }
244}
SensorType
Definition sensor_type.h:18

Referenced by initSensorCli(), and printSensorInfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showInfo() [1/2]

virtual void Sensor::showInfo ( const char sensorName) const
pure virtual

◆ showInfo() [2/2]

void Sensor::showInfo ( SensorType  type)
static

Definition at line 247 of file sensor.cpp.

247 {
248 auto entry = getEntryForType(type);
249
250 if (entry) {
251 entry->showInfo(getSensorName(type));
252 }
253}
Here is the call graph for this function:

◆ type()

SensorType Sensor::type ( ) const
inline

◆ unregister()

void Sensor::unregister ( )

Definition at line 135 of file sensor.cpp.

135 {
136 s_sensorRegistry[getIndex()].unregister();
137}

Referenced by deinitAuxSensors(), deInitFlexSensor(), deinitTps(), onEcuStartDoSomethingTriggerInputPins(), and GearDetector::~GearDetector().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ m_type

const SensorType Sensor::m_type
private

Definition at line 174 of file sensor.h.

Referenced by getIndex(), getSensorName(), and type().

◆ s_inhibitSensorTimeouts

bool Sensor::s_inhibitSensorTimeouts = false
staticprotected

Definition at line 171 of file sensor.h.

Referenced by StoredValueSensor::get(), and inhibitTimeouts().


The documentation for this class was generated from the following files: