rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes
FunctionalSensorImpl< ConverterType > Class Template Reference

#include <functional_sensor_impl.h>

Inheritance diagram for FunctionalSensorImpl< ConverterType >:
Inheritance graph
[legend]
Collaboration diagram for FunctionalSensorImpl< ConverterType >:
Collaboration graph
[legend]

Public Member Functions

 FunctionalSensorImpl (SensorType type, efidur_t timeoutPeriod)
 
void postRawValue (float inputValue, efitick_t timestamp) override
 
void setFunction (ConverterType &func)
 
ConverterType * getFunction () const
 
float getRaw () const override final
 
- Public Member Functions inherited from StoredValueSensor
SensorResult get () const final override
 
 StoredValueSensor (SensorType type, efidur_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 chargetSensorName () const
 
virtual bool hasSensor () const
 
virtual bool isRedundant () const
 
void unregister ()
 
SensorType type () const
 

Private Attributes

ConverterType * m_function = nullptr
 
float m_rawValue = 0
 

Additional Inherited Members

- Static Public Member Functions inherited from Sensor
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 inherited from FunctionalSensorBase
 FunctionalSensorBase (SensorType type, efidur_t timeoutPeriod)
 
- Protected Member Functions inherited from Sensor
 Sensor (SensorType type)
 
- Static Protected Attributes inherited from Sensor
static bool s_inhibitSensorTimeouts = false
 

Detailed Description

template<class ConverterType>
class FunctionalSensorImpl< ConverterType >

Definition at line 10 of file functional_sensor_impl.h.

Constructor & Destructor Documentation

◆ FunctionalSensorImpl()

template<class ConverterType >
FunctionalSensorImpl< ConverterType >::FunctionalSensorImpl ( SensorType  type,
efidur_t  timeoutPeriod 
)

Definition at line 2 of file functional_sensor_impl.hpp.

3 : FunctionalSensorBase(type, timeoutPeriod) {
4}
SensorType type() const
Definition sensor.h:162

Member Function Documentation

◆ getFunction()

template<class ConverterType >
ConverterType * FunctionalSensorImpl< ConverterType >::getFunction ( ) const

Definition at line 12 of file functional_sensor_impl.hpp.

12 {
13 return m_function;
14}

◆ getRaw()

template<class ConverterType >
float FunctionalSensorImpl< ConverterType >::getRaw ( ) const
finaloverridevirtual

Reimplemented from Sensor.

Definition at line 17 of file functional_sensor_impl.hpp.

17 {
18 return m_rawValue;
19}

◆ postRawValue()

template<class ConverterType >
void FunctionalSensorImpl< ConverterType >::postRawValue ( float  inputValue,
efitick_t  timestamp 
)
overridevirtual

Implements FunctionalSensorBase.

Definition at line 22 of file functional_sensor_impl.hpp.

22 {
23 // If no function is set, this sensor isn't valid.
24 if (!m_function) {
25 invalidate(UnexpectedCode::Configuration);
26 return;
27 }
28
29 m_rawValue = inputValue;
30
31 auto r = m_function->convert(inputValue);
32
33 // This has to happen so that we set the valid bit after
34 // the value is stored, to prevent the data race of reading
35 // an old invalid value
36 if (r.Valid) {
37 setValidValue(r.Value, timestamp);
38 } else {
39 invalidate(r.Code);
40 }
41}
void setValidValue(float value, efitick_t timestamp)

Referenced by flexCallback(), and sentPressureDecode().

Here is the caller graph for this function:

◆ setFunction()

template<class ConverterType >
void FunctionalSensorImpl< ConverterType >::setFunction ( ConverterType &  func)

Definition at line 7 of file functional_sensor_impl.hpp.

7 {
8 m_function = &func;
9}

Referenced by initFlexSensor(), initMaf(), initMap(), and initVbatt().

Here is the caller graph for this function:

Field Documentation

◆ m_function

template<class ConverterType >
ConverterType* FunctionalSensorImpl< ConverterType >::m_function = nullptr
private

Definition at line 23 of file functional_sensor_impl.h.

◆ m_rawValue

template<class ConverterType >
float FunctionalSensorImpl< ConverterType >::m_rawValue = 0
private

Definition at line 25 of file functional_sensor_impl.h.


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