platform-mc: Add sensor manager

Added sensor_manager class. The sensor_manager class manages the timing
of sensor polling.

tested: Verified on ast2600 EVB which is connected to a PLDM device
over I2C. bmcweb can display the state of numeric sensor.

Signed-off-by: Gilbert Chen <gilbert.chen@arm.com>
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: I4257f823ea26d7fdb322cc82d847e94db056258c
diff --git a/platform-mc/manager.hpp b/platform-mc/manager.hpp
index 7636e94..d8210b4 100644
--- a/platform-mc/manager.hpp
+++ b/platform-mc/manager.hpp
@@ -7,6 +7,7 @@
 #include "platform_manager.hpp"
 #include "requester/handler.hpp"
 #include "requester/mctp_endpoint_discovery.hpp"
+#include "sensor_manager.hpp"
 #include "terminus_manager.hpp"
 
 namespace pldm
@@ -33,7 +34,8 @@
     explicit Manager(sdeventplus::Event& event, RequesterHandler& handler,
                      pldm::InstanceIdDb& instanceIdDb) :
         terminusManager(event, handler, instanceIdDb, termini, this),
-        platformManager(terminusManager, termini)
+        platformManager(terminusManager, termini),
+        sensorManager(event, terminusManager, termini)
     {}
 
     /** @brief Helper function to do the actions before discovering terminus
@@ -68,6 +70,33 @@
         terminusManager.removeMctpTerminus(mctpInfos);
     }
 
+    /** @brief Helper function to start sensor polling of the terminus TID
+     */
+    void startSensorPolling(pldm_tid_t tid)
+    {
+        sensorManager.startPolling(tid);
+    }
+
+    /** @brief Helper function to set available state for pldm request (sensor
+     *         polling and event polling) of the terminus TID. The `false` state
+     *         will trigger stop flow in coroutine of sensor polling/event
+     *         polling task to stop.
+     */
+    void updateAvailableState(pldm_tid_t tid, Availability state)
+    {
+        if (termini.contains(tid))
+        {
+            sensorManager.updateAvailableState(tid, state);
+        }
+    }
+
+    /** @brief Helper function to stop sensor polling of the terminus TID
+     */
+    void stopSensorPolling(pldm_tid_t tid)
+    {
+        sensorManager.stopPolling(tid);
+    }
+
   private:
     /** @brief List of discovered termini */
     TerminiMapper termini{};
@@ -77,6 +106,9 @@
 
     /** @brief Platform interface for calling the hook functions */
     PlatformManager platformManager;
+
+    /** @brief Store platform manager handler */
+    SensorManager sensorManager;
 };
 } // namespace platform_mc
 } // namespace pldm