ADCSensor: Add PollRate and fix PowerState Always

    If set "PowerState" as "On" then there will create the handler to
check the host state is running or not. However, "PowerState" with
default "always" will not create the handler and cause ADCSensor crashed
by function isPowerOn when calling function checkThresholdsPowerDelay.
    For example, in our platform, we have only one ADCSensor which is
for p3v battery and need to be updated once per day.

Tested:
Test the threshold low/high for the following test case by using
"busctl set-property" to trigger threshold event and checking the
time in "ipmitool sel elist".
1. one sensor with PowerState is Always:
   When trigger low threshold it will delay 5 seconds to assert
   threshold event and the service is still alive.
   When trigger high threshold it will immediately assert the threshold
   event.
2. one sensor with other PowerState("On","BiosPost") will have the same
   behavior with case 1.

Test the following polling time by adding log in function updateValue:
PollRate not write in configuration: polling time is 0.5 sec.
PollRate with zero (value 0): polling time is 0.5 sec.
PollRate with negative value (value -1.0): polling time is 0.5 sec.
PollRate with positive value (value 2.0): polling time is 2.0 sec.

Signed-off-by: Jeff Lin <JeffLin2@quantatw.com>
Change-Id: I9044dd3b3844161721134f30a4de3229602a9172
diff --git a/include/ADCSensor.hpp b/include/ADCSensor.hpp
index d1edf6d..9ba0060 100644
--- a/include/ADCSensor.hpp
+++ b/include/ADCSensor.hpp
@@ -66,8 +66,8 @@
               std::shared_ptr<sdbusplus::asio::connection>& conn,
               boost::asio::io_service& io, const std::string& sensorName,
               std::vector<thresholds::Threshold>&& thresholds,
-              const double scaleFactor, PowerState readState,
-              const std::string& sensorConfiguration,
+              const double scaleFactor, const float pollRate,
+              PowerState readState, const std::string& sensorConfiguration,
               std::optional<BridgeGpio>&& bridgeGpio);
     ~ADCSensor() override;
     void setupRead(void);
@@ -79,6 +79,7 @@
     std::shared_ptr<boost::asio::streambuf> readBuf;
     std::string path;
     double scaleFactor;
+    unsigned int sensorPollMs;
     std::optional<BridgeGpio> bridgeGpio;
     thresholds::ThresholdTimer thresholdTimer;
     void handleResponse(const boost::system::error_code& err);