rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes
FunctionPointerSensor Class Referencefinal

#include <function_pointer_sensor.h>

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

Public Member Functions

 FunctionPointerSensor (SensorType type, float(*func)())
 
SensorResult get () const final
 
void showInfo (const char *) const override
 
- Public Member Functions inherited from Sensor
bool Register ()
 
const chargetSensorName () const
 
virtual bool hasSensor () const
 
virtual float getRaw () const
 
virtual bool isRedundant () const
 
void unregister ()
 
SensorType type () const
 

Private Attributes

float(* m_func )()
 

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 Sensor
 Sensor (SensorType type)
 
- Static Protected Attributes inherited from Sensor
static bool s_inhibitSensorTimeouts = false
 

Detailed Description

Definition at line 17 of file function_pointer_sensor.h.

Constructor & Destructor Documentation

◆ FunctionPointerSensor()

FunctionPointerSensor::FunctionPointerSensor ( SensorType  type,
float(*)()  func 
)
inline

Definition at line 19 of file function_pointer_sensor.h.

20 : Sensor(type)
21 , m_func(func) {}
SensorType type() const
Definition sensor.h:162

Member Function Documentation

◆ get()

SensorResult FunctionPointerSensor::get ( ) const
inlinefinalvirtual

Implements Sensor.

Definition at line 23 of file function_pointer_sensor.h.

23 {
24 float result = m_func();
25
26 // check for NaN
27 bool valid = !(result != result);
28
29 if (!valid) {
30 return unexpected;
31 }
32
33 return result;
34 }

◆ showInfo()

void FunctionPointerSensor::showInfo ( const char ) const
inlineoverridevirtual

Implements Sensor.

Definition at line 36 of file function_pointer_sensor.h.

36{}

Field Documentation

◆ m_func

float(* FunctionPointerSensor::m_func) ()
private

Definition at line 39 of file function_pointer_sensor.h.

Referenced by get().


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