summaryrefslogtreecommitdiffstats
path: root/control
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2018-05-08 14:16:04 -0500
committerMatthew Barth <msbarth@linux.ibm.com>2018-05-16 17:25:57 +0000
commit572d406c89c80da2bb7ec4ccb42d2de3236000e1 (patch)
tree264a9a8e509f890f60207a1ef38f7878e0319af7 /control
parent702c4a55a69915c3ab3506ee552acc5c21e06e2a (diff)
downloadphosphor-fan-presence-572d406c89c80da2bb7ec4ccb42d2de3236000e1.tar.gz
phosphor-fan-presence-572d406c89c80da2bb7ec4ccb42d2de3236000e1.zip
Enhance precondition function and tracing
Replace count_if with all_of in the property states match precondition to stop iterating over the group members once a property state does not match. Include additional debug tracing when the precondition passes and fails to help in determining where the precondition causes fans to be at full speed. Tested: Verify debug traces align with precondition state Change-Id: I1c3d8f096a645ac3bfcdfb7b9197682cf7ca52a0 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'control')
-rw-r--r--control/preconditions.hpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/control/preconditions.hpp b/control/preconditions.hpp
index f989f0d..1423ac0 100644
--- a/control/preconditions.hpp
+++ b/control/preconditions.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <algorithm>
+#include <phosphor-logging/log.hpp>
namespace phosphor
{
@@ -11,6 +12,8 @@ namespace control
namespace precondition
{
+using namespace phosphor::logging;
+
/**
* @brief A precondition to compare a group of property values and
* subscribe/unsubscribe a set speed event group
@@ -34,7 +37,7 @@ auto property_states_match(std::vector<PrecondGroup>&& pg,
sse = std::move(sse)](auto& zone, auto& group)
{
// Compare given precondition entries
- size_t precondState = std::count_if(
+ auto precondState = std::all_of(
pg.begin(),
pg.end(),
[&zone](auto const& entry)
@@ -54,8 +57,11 @@ auto property_states_match(std::vector<PrecondGroup>&& pg,
}
});
- if (precondState == pg.size())
+ if (precondState)
{
+ log<level::DEBUG>(
+ "Preconditions passed, init the associated events",
+ entry("EVENT_COUNT=%u", sse.size()));
// Init the events when all the precondition(s) are true
std::for_each(
sse.begin(),
@@ -67,6 +73,9 @@ auto property_states_match(std::vector<PrecondGroup>&& pg,
}
else
{
+ log<level::DEBUG>(
+ "Preconditions not met for events, events removed if present",
+ entry("EVENT_COUNT=%u", sse.size()));
// Unsubscribe the events' signals when any precondition is false
std::for_each(
sse.begin(),
@@ -78,7 +87,7 @@ auto property_states_match(std::vector<PrecondGroup>&& pg,
zone.setFullSpeed();
}
// Update group's fan control active allowed
- zone.setActiveAllow(&group, (precondState == pg.size()));
+ zone.setActiveAllow(&group, precondState);
};
}
OpenPOWER on IntegriCloud