diff options
Diffstat (limited to 'monitor')
-rwxr-xr-x | monitor/gen-fan-monitor-defs.py | 11 | ||||
-rw-r--r-- | monitor/nonzero_speed_trust.hpp | 7 | ||||
-rw-r--r-- | monitor/trust_group.hpp | 37 |
3 files changed, 34 insertions, 21 deletions
diff --git a/monitor/gen-fan-monitor-defs.py b/monitor/gen-fan-monitor-defs.py index 965625b..7a1b874 100755 --- a/monitor/gen-fan-monitor-defs.py +++ b/monitor/gen-fan-monitor-defs.py @@ -57,12 +57,15 @@ const std::vector<FanDefinition> fanDefinitions ##If a group were to ever need a different constructor, ##it could be handled here. <%def name="get_lambda_contents(group)"> - std::vector<std::string> names{ - %for sensor in group['sensors']: - "${sensor['name']}", + std::vector<GroupDefinition> group{ + %for member in group['group']: + <% + in_trust = str(member.get('in_trust', "true")).lower() + %> + GroupDefinition{"${member['name']}", ${in_trust}}, %endfor }; - return std::make_unique<${group['class']}>(names); + return std::make_unique<${group['class']}>(group); </%def> const std::vector<CreateGroupFunction> trustGroups { diff --git a/monitor/nonzero_speed_trust.hpp b/monitor/nonzero_speed_trust.hpp index 93fce7d..e1f787f 100644 --- a/monitor/nonzero_speed_trust.hpp +++ b/monitor/nonzero_speed_trust.hpp @@ -30,9 +30,10 @@ class NonzeroSpeed : public Group /** * Constructor * - * @param[in] names - the names of the sensors in the group + * @param[in] names - the names of the sensors and its inclusion in + * determining trust for the group */ - explicit NonzeroSpeed(const std::vector<std::string>& names) : + explicit NonzeroSpeed(const std::vector<GroupDefinition>& names) : Group(names) { } @@ -53,7 +54,7 @@ class NonzeroSpeed : public Group _sensors.end(), [](const auto& s) { - return s->getInput() != 0; + return std::get<0>(s)->getInput() != 0; }); } }; 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; }; } |