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 55 of file sensor.h.

Constructor & Destructor Documentation

◆ Sensor()

Sensor::Sensor ( SensorType  type)
inlineexplicitprotected

Definition at line 172 of file sensor.h.

173 : m_type(type) {}
const SensorType m_type
Definition sensor.h:178
SensorType type() const
Definition sensor.h:166

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 178 of file sensor.cpp.

178 {
179 const auto entry = getEntryForType(type);
180
181 // Check if this is a valid sensor entry
182 if (!entry) {
183 return UnexpectedCode::Configuration;
184 }
185
186 return entry->get();
187}
static SensorRegistryEntry * getEntryForType(SensorType type)
Definition sensor.cpp:160
Here is the call graph for this function:

◆ getEntryForType()

SensorRegistryEntry * Sensor::getEntryForType ( SensorType  type)
staticprivate

Definition at line 160 of file sensor.cpp.

160 {
161 size_t index = getIndex(type);
162 // Check that we didn't get garbage
163 if (index >= efi::size(s_sensorRegistry)) {
164 return nullptr;
165 }
166
167 return &s_sensorRegistry[index];
168}
constexpr size_t getIndex()
Definition sensor.h:181
static SensorRegistryEntry s_sensorRegistry[static_cast< size_t >(SensorType::PlaceholderLast)]
Definition sensor.cpp:141

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 181 of file sensor.h.

181 {
182 return getIndex(m_type);
183 }

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 186 of file sensor.h.

186 {
187 return static_cast<size_t>(type);
188 }
Here is the call graph for this function:

◆ getOrZero()

static float Sensor::getOrZero ( SensorType  type)
inlinestatic

Definition at line 87 of file sensor.h.

87 {
88 return Sensor::get(type).value_or(0);
89 }
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(), RotationalIdle::shouldEngageRotationalIdle(), 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 189 of file sensor.cpp.

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

◆ getSensorName() [1/2]

const char * Sensor::getSensorName ( ) const
inline

Definition at line 134 of file sensor.h.

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

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 238 of file sensor.cpp.

238 {
239 return getSensorType(type);
240}
const char * getSensorType(SensorType value)
Here is the call graph for this function:

◆ getSensorOfType()

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

Definition at line 170 of file sensor.cpp.

170 {
171 auto entry = getEntryForType(type);
172 return entry ? entry->getSensor() : nullptr;
173}

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 201 of file sensor.cpp.

201 {
202 const auto entry = getEntryForType(type);
203
204 return entry ? entry->hasSensor() : false;
205}
Here is the call graph for this function:

◆ inhibitTimeouts()

void Sensor::inhibitTimeouts ( bool  inhibit)
static

Definition at line 244 of file sensor.cpp.

244 {
246}
static bool s_inhibitSensorTimeouts
Definition sensor.h:175

◆ isRedundant() [1/2]

virtual bool Sensor::isRedundant ( ) const
inlinevirtual

Reimplemented in ProxySensor, RedundantFordTps, RedundantSensor, and SentTps.

Definition at line 159 of file sensor.h.

159 {
160 // By default sensors are not redundant
161 return false;
162 }

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 195 of file sensor.cpp.

195 {
196 const auto entry = getEntryForType(type);
197
198 return entry ? entry->isRedundant() : false;
199}

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 231 of file sensor.cpp.

231 {
232 // Reset all mocks
233 for (size_t i = 0; i < efi::size(s_sensorRegistry); i++) {
234 s_sensorRegistry[i].resetMock();
235 }
236}

Referenced by initSensorCli().

Here is the caller graph for this function:

◆ resetMockValue()

void Sensor::resetMockValue ( SensorType  type)
static

Definition at line 223 of file sensor.cpp.

223 {
224 auto entry = getEntryForType(type);
225
226 if (entry) {
227 entry->resetMock();
228 }
229}
Here is the call graph for this function:

◆ resetRegistry()

void Sensor::resetRegistry ( )
static

Definition at line 151 of file sensor.cpp.

151 {
152 // Clear all entries
153 for (size_t i = 0; i < efi::size(s_sensorRegistry); i++) {
154 auto &entry = s_sensorRegistry[i];
155
156 entry.reset();
157 }
158}

◆ setInvalidMockValue()

void Sensor::setInvalidMockValue ( SensorType  type)
static

Definition at line 207 of file sensor.cpp.

207 {
208 auto entry = getEntryForType(type);
209
210 if (entry) {
211 entry->setInvalidMockValue();
212 }
213}
Here is the call graph for this function:

◆ setMockValue()

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

Definition at line 215 of file sensor.cpp.

215 {
216 auto entry = getEntryForType(type);
217
218 if (entry) {
219 entry->setMockValue(value, mockRedundant);
220 }
221}

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 249 of file sensor.cpp.

249 {
250 for (size_t i = 1; i < efi::size(s_sensorRegistry); i++) {
251 auto& entry = s_sensorRegistry[i];
252 const char* name = getSensorType((SensorType)i);
253
254 entry.showInfo(name);
255 }
256}
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 259 of file sensor.cpp.

259 {
260 auto entry = getEntryForType(type);
261
262 if (entry) {
263 entry->showInfo(getSensorName(type));
264 }
265}
Here is the call graph for this function:

◆ type()

SensorType Sensor::type ( ) const
inline

◆ unregister()

void Sensor::unregister ( )

Definition at line 147 of file sensor.cpp.

147 {
148 s_sensorRegistry[getIndex()].unregister();
149}

Referenced by deinitAuxSensors(), deinitTps(), FlexSensor::unregister(), 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 178 of file sensor.h.

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

◆ s_inhibitSensorTimeouts

bool Sensor::s_inhibitSensorTimeouts = false
staticprotected

Definition at line 175 of file sensor.h.

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


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