Add getPollRate helper function

This open-coded pattern had been duplicated in a few places; deduplicate
and increase readability by adding a dedicated function.  While we're at
it, also ensure the configured value isn't inf or NaN.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I5f8fe788eb342ca3bf8b52bd6a2e7cc3364f45e1
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index 918b9c6..ab4f6f3 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -489,19 +489,7 @@
             }
         }
 
-        /* The poll rate for the sensors */
-        double pollRate = 0.0;
-        auto pollRateObj = baseConfig->find("PollRate");
-
-        if (pollRateObj != baseConfig->end())
-        {
-            pollRate =
-                std::visit(VariantToDoubleVisitor(), pollRateObj->second);
-            if (pollRate <= 0.0)
-            {
-                pollRate = PSUSensor::defaultSensorPoll;
-            }
-        }
+        float pollRate = getPollRate(*baseConfig, PSUSensor::defaultSensorPoll);
 
         /* Find array of labels to be exposed if it is defined in config */
         std::vector<std::string> findLabels;