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/pid/zone.hpp b/pid/zone.hpp
index 2854997..464e672 100644
--- a/pid/zone.hpp
+++ b/pid/zone.hpp
@@ -71,6 +71,7 @@
     bool getRedundantWrite(void) const override;
     void setManualMode(bool mode);
     bool getFailSafeMode(void) const override;
+    void markSensorMissing(const std::string& name);
 
     int64_t getZoneID(void) const override;
     void addSetPoint(double setPoint, const std::string& name) override;
@@ -99,8 +100,8 @@
     double getCachedValue(const std::string& name) override;
     ValueCacheEntry getCachedValues(const std::string& name) override;
 
-    void addFanInput(const std::string& fan);
-    void addThermalInput(const std::string& therm);
+    void addFanInput(const std::string& fan, bool missingAcceptable);
+    void addThermalInput(const std::string& therm, bool missingAcceptable);
 
     void initializeLog(void) override;
     void writeLog(const std::string& value) override;
@@ -166,7 +167,8 @@
             // check if fan fail.
             if (sensor->getFailed())
             {
-                _failSafeSensors.insert(sensorInput);
+                markSensorMissing(sensorInput);
+
                 if (debugEnabled)
                 {
                     std::cerr << sensorInput << " sensor get failed\n";
@@ -174,7 +176,8 @@
             }
             else if (timeout != 0 && duration >= period)
             {
-                _failSafeSensors.insert(sensorInput);
+                markSensorMissing(sensorInput);
+
                 if (debugEnabled)
                 {
                     std::cerr << sensorInput << " sensor timeout\n";
@@ -191,6 +194,7 @@
                         std::cerr << sensorInput
                                   << " is erased from failsafe sensor set\n";
                     }
+
                     _failSafeSensors.erase(kt);
                 }
             }
@@ -213,6 +217,7 @@
     const conf::CycleTime _cycleTime;
 
     std::set<std::string> _failSafeSensors;
+    std::set<std::string> _missingAcceptable;
 
     std::vector<double> _SetPoints;
     std::vector<double> _RPMCeilings;