Auto determine failsafe duty according sensor fail

- Auto determine the failsafe duty when sensor failed

example:
If PID config as follows, when "Die CPU0" sensor failed, fans in zone 0
will be set to 80%, when "DIMM0" sensor failed, since there is no
"FailSafePercent" setting in config, so set to zone's FailSafePercent
100%.
```
{
    "Class": "temp",
    ...
    ...
    ...
    "Inputs": [
        "Die CPU0"
    ],
    "Name": "CPU0 PID",
    "FailSafePercent": 80.0,
    ...
    ...
    ...
    "Type": "Pid",
    "Zones": [
        "Zone 0"
    ]
},
{
    "Class": "temp",
    ...
    ...
    ...
    "Inputs": [
        "DIMM[0-9]",
        "DIMM1[0-5]"
    ],
    "Name": "DIMM CPU0 PID",
    ...
    ...
    ...
    "Type": "Pid",
    "Zones": [
        "Zone 0"
    ]
},
{
    "FailSafePercent": 100.0,
    "MinThermalOutput": 0.0,
    "Name": "Zone 0",
    "Type": "Pid.Zone",
    "ZoneIndex": 0
},
```

Tested:
If zone1 and zone2 into failsafe duty 40% =>
fan0_pwm         | 1Dh | ok  | 29.0 | 24.70 unspecifi
fan1_pwm         | 1Eh | ok  | 29.1 | 24.70 unspecifi
fan2_pwm         | 1Fh | ok  | 29.2 | 39.98 unspecifi
fan3_pwm         | 20h | ok  | 29.3 | 39.98 unspecifi
fan4_pwm         | 21h | ok  | 29.4 | 39.98 unspecifi
fan5_pwm         | 22h | ok  | 29.5 | 39.98 unspecifi

cpu0_nbm         | 48h | ok  |  7.79 | 36 degrees C

Let cpu0_nbm(zone0 and zone2) into failsafe which set failsafe duty as
100% =>
fan0_pwm         | 1Dh | ok  | 29.0 | 99.96 unspecifi
fan1_pwm         | 1Eh | ok  | 29.1 | 99.96 unspecifi
fan2_pwm         | 1Fh | ok  | 29.2 | 39.98 unspecifi
fan3_pwm         | 20h | ok  | 29.3 | 39.98 unspecifi
fan4_pwm         | 21h | ok  | 29.4 | 99.96 unspecifi
fan5_pwm         | 22h | ok  | 29.5 | 99.96 unspecifi

cpu0_nbm         | 48h | ns  |  7.79 | No Reading

Signed-off-by: Harvey Wu <Harvey.Wu@quantatw.com>
Change-Id: Iaf5ffd1853e5cd110a1ef66c7a1fd073bc894dda
diff --git a/pid/zone.hpp b/pid/zone.hpp
index 52180a5..8c49f1f 100644
--- a/pid/zone.hpp
+++ b/pid/zone.hpp
@@ -82,7 +82,7 @@
     void addRPMCeiling(double ceiling) override;
     void clearSetPoints(void) override;
     void clearRPMCeilings(void) override;
-    double getFailSafePercent(void) const override;
+    double getFailSafePercent(void) override;
     double getMinThermalSetPoint(void) const;
     uint64_t getCycleIntervalTime(void) const override;
     uint64_t getUpdateThermalsCycle(void) const override;
@@ -121,8 +121,7 @@
                               std::string objPath, bool defer);
     bool isPidProcessEnabled(std::string name);
 
-    void initPidFailSafePercent(void);
-    void addPidFailSafePercent(std::string name, double percent);
+    void addPidFailSafePercent(std::vector<std::string> inputs, double percent);
 
     void updateThermalPowerDebugInterface(std::string pidName,
                                           std::string leader, double input,
@@ -214,13 +213,11 @@
     bool _redundantWrite = false;
     bool _accumulateSetPoint = false;
     const double _minThermalOutputSetPt;
-    // Current fail safe Percent.
-    double _failSafePercent;
     // Zone fail safe Percent setting by configuration.
     const double _zoneFailSafePercent;
     const conf::CycleTime _cycleTime;
 
-    std::set<std::string> _failSafeSensors;
+    std::map<std::string, double> _failSafeSensors;
     std::set<std::string> _missingAcceptable;
 
     std::map<std::string, double> _SetPoints;
@@ -236,10 +233,10 @@
 
     std::map<std::string, std::unique_ptr<ProcessObject>> _pidsControlProcess;
     /*
-     * <key = pidname, value = pid failsafe percent>
-     * Pid fail safe Percent setting by each pid controller configuration.
+     * <key = sensor name, value = sensor failsafe percent>
+     * sensor fail safe Percent setting by each pid controller configuration.
      */
-    std::map<std::string, double> _pidsFailSafePercent;
+    std::map<std::string, double> _sensorFailSafePercent;
 };
 
 } // namespace pid_control