migrating to SensorType::Rpm API

This commit is contained in:
Andrey 2022-01-20 23:54:52 -05:00
parent 970f81c5b3
commit 014ea2b78a
5 changed files with 3 additions and 16 deletions

View File

@ -78,7 +78,7 @@ percent_t GppwmChannel::getOutput() const {
return m_config->dutyIfError;
}
float rpm = GET_RPM();
float rpm = Sensor::getOrZero(SensorType::Rpm);
float result = m_table->getValue(rpm, loadAxisValue.Value);

View File

@ -78,7 +78,6 @@ public:
#if EFI_UNIT_TEST
float mockFan = 0;
float mockRpm = 0;
float mockCrankingRpm = 0;
float mockTimeSinceBoot = 0;
int mockAcToggle = 0;

View File

@ -67,11 +67,6 @@ uint32_t RpmCalculator::getRevolutionCounterSinceStart(void) const {
*/
// todo: migrate to float return result or add a float version? this would have with calculations
int RpmCalculator::getRpm() const {
#if !EFI_PROD_CODE
if (mockRpm != MOCK_UNDEFINED) {
return mockRpm;
}
#endif /* EFI_PROD_CODE */
return rpmValue;
}
@ -80,9 +75,6 @@ int RpmCalculator::getRpm() const {
RpmCalculator::RpmCalculator() :
StoredValueSensor(SensorType::Rpm, 0)
{
#if !EFI_PROD_CODE
mockRpm = MOCK_UNDEFINED;
#endif /* EFI_PROD_CODE */
assignRpmValue(0);
}

View File

@ -39,9 +39,6 @@ typedef enum {
class RpmCalculator : public StoredValueSensor {
public:
#if !EFI_PROD_CODE
int mockRpm;
#endif /* EFI_PROD_CODE */
RpmCalculator();
void onSlowCallback();
@ -81,7 +78,6 @@ public:
/**
* Just a getter for rpmValue
* Also handles mockRpm if not EFI_PROD_CODE
*/
int getRpm() const;
/**
@ -157,7 +153,7 @@ private:
Timer engineStartTimer;
};
// Just a getter for rpmValue which also handles mockRpm if not EFI_PROD_CODE
// Just a getter for rpmValue
#define GET_RPM() ( engine->rpmCalculator.getRpm() )
#define isValidRpm(rpm) ((rpm) > 0 && (rpm) < UNREALISTIC_RPM)

View File

@ -83,7 +83,6 @@ TEST(GpPwm, TestGetOutput) {
MockVp3d table;
engine->rpmCalculator.mockRpm = 1200;
EXPECT_CALL(table, getValue(1200, 35.0f))
.WillRepeatedly([](float x, float tps) {
return tps;
@ -98,5 +97,6 @@ TEST(GpPwm, TestGetOutput) {
// Set TPS, should return tps value
Sensor::setMockValue(SensorType::Tps1, 35.0f);
Sensor::setMockValue(SensorType::Rpm, 1200);
EXPECT_FLOAT_EQ(35.0f, ch.getOutput());
}