DBusConfiguration: Fix scaling
Revert the removal of the /100 because that caused
90% to be passed as 90 instead of .9. To counter-act
this multiply the stepwise controller by 100 so that
setting 50 is 50%.
Tested-by: Used sensor override to make stepwise jump
threshold and got desired pwm result.
Change-Id: I629bf0d4b0b3bc77660c09fccae82b1bdac4c578
diff --git a/pid/fancontroller.cpp b/pid/fancontroller.cpp
index ee43e4e..4a61def 100644
--- a/pid/fancontroller.cpp
+++ b/pid/fancontroller.cpp
@@ -14,8 +14,6 @@
* limitations under the License.
*/
-#include "config.h"
-
#include "fancontroller.hpp"
#include "util.hpp"
@@ -128,12 +126,8 @@
}
#endif
-// in the dbus configurations the /100 is added to the configurations
-// directly so this step is not needed
-#if !CONFIGURE_DBUS
// value and kFanFailSafeDutyCycle are 10 for 10% so let's fix that.
percent /= 100;
-#endif
// PidSensorMap for writing.
for (const auto& it : _inputs)
diff --git a/pid/stepwisecontroller.cpp b/pid/stepwisecontroller.cpp
index 43fd241..fee25ab 100644
--- a/pid/stepwisecontroller.cpp
+++ b/pid/stepwisecontroller.cpp
@@ -95,6 +95,8 @@
void StepwiseController::outputProc(double value)
{
+ // values are 10 for 10%
+ value *= 100;
_owner->addRPMSetPoint(value);
return;
diff --git a/test/pid_stepwisecontroller_unittest.cpp b/test/pid_stepwisecontroller_unittest.cpp
index e3c4f09..5b1e655 100644
--- a/test/pid_stepwisecontroller_unittest.cpp
+++ b/test/pid_stepwisecontroller_unittest.cpp
@@ -12,6 +12,8 @@
using ::testing::Return;
using ::testing::StrEq;
+constexpr size_t scale = 100; // values are 10 for 10%
+
TEST(StepwiseControllerTest, HysteresisTestPositive)
{
// Verifies positive hysteresis works as expected
@@ -38,8 +40,8 @@
.WillOnce(Return(31.0)) // return 40
.WillOnce(Return(32.0)); // return 60
- EXPECT_CALL(z, addRPMSetPoint(40.0)).Times(2);
- EXPECT_CALL(z, addRPMSetPoint(60.0)).Times(1);
+ EXPECT_CALL(z, addRPMSetPoint(40.0 * scale)).Times(2);
+ EXPECT_CALL(z, addRPMSetPoint(60.0 * scale)).Times(1);
for (int ii = 0; ii < 3; ii++)
{
@@ -73,8 +75,8 @@
.WillOnce(Return(27.0)) // return 60
.WillOnce(Return(26.0)); // return 40
- EXPECT_CALL(z, addRPMSetPoint(40.0)).Times(1);
- EXPECT_CALL(z, addRPMSetPoint(60.0)).Times(2);
+ EXPECT_CALL(z, addRPMSetPoint(40.0 * scale)).Times(1);
+ EXPECT_CALL(z, addRPMSetPoint(60.0 * scale)).Times(2);
for (int ii = 0; ii < 3; ii++)
{