fix (#1268)
This commit is contained in:
parent
5cefd5c086
commit
595df15dfd
|
@ -5,6 +5,11 @@
|
||||||
class Logging;
|
class Logging;
|
||||||
|
|
||||||
struct SensorConverter {
|
struct SensorConverter {
|
||||||
|
// Trying to copy a converter func by value is almost guaranteed to be a bug - disallow it
|
||||||
|
SensorConverter(const SensorConverter&) = delete;
|
||||||
|
// ...but doing so requires explicitly declaring the default constructor, so do that too.
|
||||||
|
SensorConverter() = default;
|
||||||
|
|
||||||
virtual SensorResult convert(float raw) const = 0;
|
virtual SensorResult convert(float raw) const = 0;
|
||||||
virtual void showInfo(Logging* logger, float testRawValue) const {}
|
virtual void showInfo(Logging* logger, float testRawValue) const {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,8 +14,7 @@ EXTERN_ENGINE;
|
||||||
LinearFunc oilpSensorFunc;
|
LinearFunc oilpSensorFunc;
|
||||||
FunctionalSensor oilpSensor(SensorType::OilPressure, /* timeout = */ MS2NT(50));
|
FunctionalSensor oilpSensor(SensorType::OilPressure, /* timeout = */ MS2NT(50));
|
||||||
|
|
||||||
void configureOilPressure(LinearFunc func, const oil_pressure_config_s& cfg)
|
void configureOilPressure(LinearFunc& func, const oil_pressure_config_s& cfg) {
|
||||||
{
|
|
||||||
float val1 = cfg.value1;
|
float val1 = cfg.value1;
|
||||||
float val2 = cfg.value2;
|
float val2 = cfg.value2;
|
||||||
|
|
||||||
|
|
|
@ -108,3 +108,28 @@ TEST(SensorInit, DriverIntentWith) {
|
||||||
// Should get the pedal
|
// Should get the pedal
|
||||||
EXPECT_EQ(Sensor::get(SensorType::DriverThrottleIntent).Value, 75);
|
EXPECT_EQ(Sensor::get(SensorType::DriverThrottleIntent).Value, 75);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(SensorInit, OilPressure) {
|
||||||
|
WITH_ENGINE_TEST_HELPER(TEST_ENGINE);
|
||||||
|
|
||||||
|
CONFIG(oilPressure.hwChannel) = EFI_ADC_0;
|
||||||
|
CONFIG(oilPressure.v1) = 1;
|
||||||
|
CONFIG(oilPressure.v2) = 4;
|
||||||
|
CONFIG(oilPressure.value1) = 0;
|
||||||
|
CONFIG(oilPressure.value2) = 1000;
|
||||||
|
|
||||||
|
initOilPressure(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
|
// Ensure the sensors were registered
|
||||||
|
auto s = const_cast<Sensor*>(Sensor::getSensorOfType(SensorType::OilPressure));
|
||||||
|
ASSERT_NE(nullptr, s);
|
||||||
|
|
||||||
|
// Test in range
|
||||||
|
EXPECT_POINT_VALID(s, 1.0f, 0.0f); // minimum
|
||||||
|
EXPECT_POINT_VALID(s, 2.5f, 500.0f); // mid
|
||||||
|
EXPECT_POINT_VALID(s, 4.0f, 1000.0f) // maximium
|
||||||
|
|
||||||
|
// Test out of range
|
||||||
|
EXPECT_POINT_INVALID(s, 0.0f);
|
||||||
|
EXPECT_POINT_INVALID(s, 5.0f);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue