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/ADCSensorMain.cpp b/src/ADCSensorMain.cpp
index 05d586f..d174f64 100644
--- a/src/ADCSensorMain.cpp
+++ b/src/ADCSensorMain.cpp
@@ -238,18 +238,8 @@
                 }
             }
 
-            auto findPollRate = baseConfiguration->second.find("PollRate");
-            float pollRate = pollRateDefault;
-            if (findPollRate != baseConfiguration->second.end())
-            {
-                pollRate =
-                    std::visit(VariantToFloatVisitor(), findPollRate->second);
-                if (pollRate <= 0.0F)
-                {
-                    pollRate = pollRateDefault; // polling time too short
-                }
-            }
-
+            float pollRate =
+                getPollRate(baseConfiguration->second, pollRateDefault);
             PowerState readState = getPowerState(baseConfiguration->second);
 
             auto& sensor = sensors[sensorName];