rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
fallback_sensor.h
Go to the documentation of this file.
1#pragma once
2
3#include "sensor.h"
4
5class FallbackSensor final : public Sensor {
6public:
7 FallbackSensor(SensorType outputType, SensorType primarySensor, SensorType fallbackSensor)
8 : Sensor(outputType)
9 , m_primary(primarySensor)
10 , m_fallback(fallbackSensor)
11 {
12 }
13
14 SensorResult get() const override {
15 auto primary = Sensor::get(m_primary);
16
17 if (primary) {
18 return primary;
19 }
20
21 return Sensor::get(m_fallback);
22 }
23
24 void showInfo(const char* sensorName) const override;
25
26private:
29};
SensorResult get() const override
FallbackSensor(SensorType outputType, SensorType primarySensor, SensorType fallbackSensor)
void showInfo(const char *sensorName) const override
const SensorType m_primary
const SensorType m_fallback
virtual SensorResult get() const =0
Base class for sensors. Inherit this class to implement a new type of sensor.
expected< float > SensorResult
Definition sensor.h:46
SensorType
Definition sensor_type.h:18