Add UNC crossing option for FailSafe condition

Added a unc-failsafe meson option that if set to true, would then check
if any temperature sensor PIDs exceed their upper non-critical
threshold. If a sensor is detected to have exceeded their UNC, then the
zone associated with that PID would go to FailSafe.

By default, this option will be set to false for backwards
compatibility.

Change-Id: I2fbc6000e8d37b34c51d3578becdaf18d449b0e8
Signed-off-by: Jonico Eustaquio <jonico.eustaquio@fii-na.com>
diff --git a/dbus/dbushelper.cpp b/dbus/dbushelper.cpp
index 54c75ca..038e784 100644
--- a/dbus/dbushelper.cpp
+++ b/dbus/dbushelper.cpp
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include "config.h"
 
 #include "dbushelper.hpp"
 
@@ -160,7 +161,9 @@
     catch (const sdbusplus::exception_t&)
     {
         // do nothing, sensors don't have to expose critical thresholds
+#ifndef UNC_FAILSAFE
         return false;
+#endif
     }
 
     auto findCriticalLow = criticalMap.find("CriticalAlarmLow");
@@ -178,6 +181,32 @@
     {
         asserted = std::get<bool>(findCriticalHigh->second);
     }
+#ifdef UNC_FAILSAFE
+    if (!asserted)
+    {
+        auto warning = _bus.new_method_call(service.c_str(), path.c_str(),
+                                            propertiesintf, "GetAll");
+        warning.append(warningThreshInf);
+        PropertyMap warningMap;
+
+        try
+        {
+            auto msg = _bus.call(warning);
+            msg.read(warningMap);
+        }
+        catch (const sdbusplus::exception_t&)
+        {
+            // sensors don't have to expose non-critical thresholds
+            return false;
+        }
+        auto findWarningHigh = warningMap.find("WarningAlarmHigh");
+
+        if (findWarningHigh != warningMap.end())
+        {
+            asserted = std::get<bool>(findWarningHigh->second);
+        }
+    }
+#endif
     return asserted;
 }