migrating to SensorType::Rpm API
This commit is contained in:
parent
4ebb3c94d3
commit
1bd71e4b2e
|
@ -78,7 +78,7 @@ percent_t GppwmChannel::getOutput() const {
|
||||||
return m_config->dutyIfError;
|
return m_config->dutyIfError;
|
||||||
}
|
}
|
||||||
|
|
||||||
float rpm = GET_RPM();
|
float rpm = Sensor::getOrZero(SensorType::Rpm);
|
||||||
|
|
||||||
float result = m_table->getValue(rpm, loadAxisValue.Value);
|
float result = m_table->getValue(rpm, loadAxisValue.Value);
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,6 @@ public:
|
||||||
|
|
||||||
#if EFI_UNIT_TEST
|
#if EFI_UNIT_TEST
|
||||||
float mockFan = 0;
|
float mockFan = 0;
|
||||||
float mockRpm = 0;
|
|
||||||
float mockCrankingRpm = 0;
|
float mockCrankingRpm = 0;
|
||||||
float mockTimeSinceBoot = 0;
|
float mockTimeSinceBoot = 0;
|
||||||
int mockAcToggle = 0;
|
int mockAcToggle = 0;
|
||||||
|
|
|
@ -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
|
// todo: migrate to float return result or add a float version? this would have with calculations
|
||||||
int RpmCalculator::getRpm() const {
|
int RpmCalculator::getRpm() const {
|
||||||
#if !EFI_PROD_CODE
|
|
||||||
if (mockRpm != MOCK_UNDEFINED) {
|
|
||||||
return mockRpm;
|
|
||||||
}
|
|
||||||
#endif /* EFI_PROD_CODE */
|
|
||||||
return rpmValue;
|
return rpmValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,9 +75,6 @@ int RpmCalculator::getRpm() const {
|
||||||
RpmCalculator::RpmCalculator() :
|
RpmCalculator::RpmCalculator() :
|
||||||
StoredValueSensor(SensorType::Rpm, 0)
|
StoredValueSensor(SensorType::Rpm, 0)
|
||||||
{
|
{
|
||||||
#if !EFI_PROD_CODE
|
|
||||||
mockRpm = MOCK_UNDEFINED;
|
|
||||||
#endif /* EFI_PROD_CODE */
|
|
||||||
assignRpmValue(0);
|
assignRpmValue(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,6 @@ typedef enum {
|
||||||
|
|
||||||
class RpmCalculator : public StoredValueSensor {
|
class RpmCalculator : public StoredValueSensor {
|
||||||
public:
|
public:
|
||||||
#if !EFI_PROD_CODE
|
|
||||||
int mockRpm;
|
|
||||||
#endif /* EFI_PROD_CODE */
|
|
||||||
RpmCalculator();
|
RpmCalculator();
|
||||||
|
|
||||||
void onSlowCallback();
|
void onSlowCallback();
|
||||||
|
@ -81,7 +78,6 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Just a getter for rpmValue
|
* Just a getter for rpmValue
|
||||||
* Also handles mockRpm if not EFI_PROD_CODE
|
|
||||||
*/
|
*/
|
||||||
int getRpm() const;
|
int getRpm() const;
|
||||||
/**
|
/**
|
||||||
|
@ -157,7 +153,7 @@ private:
|
||||||
Timer engineStartTimer;
|
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 GET_RPM() ( engine->rpmCalculator.getRpm() )
|
||||||
|
|
||||||
#define isValidRpm(rpm) ((rpm) > 0 && (rpm) < UNREALISTIC_RPM)
|
#define isValidRpm(rpm) ((rpm) > 0 && (rpm) < UNREALISTIC_RPM)
|
||||||
|
|
|
@ -83,7 +83,6 @@ TEST(GpPwm, TestGetOutput) {
|
||||||
|
|
||||||
MockVp3d table;
|
MockVp3d table;
|
||||||
|
|
||||||
engine->rpmCalculator.mockRpm = 1200;
|
|
||||||
EXPECT_CALL(table, getValue(1200, 35.0f))
|
EXPECT_CALL(table, getValue(1200, 35.0f))
|
||||||
.WillRepeatedly([](float x, float tps) {
|
.WillRepeatedly([](float x, float tps) {
|
||||||
return tps;
|
return tps;
|
||||||
|
@ -98,5 +97,6 @@ TEST(GpPwm, TestGetOutput) {
|
||||||
|
|
||||||
// Set TPS, should return tps value
|
// Set TPS, should return tps value
|
||||||
Sensor::setMockValue(SensorType::Tps1, 35.0f);
|
Sensor::setMockValue(SensorType::Tps1, 35.0f);
|
||||||
|
Sensor::setMockValue(SensorType::Rpm, 1200);
|
||||||
EXPECT_FLOAT_EQ(35.0f, ch.getOutput());
|
EXPECT_FLOAT_EQ(35.0f, ch.getOutput());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue