diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2018-01-30 13:06:27 -0600 |
---|---|---|
committer | Matthew Barth <msbarth@us.ibm.com> | 2018-03-01 09:34:04 -0600 |
commit | 6f31d19b704adf7302f924c1fbb80059fd3e7532 (patch) | |
tree | 1d6d0e50ce07c5ac3dc04204dab74fac8370014f /monitor/trust_group.hpp | |
parent | 32affb9879b18226b3a026072ce1753f03b7ca58 (diff) | |
download | phosphor-fan-presence-6f31d19b704adf7302f924c1fbb80059fd3e7532.tar.gz phosphor-fan-presence-6f31d19b704adf7302f924c1fbb80059fd3e7532.zip |
Generate sensor to trust association
Each sensor listed to be associated with a trust group is defined to
either be part of the trust group or just affected by the results of the
trust group. This is denoted by defining an "in_trust" boolean attribute
that will include the sensor in the trust group for determination of
trust when true, otherwise only be included in the resulting trust
affect when defined as false.
When no "in_trust" attribute is given, the sensor is defaulted to be
included in the trust group determining trust.
Tested: Current trust group associations & reactions are unchanged
Change-Id: I717074bc1a32a07dc59f172a4c823c7e2bb84f8c
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'monitor/trust_group.hpp')
-rw-r--r-- | monitor/trust_group.hpp | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/monitor/trust_group.hpp b/monitor/trust_group.hpp index ff60508..7f28f6c 100644 --- a/monitor/trust_group.hpp +++ b/monitor/trust_group.hpp @@ -9,6 +9,11 @@ namespace fan namespace trust { +constexpr auto sensorName = 0; +constexpr auto inTrust = 1; +using GroupDefinition = std::tuple<std::string, + bool>; + /** * @class Group * @@ -43,9 +48,9 @@ class Group /** * Constructor * - * @param[in] names - the names of the sensors in the group + * @param[in] names - the names and inclusion of sensors in the group */ - explicit Group(const std::vector<std::string>& names) : + explicit Group(const std::vector<GroupDefinition>& names) : _names(names) { } @@ -65,12 +70,13 @@ class Group [&sensor](const auto& name) { return monitor::FAN_SENSOR_PATH + - name == sensor->name(); + std::get<sensorName>(name) == sensor->name(); }); if (found != _names.end()) { - _sensors.push_back(sensor); + auto gs = std::make_tuple(sensor, std::get<inTrust>(*found)); + _sensors.push_back(gs); } } @@ -89,7 +95,7 @@ class Group _sensors.end(), [&sensor](const auto& s) { - return sensor.name() == s->name(); + return sensor.name() == std::get<0>(s)->name(); }) != _sensors.end()); } @@ -107,7 +113,7 @@ class Group _sensors.end(), [](const auto& s) { - s->stopTimer(); + std::get<0>(s)->stopTimer(); }); } @@ -126,11 +132,11 @@ class Group { //If a sensor isn't functional, then its timer //already expired so don't bother starting it again - if (s->functional() && - static_cast<uint64_t>(s->getInput()) != - s->getTarget()) + if (std::get<0>(s)->functional() && + static_cast<uint64_t>(std::get<0>(s)->getInput()) != + std::get<0>(s)->getTarget()) { - s->startTimer(); + std::get<0>(s)->startTimer(); } }); } @@ -190,11 +196,13 @@ class Group protected: /** - * The sensor objects in the group. + * The sensor objects and their trust inclusion in the group. * * Added by registerSensor(). */ - std::vector<std::shared_ptr<monitor::TachSensor>> _sensors; + std::vector<std::tuple< + std::shared_ptr<monitor::TachSensor>, + bool>> _sensors; private: @@ -230,9 +238,10 @@ class Group bool _stateChange = false; /** - * The names of the sensors that should be added to this group + * The names of the sensors and whether it is included in + * determining trust for this group */ - const std::vector<std::string> _names; + const std::vector<GroupDefinition> _names; }; } |