platform-mc: Added EventManager

Added eventManager to handle sensor event class(00h) which is defined in
table 11 of DSP0248 v1.3.0. In this commit, the eventManager supports to
receive event asynchronously. The commit will also log the Ipmitool SEL
log and Redfish log for PLDM sensor event messages.

Change-Id: I1b337ccae454067841ffbbd8754631216a995542
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Signed-off-by: Gilbert Chen <gilbertc@nvidia.com>
diff --git a/platform-mc/terminus.cpp b/platform-mc/terminus.cpp
index c8cd91a..b5a1e8c 100644
--- a/platform-mc/terminus.cpp
+++ b/platform-mc/terminus.cpp
@@ -14,8 +14,8 @@
 {
 
 Terminus::Terminus(pldm_tid_t tid, uint64_t supportedTypes) :
-    initialized(false), synchronyConfigurationSupported(0), tid(tid),
-    supportedTypes(supportedTypes)
+    initialized(false), maxBufferSize(PLDM_PLATFORM_EVENT_MSG_MAX_BUFFER_SIZE),
+    synchronyConfigurationSupported(0), tid(tid), supportedTypes(supportedTypes)
 {}
 
 bool Terminus::doesSupportType(uint8_t type)
@@ -537,5 +537,36 @@
     }
 }
 
+std::shared_ptr<NumericSensor> Terminus::getSensorObject(SensorId id)
+{
+    if (terminusName.empty())
+    {
+        lg2::error(
+            "Terminus ID {TID}: DOES NOT have terminus name. No numeric sensor object.",
+            "TID", tid);
+        return nullptr;
+    }
+    if (!numericSensors.size())
+    {
+        lg2::error("Terminus ID {TID} name {NAME}: DOES NOT have sensor.",
+                   "TID", tid, "NAME", terminusName);
+        return nullptr;
+    }
+
+    for (auto& sensor : numericSensors)
+    {
+        if (!sensor)
+        {
+            continue;
+        }
+
+        if (sensor->sensorId == id)
+        {
+            return sensor;
+        }
+    }
+
+    return nullptr;
+}
 } // namespace platform_mc
 } // namespace pldm