summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2018-02-16 12:38:27 -0600
committerMatthew Barth <msbarth@us.ibm.com>2018-03-01 09:34:09 -0600
commita1c88322b837b2b752494e91427d3950e1cd5ccc (patch)
treeed9914aab3682a222f9342e84d6c66f1d337afaf
parent6f31d19b704adf7302f924c1fbb80059fd3e7532 (diff)
downloadphosphor-fan-presence-a1c88322b837b2b752494e91427d3950e1cd5ccc.tar.gz
phosphor-fan-presence-a1c88322b837b2b752494e91427d3950e1cd5ccc.zip
Replace tuple with struct for trust sensor group
To simplify sensor and trust access, utilize a struct in place of a tuple for storing the trust group sensors and their inclusion in the trust determination. Tested: Current trust group associations & reactions are unchanged Change-Id: Ifd5cf5d0540a3b2028ccf74e725d8ddd11982aee Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rw-r--r--monitor/nonzero_speed_trust.hpp2
-rw-r--r--monitor/trust_group.hpp26
2 files changed, 16 insertions, 12 deletions
diff --git a/monitor/nonzero_speed_trust.hpp b/monitor/nonzero_speed_trust.hpp
index e1f787f..7e6a85a 100644
--- a/monitor/nonzero_speed_trust.hpp
+++ b/monitor/nonzero_speed_trust.hpp
@@ -54,7 +54,7 @@ class NonzeroSpeed : public Group
_sensors.end(),
[](const auto& s)
{
- return std::get<0>(s)->getInput() != 0;
+ return s.sensor->getInput() != 0;
});
}
};
diff --git a/monitor/trust_group.hpp b/monitor/trust_group.hpp
index 7f28f6c..a41520a 100644
--- a/monitor/trust_group.hpp
+++ b/monitor/trust_group.hpp
@@ -14,6 +14,12 @@ constexpr auto inTrust = 1;
using GroupDefinition = std::tuple<std::string,
bool>;
+struct GroupSensor
+{
+ std::shared_ptr<monitor::TachSensor> sensor;
+ bool inTrust;
+};
+
/**
* @class Group
*
@@ -75,8 +81,7 @@ class Group
if (found != _names.end())
{
- auto gs = std::make_tuple(sensor, std::get<inTrust>(*found));
- _sensors.push_back(gs);
+ _sensors.push_back({sensor, std::get<inTrust>(*found)});
}
}
@@ -95,7 +100,7 @@ class Group
_sensors.end(),
[&sensor](const auto& s)
{
- return sensor.name() == std::get<0>(s)->name();
+ return sensor.name() == s.sensor->name();
}) != _sensors.end());
}
@@ -113,7 +118,7 @@ class Group
_sensors.end(),
[](const auto& s)
{
- std::get<0>(s)->stopTimer();
+ s.sensor->stopTimer();
});
}
@@ -132,11 +137,12 @@ class Group
{
//If a sensor isn't functional, then its timer
//already expired so don't bother starting it again
- if (std::get<0>(s)->functional() &&
- static_cast<uint64_t>(std::get<0>(s)->getInput()) !=
- std::get<0>(s)->getTarget())
+ if (s.sensor->functional() &&
+ static_cast<uint64_t>(
+ s.sensor->getInput()) !=
+ s.sensor->getTarget())
{
- std::get<0>(s)->startTimer();
+ s.sensor->startTimer();
}
});
}
@@ -200,9 +206,7 @@ class Group
*
* Added by registerSensor().
*/
- std::vector<std::tuple<
- std::shared_ptr<monitor::TachSensor>,
- bool>> _sensors;
+ std::vector<GroupSensor> _sensors;
private:
OpenPOWER on IntegriCloud