Add MissingIsAcceptable feature to avoid failsafe

This is a partial implementation of the ideas here:
https://github.com/openbmc/phosphor-pid-control/issues/31

A new configuration item is supported in the PID object, named
"MissingIsAcceptable" (for D-Bus) or "missingIsAcceptable" (for the old
config.json). The value is an array of strings. If these strings match
sensor names, those sensors will be flagged as "missing is acceptable",
that is, they can go missing and the zone will not be thrown into
failsafe mode as a result.

This can be handy for sensors that are not always available on your
particular machine. It is independent of the existing Availability
interface, because the decision to go into failsafe mode or not is a
property of the PID loop, not of the sensor itself.

If a PID loop consists of all sensors that are missing, the output
will be deemed to be the setpoint, thus essentially making the PID
loop a no-op. Now initializing sensor values to NaN, not zero, as zero
is not a good default if PID loop is margin, undoing a bug I made:
https://gerrit.openbmc.org/c/openbmc/phosphor-pid-control/+/38228

Tested: It worked for me. Also, added a unit test case.

Change-Id: Idc7978ab06fcc9ed8c6c9df9483101376e5df4d1
Signed-off-by: Josh Lehan <krellan@google.com>
diff --git a/util.cpp b/util.cpp
index 87c4deb..b83ed43 100644
--- a/util.cpp
+++ b/util.cpp
@@ -103,15 +103,16 @@
 
 std::vector<conf::SensorInput>
     spliceInputs(const std::vector<std::string>& inputNames,
-                 const std::vector<double>& inputTempToMargin)
+                 const std::vector<double>& inputTempToMargin,
+                 const std::vector<std::string>& missingAcceptableNames)
 {
     std::vector<conf::SensorInput> results;
 
-    // Default to the TempToMargin feature disabled
+    // Default to TempToMargin and MissingIsAcceptable disabled
     for (const auto& inputName : inputNames)
     {
         conf::SensorInput newInput{
-            inputName, std::numeric_limits<double>::quiet_NaN(), false};
+            inputName, std::numeric_limits<double>::quiet_NaN(), false, false};
 
         results.emplace_back(newInput);
     }
@@ -132,6 +133,23 @@
         results[index].convertTempToMargin = true;
     }
 
+    std::set<std::string> acceptableSet;
+
+    // Copy vector to set, to avoid O(n^2) runtime below
+    for (const auto& name : missingAcceptableNames)
+    {
+        acceptableSet.emplace(name);
+    }
+
+    // Flag missingIsAcceptable true if name found in that set
+    for (auto& result : results)
+    {
+        if (acceptableSet.find(result.name) != acceptableSet.end())
+        {
+            result.missingIsAcceptable = true;
+        }
+    }
+
     return results;
 }