diff options
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; }; } |