rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
controllers
sensors
core
function_pointer_sensor.h
Go to the documentation of this file.
1
/**
2
* @file function_pointer_sensor.h
3
* @brief A sensor to provide a bridge from old getX()-style functions to the new sensor registry.
4
*
5
* @date September 12, 2019
6
* @author Matthew Kennedy, (c) 2019
7
*/
8
9
#pragma once
10
11
#include "
sensor.h
"
12
13
/* This class is intended as a bridge to bridge from old getMySensor() functions
14
* to the new system. This way, producers and consumers can be independently
15
* updated to the new system, with sensors being usable either way for some time.
16
*/
17
class
FunctionPointerSensor
final :
public
Sensor
{
18
public
:
19
FunctionPointerSensor
(
SensorType
type
,
float
(*func)())
20
:
Sensor
(
type
)
21
,
m_func
(func) {}
22
23
SensorResult
get
() const final {
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
}
35
36
void
showInfo
(
const
char
*
/*sensorName*/
)
const override
{}
37
38
private
:
39
float
(*
m_func
)();
40
};
FunctionPointerSensor
Definition
function_pointer_sensor.h:17
FunctionPointerSensor::m_func
float(* m_func)()
Definition
function_pointer_sensor.h:39
FunctionPointerSensor::get
SensorResult get() const final
Definition
function_pointer_sensor.h:23
FunctionPointerSensor::FunctionPointerSensor
FunctionPointerSensor(SensorType type, float(*func)())
Definition
function_pointer_sensor.h:19
FunctionPointerSensor::showInfo
void showInfo(const char *) const override
Definition
function_pointer_sensor.h:36
Sensor
Definition
sensor.h:51
Sensor::type
SensorType type() const
Definition
sensor.h:162
float
sensor.h
Base class for sensors. Inherit this class to implement a new type of sensor.
SensorResult
expected< float > SensorResult
Definition
sensor.h:46
SensorType
SensorType
Definition
sensor_type.h:18
Generated on Fri Sep 26 2025 00:10:15 for rusEFI by
1.9.8