rename away from RPM
The SetPoint output from a thermal PID is likely RPM, and that value is
then fed into a fan controller PID as the set-point (unit: RPM). This
does not have to be RPM, however. Continue renaming variables and
methods to remove the explicit unit-naming.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I570dee0c688338f9a458cac7123314717bee2b42
diff --git a/conf.hpp b/conf.hpp
index 35c2da5..95bdeaa 100644
--- a/conf.hpp
+++ b/conf.hpp
@@ -48,7 +48,7 @@
*/
struct ZoneConfig
{
- /* The minimum RPM value we would ever want. */
+ /* The minimum set-point value we would ever want (typically in RPM) */
double minThermalOutput;
/* If the sensors are in fail-safe mode, this is the percentage to use. */
diff --git a/pid/fancontroller.cpp b/pid/fancontroller.cpp
index 1f23e0b..dd26d16 100644
--- a/pid/fancontroller.cpp
+++ b/pid/fancontroller.cpp
@@ -88,7 +88,7 @@
double FanController::setptProc(void)
{
- double maxRPM = _owner->getMaxRPMRequest();
+ double maxRPM = _owner->getMaxSetPointRequest();
// store for reference, and check if more or less.
double prev = getSetpoint();
diff --git a/pid/pidloop.cpp b/pid/pidloop.cpp
index b86ea4b..56bf8bd 100644
--- a/pid/pidloop.cpp
+++ b/pid/pidloop.cpp
@@ -37,7 +37,7 @@
// Run the margin PIDs.
zone->processThermals();
// Get the maximum RPM setpoint.
- zone->determineMaxRPMRequest();
+ zone->determineMaxSetPointRequest();
}
void pidControlLoop(PIDZone* zone, boost::asio::steady_timer& timer, bool first,
diff --git a/pid/zone.cpp b/pid/zone.cpp
index 47d6695..6a63671 100644
--- a/pid/zone.cpp
+++ b/pid/zone.cpp
@@ -35,9 +35,9 @@
using tstamp = std::chrono::high_resolution_clock::time_point;
using namespace std::literals::chrono_literals;
-double PIDZone::getMaxRPMRequest(void) const
+double PIDZone::getMaxSetPointRequest(void) const
{
- return _maximumRPMSetPt;
+ return _maximumSetPoint;
}
bool PIDZone::getManualMode(void) const
@@ -86,7 +86,7 @@
return _failSafePercent;
}
-double PIDZone::getMinThermalRPMSetpoint(void) const
+double PIDZone::getMinThermalSetpoint(void) const
{
return _minThermalOutputSetPt;
}
@@ -116,7 +116,7 @@
_thermalInputs.push_back(therm);
}
-void PIDZone::determineMaxRPMRequest(void)
+void PIDZone::determineMaxSetPointRequest(void)
{
double max = 0;
std::vector<double>::iterator result;
@@ -137,7 +137,7 @@
* If the maximum RPM setpoint output is below the minimum RPM
* setpoint, set it to the minimum.
*/
- max = std::max(getMinThermalRPMSetpoint(), max);
+ max = std::max(getMinThermalSetpoint(), max);
if (tuningEnabled)
{
@@ -167,7 +167,7 @@
}
}
- _maximumRPMSetPt = max;
+ _maximumSetPoint = max;
return;
}
@@ -223,7 +223,7 @@
_log << std::chrono::duration_cast<std::chrono::milliseconds>(
now.time_since_epoch())
.count();
- _log << "," << _maximumRPMSetPt;
+ _log << "," << _maximumSetPoint;
}
for (const auto& f : _fanInputs)
diff --git a/pid/zone.hpp b/pid/zone.hpp
index 5516bed..3cf4e59 100644
--- a/pid/zone.hpp
+++ b/pid/zone.hpp
@@ -30,7 +30,7 @@
virtual double getCachedValue(const std::string& name) = 0;
virtual void addSetPoint(double setpoint) = 0;
virtual void addRPMCeiling(double ceiling) = 0;
- virtual double getMaxRPMRequest() const = 0;
+ virtual double getMaxSetPointRequest() const = 0;
virtual bool getFailSafeMode() const = 0;
virtual double getFailSafePercent() const = 0;
virtual Sensor* getSensor(const std::string& name) = 0;
@@ -48,7 +48,7 @@
const SensorManager& mgr, sdbusplus::bus::bus& bus,
const char* objPath, bool defer) :
ModeObject(bus, objPath, defer),
- _zoneId(zone), _maximumRPMSetPt(),
+ _zoneId(zone), _maximumSetPoint(),
_minThermalOutputSetPt(minThermalOutput),
_failSafePercent(failSafePercent), _mgr(mgr)
{
@@ -58,7 +58,7 @@
}
}
- double getMaxRPMRequest(void) const override;
+ double getMaxSetPointRequest(void) const override;
bool getManualMode(void) const;
/* Could put lock around this since it's accessed from two threads, but
@@ -72,10 +72,10 @@
void clearSetPoints(void);
void clearRPMCeilings(void);
double getFailSafePercent(void) const override;
- double getMinThermalRPMSetpoint(void) const;
+ double getMinThermalSetpoint(void) const;
Sensor* getSensor(const std::string& name) override;
- void determineMaxRPMRequest(void);
+ void determineMaxSetPointRequest(void);
void updateFanTelemetry(void);
void updateSensors(void);
void initializeCache(void);
@@ -101,7 +101,7 @@
std::ofstream _log;
const int64_t _zoneId;
- double _maximumRPMSetPt = 0;
+ double _maximumSetPoint = 0;
bool _manualMode = false;
const double _minThermalOutputSetPt;
const double _failSafePercent;
diff --git a/test/pid_fancontroller_unittest.cpp b/test/pid_fancontroller_unittest.cpp
index ad646bf..abf9aaa 100644
--- a/test/pid_fancontroller_unittest.cpp
+++ b/test/pid_fancontroller_unittest.cpp
@@ -122,21 +122,21 @@
// Fanspeed starts are Neutral.
EXPECT_EQ(FanSpeedDirection::NEUTRAL, fp->getFanDirection());
- // getMaxRPMRequest returns a higher value than 0, so the fans should be
- // marked as speeding up.
- EXPECT_CALL(z, getMaxRPMRequest()).WillOnce(Return(10.0));
+ // getMaxSetPointRequest returns a higher value than 0, so the fans should
+ // be marked as speeding up.
+ EXPECT_CALL(z, getMaxSetPointRequest()).WillOnce(Return(10.0));
EXPECT_EQ(10.0, p->setptProc());
EXPECT_EQ(FanSpeedDirection::UP, fp->getFanDirection());
- // getMaxRPMRequest returns a lower value than 10, so the fans should be
- // marked as slowing down.
- EXPECT_CALL(z, getMaxRPMRequest()).WillOnce(Return(5.0));
+ // getMaxSetPointRequest returns a lower value than 10, so the fans should
+ // be marked as slowing down.
+ EXPECT_CALL(z, getMaxSetPointRequest()).WillOnce(Return(5.0));
EXPECT_EQ(5.0, p->setptProc());
EXPECT_EQ(FanSpeedDirection::DOWN, fp->getFanDirection());
- // getMaxRPMRequest returns the same value, so the fans should be marked as
- // neutral.
- EXPECT_CALL(z, getMaxRPMRequest()).WillOnce(Return(5.0));
+ // getMaxSetPointRequest returns the same value, so the fans should be
+ // marked as neutral.
+ EXPECT_CALL(z, getMaxSetPointRequest()).WillOnce(Return(5.0));
EXPECT_EQ(5.0, p->setptProc());
EXPECT_EQ(FanSpeedDirection::NEUTRAL, fp->getFanDirection());
}
diff --git a/test/pid_zone_unittest.cpp b/test/pid_zone_unittest.cpp
index e0ecd76..5da10f8 100644
--- a/test/pid_zone_unittest.cpp
+++ b/test/pid_zone_unittest.cpp
@@ -121,8 +121,8 @@
TEST_F(PidZoneTest, RpmSetPoints_AddMaxClear_BehaveAsExpected)
{
- // Tests addSetPoint, clearSetPoints, determineMaxRPMRequest
- // and getMinThermalRPMSetpoint.
+ // Tests addSetPoint, clearSetPoints, determineMaxSetPointRequest
+ // and getMinThermalSetpoint.
// At least one value must be above the minimum thermal setpoint used in
// the constructor otherwise it'll choose that value
@@ -133,15 +133,15 @@
}
// This will pull the maximum RPM setpoint request.
- zone->determineMaxRPMRequest();
- EXPECT_EQ(5000, zone->getMaxRPMRequest());
+ zone->determineMaxSetPointRequest();
+ EXPECT_EQ(5000, zone->getMaxSetPointRequest());
// Clear the values, so it'll choose the minimum thermal setpoint.
zone->clearSetPoints();
// This will go through the RPM set point values and grab the maximum.
- zone->determineMaxRPMRequest();
- EXPECT_EQ(zone->getMinThermalRPMSetpoint(), zone->getMaxRPMRequest());
+ zone->determineMaxSetPointRequest();
+ EXPECT_EQ(zone->getMinThermalSetpoint(), zone->getMaxSetPointRequest());
}
TEST_F(PidZoneTest, RpmSetPoints_AddBelowMinimum_BehavesAsExpected)
@@ -156,10 +156,10 @@
}
// This will pull the maximum RPM setpoint request.
- zone->determineMaxRPMRequest();
+ zone->determineMaxSetPointRequest();
// Verifies the value returned in the minimal thermal rpm set point.
- EXPECT_EQ(zone->getMinThermalRPMSetpoint(), zone->getMaxRPMRequest());
+ EXPECT_EQ(zone->getMinThermalSetpoint(), zone->getMaxSetPointRequest());
}
TEST_F(PidZoneTest, GetFailSafePercent_ReturnsExpected)
diff --git a/test/zone_mock.hpp b/test/zone_mock.hpp
index a81ddeb..cd97f1f 100644
--- a/test/zone_mock.hpp
+++ b/test/zone_mock.hpp
@@ -14,7 +14,7 @@
MOCK_METHOD1(getCachedValue, double(const std::string&));
MOCK_METHOD1(addSetPoint, void(double));
MOCK_METHOD1(addRPMCeiling, void(double));
- MOCK_CONST_METHOD0(getMaxRPMRequest, double());
+ MOCK_CONST_METHOD0(getMaxSetPointRequest, double());
MOCK_CONST_METHOD0(getFailSafeMode, bool());
MOCK_CONST_METHOD0(getFailSafePercent, double());
MOCK_METHOD1(getSensor, Sensor*(const std::string&));