From 6f31d19b704adf7302f924c1fbb80059fd3e7532 Mon Sep 17 00:00:00 2001 From: Matthew Barth Date: Tue, 30 Jan 2018 13:06:27 -0600 Subject: 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 --- monitor/trust_group.hpp | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'monitor/trust_group.hpp') 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; + /** * @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& names) : + explicit Group(const std::vector& names) : _names(names) { } @@ -65,12 +70,13 @@ class Group [&sensor](const auto& name) { return monitor::FAN_SENSOR_PATH + - name == sensor->name(); + std::get(name) == sensor->name(); }); if (found != _names.end()) { - _sensors.push_back(sensor); + auto gs = std::make_tuple(sensor, std::get(*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(s->getInput()) != - s->getTarget()) + if (std::get<0>(s)->functional() && + static_cast(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> _sensors; + std::vector, + 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 _names; + const std::vector _names; }; } -- cgit v1.2.1