rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
functional_sensor_impl.hpp
Go to the documentation of this file.
1template<class ConverterType>
3 : FunctionalSensorBase(type, timeoutPeriod) {
4}
5
6template<class ConverterType>
8 m_function = &func;
9}
10
11template<class ConverterType>
13 return m_function;
15
16template<class ConverterType>
18 return m_rawValue;
19}
21template<class ConverterType>
22void 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}
ConverterType * getFunction() const
FunctionalSensorImpl(SensorType type, efidur_t timeoutPeriod)
void setFunction(ConverterType &func)
float getRaw() const override final
void postRawValue(float inputValue, efitick_t timestamp) override
efitick_t efidur_t
SensorType
Definition sensor_type.h:18