Cleaned up usage of updateValue() callers
Removed needless float, simply using double
Corrected string parsing function called for each type
Callers no longer need to check for equality first
Equality test now added to int and string override methods
This ensures all have same semantics
Removed extraordinarily spammy debug in updateValue(double)
Signed-off-by: Josh Lehan <krellan@google.com>
Change-Id: If8422d6516e083041685ddb6ef8cd469299cbad3
diff --git a/src/PSUEvent.cpp b/src/PSUEvent.cpp
index 4e5c5a7..0849500 100644
--- a/src/PSUEvent.cpp
+++ b/src/PSUEvent.cpp
@@ -198,12 +198,10 @@
try
{
std::getline(responseStream, response);
- int nvalue = std::stof(response);
+ int nvalue = std::stoi(response);
responseStream.clear();
- if (nvalue != value)
- {
- updateValue(nvalue);
- }
+
+ updateValue(nvalue);
errCount = 0;
}
catch (const std::invalid_argument&)
@@ -240,6 +238,13 @@
// deasserted.
void PSUSubEvent::updateValue(const int& newValue)
{
+ // Take no action if value already equal
+ // Same semantics as Sensor::updateValue(const double&)
+ if (newValue == value)
+ {
+ return;
+ }
+
if (newValue == 0)
{
// log deassert only after all asserts are gone