Add Asserted property for cpu thermtrip

Add "Asserted" property in dbus to make phosphor-ipmi-host could know
whether the cpu thermaltrip error is asserted or not.

Tested:
Add the monitor and check the objectPath name in dbus is as expected and
check the discrete sensor's status is not disable.

Signed-off-by: JinFuLin <JeffLin2@quantatw.com>
Change-Id: I9609b70994ac2a57daae25d1d5101d2178049ceb
diff --git a/include/error_monitors/cpu_thermtrip_monitor.hpp b/include/error_monitors/cpu_thermtrip_monitor.hpp
index fdc6cf2..02f11f4 100644
--- a/include/error_monitors/cpu_thermtrip_monitor.hpp
+++ b/include/error_monitors/cpu_thermtrip_monitor.hpp
@@ -26,10 +26,12 @@
     const static host_error_monitor::base_gpio_monitor::AssertValue
         assertValue =
             host_error_monitor::base_gpio_monitor::AssertValue::lowAssert;
+    std::shared_ptr<sdbusplus::asio::dbus_interface> assertInterface;
     size_t cpuNum;
 
     void logEvent() override
     {
+        assertInterface->set_property("Asserted", true);
         cpuThermTripLog();
     }
 
@@ -43,13 +45,29 @@
                         cpuNum, NULL);
     }
 
+    void deassertHandler() override
+    {
+        assertInterface->set_property("Asserted", false);
+    }
+
   public:
     CPUThermtripMonitor(boost::asio::io_service& io,
                         std::shared_ptr<sdbusplus::asio::connection> conn,
-                        const std::string& signalName, const size_t cpuNum) :
+                        const std::string& signalName, const size_t cpuNum,
+                        const std::string& customName = std::string()) :
         BaseGPIOMonitor(io, conn, signalName, assertValue),
         cpuNum(cpuNum)
     {
+        sdbusplus::asio::object_server server =
+            sdbusplus::asio::object_server(conn);
+        std::string objectName = customName.empty() ? signalName : customName;
+        std::string path =
+            "/xyz/openbmc_project/host_error_monitor/processor/" + objectName;
+
+        assertInterface = server.add_interface(
+            path, "xyz.openbmc_project.HostErrorMonitor.Processor.ThermalTrip");
+        assertInterface->register_property("Asserted", false);
+        assertInterface->initialize();
         if (valid)
         {
             startMonitoring();