rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
controllers
sensors
core
functional_sensor_impl.hpp
Go to the documentation of this file.
1
template
<
class
ConverterType>
2
FunctionalSensorImpl<ConverterType>::FunctionalSensorImpl
(
const
SensorType
type,
const
efidur_t
timeoutPeriod)
3
:
FunctionalSensorBase
(type, timeoutPeriod) {
4
}
5
6
template
<
class
ConverterType>
7
void
FunctionalSensorImpl<ConverterType>::setFunction
(ConverterType& func) {
8
m_function = &func;
9
}
10
11
template
<
class
ConverterType>
12
ConverterType*
FunctionalSensorImpl<ConverterType>::getFunction
()
const
{
13
return
m_function;
14
}
15
16
template
<
class
ConverterType>
17
float
FunctionalSensorImpl<ConverterType>::getRaw
()
const
{
18
return
m_rawValue;
19
}
20
21
template
<
class
ConverterType>
22
void
FunctionalSensorImpl<ConverterType>::postRawValue
(
const
float
inputValue,
const
efitick_t timestamp) {
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
}
FunctionalSensorBase
Definition
functional_sensor_base.h:9
FunctionalSensorImpl::getFunction
ConverterType * getFunction() const
Definition
functional_sensor_impl.hpp:12
FunctionalSensorImpl::FunctionalSensorImpl
FunctionalSensorImpl(SensorType type, efidur_t timeoutPeriod)
Definition
functional_sensor_impl.hpp:2
FunctionalSensorImpl::setFunction
void setFunction(ConverterType &func)
Definition
functional_sensor_impl.hpp:7
FunctionalSensorImpl::getRaw
float getRaw() const override final
Definition
functional_sensor_impl.hpp:17
FunctionalSensorImpl::postRawValue
void postRawValue(float inputValue, efitick_t timestamp) override
Definition
functional_sensor_impl.hpp:22
efidur_t
efitick_t efidur_t
Definition
rusefi_types.h:42
SensorType
SensorType
Definition
sensor_type.h:18
Generated on Sat Sep 27 2025 00:10:06 for rusEFI by
1.9.8