presence: Sensor conflict checking for AnyOf
There can be more than one way to detect the presence of a fan, such as
by a GPIO and by a nonzero tach reading. The AnyOf redundancy policy
only requires one of these to indicate present when determining the
overall fan presence state.
This commit adds the functionality to check for the case when one of the
method reports not present while another reports present. In this case,
the one reporting not present will be considered the wrong one, and
depending on the detection type either an information event log or just
a journal trace will be created.
Only one log per method per power cycle will occur. Since one of the
methods probably looks for nonzero tach readings, there is a 5 second
delay after a power on is detected before a conflict check is done.
If the GPIO method is where the problem is detected, an event log is
created. If it's instead the tach sensor method, then a trace will just
be put in the journal because there is already code watching for and
creating event logs for stopped tachs - the fan monitor code.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I72a764ecff4076d6dc40335b92d177b6b3cfa2d9
diff --git a/presence/tach.hpp b/presence/tach.hpp
index 4432660..8fd9a08 100644
--- a/presence/tach.hpp
+++ b/presence/tach.hpp
@@ -71,6 +71,13 @@
*/
bool present() override;
+ /**
+ * @brief Called when this presence sensor doesn't agree with other ones.
+ *
+ * @param[in] fanInventoryPath - The fan inventory D-Bus object path.
+ */
+ void logConflict(const std::string& fanInventoryPath) const override;
+
private:
/**
* @brief Get the policy associated with this sensor.