8class SensorRegistryEntry {
10 const Sensor* getSensor() {
14 void setInvalidMockValue() {
19 void setMockValue(
float value,
bool mockRedundant) {
23 m_mockRedundant = mockRedundant;
38 if (m_sensor && m_sensor !=
sensor) {
63 const Sensor *s = m_sensor;
67 return UnexpectedCode::Configuration;
75 return UnexpectedCode::Configuration;
78 void showInfo(
const char* sensorName)
const {
80 efiPrintf(
"Sensor \"%s\" mocked with value %.2f", sensorName, m_mockValue);
82 const auto sensor = m_sensor;
87 efiPrintf(
"Sensor \"%s\" is not configured.", sensorName);
92 bool hasSensor()
const {
93 return m_useMock || (m_sensor && m_sensor->hasSensor());
96 float getRaw()
const {
97 const auto sensor = m_sensor;
107 bool isRedundant()
const {
108 const auto sensor = m_sensor;
115 return m_mockRedundant;
122 bool m_useMock =
false;
123 bool m_valid =
false;
124 bool m_mockRedundant =
false;
126 Sensor* m_sensor =
nullptr;
160 return entry ? entry->getSensor() :
nullptr;
171 return UnexpectedCode::Configuration;
180 return entry ? entry->getRaw() : 0;
186 return entry ? entry->isRedundant() :
false;
192 return entry ? entry->hasSensor() :
false;
199 entry->setInvalidMockValue();
207 entry->setMockValue(value, mockRedundant);
242 entry.showInfo(name);
260 using namespace rusefi::stringutil;
265 if (strEqualCaseInsensitive(sensorName, name)) {
const char * getSensorType(SensorType value)
void showInfo(const char *sensorName) const override
static bool isRedundant(SensorType type)
static void setMockValue(SensorType type, float value, bool mockRedundant=false)
static void resetMockValue(SensorType type)
static SensorRegistryEntry * getEntryForType(SensorType type)
static void setInvalidMockValue(SensorType type)
virtual bool hasSensor() const
static const Sensor * getSensorOfType(SensorType type)
virtual SensorResult get() const =0
virtual bool isRedundant() const
virtual float getRaw() const
static float getRaw(SensorType type)
static void showAllSensorInfo()
virtual void showInfo(const char *sensorName) const =0
static void inhibitTimeouts(bool inhibit)
static void resetAllMocks()
static bool hasSensor(SensorType type)
static void resetRegistry()
static bool s_inhibitSensorTimeouts
const char * getSensorName() const
static SensorResult get(SensorType type)
constexpr size_t getIndex()
void firmwareError(ObdCode code, const char *fmt,...)
static Lps25Sensor sensor(device)
SensorType findSensorTypeByName(const char *name)
static SensorRegistryEntry s_sensorRegistry[static_cast< size_t >(SensorType::PlaceholderLast)]
expected< float > SensorResult