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/include/ADCSensor.hpp b/include/ADCSensor.hpp
index d7eb933..2b5cdd4 100644
--- a/include/ADCSensor.hpp
+++ b/include/ADCSensor.hpp
@@ -4,6 +4,11 @@
 #include <sdbusplus/asio/object_server.hpp>
 #include <sensor.hpp>
 
+enum class PowerState : bool
+{
+    on,
+    always
+};
 class ADCSensor : public Sensor
 {
   public:
@@ -12,7 +17,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, const std::string &sensorConfiguration);
+              const double scaleFactor, PowerState readState,
+              const std::string &sensorConfiguration);
     ~ADCSensor();
 
   private:
@@ -22,6 +28,7 @@
     boost::asio::streambuf readBuf;
     int errCount;
     double scaleFactor;
+    PowerState readState;
     void setupRead(void);
     void handleResponse(const boost::system::error_code &err);
     void checkThresholds(void) override;