Clean up power state handling and fix voltage events

Seperate isPowerOn into two functions, one to set up the
match and one to poll the boolean. This way a dbus connection
object isn't needed in the sensor. Use this new function to
allow the ADCSensor to only signal threshold crosses if the
sensor is in the correct state.

Tested-by: Verified no SEL events for ADC sensors were created
during power cycling.

Change-Id: Ida800ab478b85ac2cb5976fa3471411c5d4bdc88
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
index d54263a..969a449 100644
--- a/src/CPUSensor.cpp
+++ b/src/CPUSensor.cpp
@@ -40,8 +40,8 @@
     Sensor(boost::replace_all_copy(sensorName, " ", "_"), path,
            std::move(_thresholds), sensorConfiguration, objectType, maxReading,
            minReading),
-    objServer(objectServer), dbusConnection(conn),
-    inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), errCount(0)
+    objServer(objectServer), inputDev(io, open(path.c_str(), O_RDONLY)),
+    waitTimer(io), errCount(0)
 
 {
     sensorInterface = objectServer.add_interface(
@@ -60,7 +60,7 @@
             "xyz.openbmc_project.Sensor.Threshold.Critical");
     }
     setInitialProperties(conn);
-    isPowerOn(dbusConnection); // first call initializes
+    setupPowerMatch(conn);
     setupRead();
 }
 
@@ -123,7 +123,7 @@
     if (errCount >= warnAfterErrorCount)
     {
         // only an error if power is on
-        if (isPowerOn(dbusConnection))
+        if (isPowerOn())
         {
             // only print once
             if (errCount == warnAfterErrorCount)