rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
sensor_info_printing.cpp
Go to the documentation of this file.
1#include "pch.h"
3#include "proxy_sensor.h"
4#include "functional_sensor.h"
5#include "fuel_level_sensor.h"
6#include "redundant_sensor.h"
8#include "fallback_sensor.h"
9#include "frequency_sensor.h"
10#include "Lps25Sensor.h"
11#include "linear_func.h"
12#include "resistance_func.h"
13#include "thermistor_func.h"
14#include "identity_func.h"
15#include "map_averaging.h"
16
17void StoredValueSensor::showInfo(const char* sensorName) const {
18 const auto value = get();
19 efiPrintf("StoredValue Sensor \"%s\": valid: %s, value: %.2f", sensorName, boolToString(value.Valid), value.Value);
20}
21
22void ProxySensor::showInfo(const char* sensorName) const {
23 efiPrintf("Sensor \"%s\" proxied from sensor \"%s\"", sensorName, getSensorName(m_proxiedSensor));
24}
25
26void FunctionalSensor::showInfo(const char* sensorName) const {
27 const auto value = get();
28 efiPrintf("Sensor \"%s\": Raw value: %.2f Valid: %s Converted value %.2f", sensorName, getRaw(), boolToString(value.Valid), value.Value);
29
30 // now print out the underlying function's info
31 if (auto func = getFunction()) {
32 func->showInfo(getRaw());
33 }
34}
35
36void FuelLevelSensor::showInfo(const char* sensorName) const {
37 const auto value = get();
38 efiPrintf("Sensor \"%s\": Raw value: %.2f Valid: %s Converted value %.2f", sensorName, getRaw(), boolToString(value.Valid), value.Value);
39}
40
41#if EFI_CAN_SUPPORT || EFI_UNIT_TEST
42#include "can_sensor.h"
43
44void CanSensorBase::showInfo(const char* sensorName) const {
45 const auto value = get();
46 efiPrintf("CAN Sensor \"%s\": valid: %s value: %.2f", sensorName, boolToString(value.Valid), value.Value);
47}
48#endif // EFI_CAN_SUPPORT
49
50void RedundantSensor::showInfo(const char* sensorName) const {
51 efiPrintf("Sensor \"%s\" is redundant combining \"%s\" and \"%s\"", sensorName, getSensorName(m_first), getSensorName(m_second));
52}
53
54void FrequencySensor::showInfo(const char* sensorName) const {
55 efiPrintf("FrequencySensor \"%s\" counter %d", sensorName, eventCounter);
56}
57
58void RedundantFordTps::showInfo(const char* sensorName) const {
59 efiPrintf("Sensor \"%s\" is Ford-type redundant TPS combining \"%s\" and \"%s\"", sensorName, getSensorName(m_first), getSensorName(m_second));
60}
61
62void FallbackSensor::showInfo(const char* sensorName) const {
63 efiPrintf("Sensor \"%s\" is fallback sensor with primary \"%s\" and fallback \"%s\"", sensorName, getSensorName(m_primary), getSensorName(m_fallback));
64}
65
66void RpmCalculator::showInfo(const char* /*sensorName*/) const {
67#if EFI_SHAFT_POSITION_INPUT
68 efiPrintf("RPM sensor: stopped: %d spinning up: %d cranking: %d running: %d rpm: %f",
69 isStopped(),
71 isCranking(),
72 isRunning(),
73 get().value_or(0)
74 );
75#endif // EFI_SHAFT_POSITION_INPUT
76}
77
78void Lps25Sensor::showInfo(const char* sensorName) const {
79 efiPrintf("%s: LPS25 baro %.2f kPa", sensorName, get().Value);
80}
81
82void MapAverager::showInfo(const char* sensorName) const {
83 const auto value = get();
84 efiPrintf("Sensor \"%s\" is MAP averager: valid: %s value: %.2f averaged sample count: %d", sensorName, boolToString(value.Valid), value.Value, m_lastCounter);
85}
86
87void LinearFunc::showInfo(float testRawValue) const {
88 efiPrintf(" Linear function slope: %.2f offset: %.2f min: %.1f max: %.1f", m_a, m_b, m_minOutput, m_maxOutput);
89 const auto value = convert(testRawValue);
90 efiPrintf(" raw value %.2f converts to %.2f valid: %s", testRawValue, value.Value, boolToString(value.Valid));
91}
92
93void ResistanceFunc::showInfo(float testInputValue) const {
94 const auto result = convert(testInputValue);
95 efiPrintf(" %.2f volts -> %.1f ohms with supply voltage %.2f and pullup %.1f.", testInputValue, result.Value, m_supplyVoltage, m_pullupResistor);
96}
97
98void ThermistorFunc::showInfo(float testInputValue) const {
99 const auto value = convert(testInputValue);
100 efiPrintf(" %.1f ohms -> valid: %s. %.1f deg C", testInputValue, boolToString(value.Valid), value.Value);
101}
102
103void IdentityFunction::showInfo(float /*testInputValue*/) const {
104 efiPrintf(" Identity function passes along value.");
105}
void showInfo(const char *sensorName) const override
void showInfo(const char *sensorName) const override
const SensorType m_primary
const SensorType m_fallback
void showInfo(const char *sensorName) const override
void showInfo(const char *sensorName) const override
void showInfo(const char *sensorName) const override
SensorResult convert(float inputValue) const override
float m_minOutput
Definition linear_func.h:25
void showInfo(float testRawValue) const override
float m_maxOutput
Definition linear_func.h:26
void showInfo(const char *sensorName) const override
size_t m_lastCounter
void showInfo(const char *sensorName) const override
void showInfo(const char *sensorName) const override
SensorType m_proxiedSensor
const SensorType m_first
const SensorType m_second
void showInfo(const char *sensorName) const override
const SensorType m_first
const SensorType m_second
void showInfo(const char *sensorName) const override
SensorResult convert(float inputValue) const override
void showInfo(float testInputValue) const override
bool isSpinningUp() const
bool isStopped() const override
void showInfo(const char *sensorName) const override
bool isRunning() const
bool isCranking() const override
const char * getSensorName() const
Definition sensor.h:130
void showInfo(const char *sensorName) const override
SensorResult get() const final override
void showInfo(float testRawValue) const override
SensorResult convert(float ohms) const override
const char * boolToString(bool value)
Definition efilib.cpp:19
A sensor to duplicate a sensor to an additional SensorType.
Base class for a sensor that has its value asynchronously set, then later retrieved by a consumer.
void showInfo(float testRawValue) const