Remove duplicate functions

There are many duplicate functions in the sensors,
collapse them into base class.

Change-Id: Ic0e4a1c396c221ea637cea5b8f429a751fc31f99
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/include/ADCSensor.hpp b/include/ADCSensor.hpp
index 59b4450..d7eb933 100644
--- a/include/ADCSensor.hpp
+++ b/include/ADCSensor.hpp
@@ -7,7 +7,6 @@
 class ADCSensor : public Sensor
 {
   public:
-    std::string configuration;
     ADCSensor(const std::string &path,
               sdbusplus::asio::object_server &objectServer,
               std::shared_ptr<sdbusplus::asio::connection> &conn,
@@ -22,14 +21,8 @@
     boost::asio::deadline_timer waitTimer;
     boost::asio::streambuf readBuf;
     int errCount;
-    double maxValue;
-    double minValue;
     double scaleFactor;
     void setupRead(void);
     void handleResponse(const boost::system::error_code &err);
-    void checkThresholds(void);
-    void updateValue(const double &newValue);
-
-    void setInitialProperties(
-        std::shared_ptr<sdbusplus::asio::connection> &conn);
+    void checkThresholds(void) override;
 };
diff --git a/include/CPUSensor.hpp b/include/CPUSensor.hpp
index 41cc02f..4eb2ae0 100644
--- a/include/CPUSensor.hpp
+++ b/include/CPUSensor.hpp
@@ -7,7 +7,6 @@
 class CPUSensor : public Sensor
 {
   public:
-    std::string configuration;
     CPUSensor(const std::string &path, const std::string &objectType,
               sdbusplus::asio::object_server &objectServer,
               std::shared_ptr<sdbusplus::asio::connection> &conn,
@@ -19,20 +18,13 @@
     static constexpr unsigned int sensorPollMs = 1000;
 
   private:
-    std::string objectType;
     sdbusplus::asio::object_server &objServer;
     std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
     boost::asio::posix::stream_descriptor inputDev;
     boost::asio::deadline_timer waitTimer;
     boost::asio::streambuf readBuf;
     int errCount;
-    double maxValue;
-    double minValue;
     void setupRead(void);
     void handleResponse(const boost::system::error_code &err);
-    void checkThresholds(void);
-    void updateValue(const double &newValue);
-
-    void setInitialProperties(
-        std::shared_ptr<sdbusplus::asio::connection> &conn);
+    void checkThresholds(void) override;
 };
diff --git a/include/HwmonTempSensor.hpp b/include/HwmonTempSensor.hpp
index 117f286..3e582ab 100644
--- a/include/HwmonTempSensor.hpp
+++ b/include/HwmonTempSensor.hpp
@@ -7,7 +7,6 @@
 class HwmonTempSensor : public Sensor
 {
   public:
-    std::string configuration;
     HwmonTempSensor(const std::string &path, const std::string &objectType,
                     sdbusplus::asio::object_server &objectServer,
                     std::shared_ptr<sdbusplus::asio::connection> &conn,
@@ -17,19 +16,12 @@
     ~HwmonTempSensor();
 
   private:
-    std::string objectType;
     sdbusplus::asio::object_server &objServer;
     boost::asio::posix::stream_descriptor inputDev;
     boost::asio::deadline_timer waitTimer;
     boost::asio::streambuf readBuf;
     int errCount;
-    double maxValue;
-    double minValue;
     void setupRead(void);
     void handleResponse(const boost::system::error_code &err);
-    void checkThresholds(void);
-    void updateValue(const double &newValue);
-
-    void setInitialProperties(
-        std::shared_ptr<sdbusplus::asio::connection> &conn);
+    void checkThresholds(void) override;
 };
\ No newline at end of file
diff --git a/include/TachSensor.hpp b/include/TachSensor.hpp
index c3d3e58..c9aa80a 100644
--- a/include/TachSensor.hpp
+++ b/include/TachSensor.hpp
@@ -45,8 +45,7 @@
 class TachSensor : public Sensor
 {
   public:
-    std::string configuration;
-    TachSensor(const std::string &path,
+    TachSensor(const std::string &path, const std::string &objectType,
                sdbusplus::asio::object_server &objectServer,
                std::shared_ptr<sdbusplus::asio::connection> &conn,
                std::unique_ptr<PresenceSensor> &&presence,
@@ -65,13 +64,7 @@
     boost::asio::deadline_timer waitTimer;
     boost::asio::streambuf readBuf;
     int errCount;
-    double maxValue;
-    double minValue;
     void setupRead(void);
     void handleResponse(const boost::system::error_code &err);
-    void checkThresholds(void);
-    void updateValue(const double &newValue);
-
-    void setInitialProperties(
-        std::shared_ptr<sdbusplus::asio::connection> &conn);
+    void checkThresholds(void) override;
 };
diff --git a/include/sensor.hpp b/include/sensor.hpp
index 62eec62..f333e6a 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -6,15 +6,23 @@
 constexpr size_t sensorFailedPollTimeMs = 5000;
 struct Sensor
 {
-    Sensor(const std::string& name, const std::string& path,
-           std::vector<thresholds::Threshold>&& thresholdData) :
+    Sensor(const std::string &name, const std::string &path,
+           std::vector<thresholds::Threshold> &&thresholdData,
+           const std::string &configurationPath, const std::string &objectType,
+           const double max, const double min) :
         name(name),
-        path(path), thresholds(std::move(thresholdData))
+        path(path), thresholds(std::move(thresholdData)),
+        configurationPath(configurationPath), maxValue(max), minValue(min)
     {
     }
     virtual ~Sensor() = default;
+    virtual void checkThresholds(void) = 0;
     std::string name;
     std::string path;
+    std::string configurationPath;
+    std::string objectType;
+    double maxValue;
+    double minValue;
     std::vector<thresholds::Threshold> thresholds;
     std::shared_ptr<sdbusplus::asio::dbus_interface> sensorInterface;
     std::shared_ptr<sdbusplus::asio::dbus_interface> thresholdInterfaceWarning;
@@ -22,7 +30,8 @@
     double value = std::numeric_limits<double>::quiet_NaN();
     double overriddenValue = std::numeric_limits<double>::quiet_NaN();
     bool internalSet = false;
-    int setSensorValue(const double& newValue, double& oldValue)
+
+    int setSensorValue(const double &newValue, double &oldValue)
     {
         if (internalSet)
         {
@@ -33,4 +42,96 @@
         overriddenValue = newValue;
         return 1;
     }
+
+    void
+        setInitialProperties(std::shared_ptr<sdbusplus::asio::connection> &conn)
+    {
+        sensorInterface->register_property("MaxValue", maxValue);
+        sensorInterface->register_property("MinValue", minValue);
+        sensorInterface->register_property(
+            "Value", value, [&](const double &newValue, double &oldValue) {
+                return setSensorValue(newValue, oldValue);
+            });
+
+        for (auto &threshold : thresholds)
+        {
+            std::shared_ptr<sdbusplus::asio::dbus_interface> iface;
+            std::string level;
+            std::string alarm;
+            if (threshold.level == thresholds::Level::CRITICAL)
+            {
+                iface = thresholdInterfaceCritical;
+                if (threshold.direction == thresholds::Direction::HIGH)
+                {
+                    level = "CriticalHigh";
+                    alarm = "CriticalAlarmHigh";
+                }
+                else
+                {
+                    level = "CriticalLow";
+                    alarm = "CriticalAlarmLow";
+                }
+            }
+            else if (threshold.level == thresholds::Level::WARNING)
+            {
+                iface = thresholdInterfaceWarning;
+                if (threshold.direction == thresholds::Direction::HIGH)
+                {
+                    level = "WarningHigh";
+                    alarm = "WarningAlarmHigh";
+                }
+                else
+                {
+                    level = "WarningLow";
+                    alarm = "WarningAlarmLow";
+                }
+            }
+            else
+            {
+                std::cerr << "Unknown threshold level" << threshold.level
+                          << "\n";
+                continue;
+            }
+            if (!iface)
+            {
+                std::cout << "trying to set uninitialized interface\n";
+                continue;
+            }
+            iface->register_property(
+                level, threshold.value,
+                [&](const double &request, double &oldValue) {
+                    oldValue = request; // todo, just let the config do this?
+                    threshold.value = request;
+                    thresholds::persistThreshold(configurationPath, objectType,
+                                                 threshold, conn);
+                    return 1;
+                });
+            iface->register_property(alarm, false);
+        }
+        if (!sensorInterface->initialize())
+        {
+            std::cerr << "error initializing value interface\n";
+        }
+        if (thresholdInterfaceWarning &&
+            !thresholdInterfaceWarning->initialize())
+        {
+            std::cerr << "error initializing warning threshold interface\n";
+        }
+
+        if (thresholdInterfaceCritical &&
+            !thresholdInterfaceCritical->initialize())
+        {
+            std::cerr << "error initializing critical threshold interface\n";
+        }
+    }
+
+    void updateValue(const double &newValue)
+    {
+        // Indicate that it is internal set call
+        internalSet = true;
+        sensorInterface->set_property("Value", newValue);
+        internalSet = false;
+        value = newValue;
+        checkThresholds();
+    }
 };
\ No newline at end of file
diff --git a/src/ADCSensor.cpp b/src/ADCSensor.cpp
index 7015d4c..63cc5dd 100644
--- a/src/ADCSensor.cpp
+++ b/src/ADCSensor.cpp
@@ -33,6 +33,8 @@
 static constexpr unsigned int sensorScaleFactor = 1000;
 
 static constexpr double roundFactor = 10000; // 3 decimal places
+static constexpr double maxReading = 20;
+static constexpr double minReading = 0;
 
 ADCSensor::ADCSensor(const std::string &path,
                      sdbusplus::asio::object_server &objectServer,
@@ -42,12 +44,10 @@
                      const double scaleFactor,
                      const std::string &sensorConfiguration) :
     Sensor(boost::replace_all_copy(sensorName, " ", "_"), path,
-           std::move(_thresholds)),
-    objServer(objectServer), configuration(sensorConfiguration),
-    scaleFactor(scaleFactor), inputDev(io, open(path.c_str(), O_RDONLY)),
-    waitTimer(io), errCount(0),
-    // todo, get these from config
-    maxValue(20), minValue(0)
+           std::move(_thresholds), sensorConfiguration,
+           "xyz.openbmc_project.Configuration.ADC", maxReading, minReading),
+    objServer(objectServer), scaleFactor(scaleFactor),
+    inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), errCount(0)
 {
     sensorInterface = objectServer.add_interface(
         "/xyz/openbmc_project/sensors/voltage/" + name,
@@ -162,95 +162,3 @@
 {
     thresholds::checkThresholds(this);
 }
-
-void ADCSensor::updateValue(const double &newValue)
-{
-    // Indicate that it is internal set call
-    internalSet = true;
-    bool ret = sensorInterface->set_property("Value", newValue);
-    internalSet = false;
-    value = newValue;
-    checkThresholds();
-}
-
-void ADCSensor::setInitialProperties(
-    std::shared_ptr<sdbusplus::asio::connection> &conn)
-{
-    // todo, get max and min from configuration
-    sensorInterface->register_property("MaxValue", maxValue);
-    sensorInterface->register_property("MinValue", minValue);
-    sensorInterface->register_property(
-        "Value", value, [&](const double &newValue, double &oldValue) {
-            return setSensorValue(newValue, oldValue);
-        });
-
-    for (auto &threshold : thresholds)
-    {
-        std::shared_ptr<sdbusplus::asio::dbus_interface> iface;
-        std::string level;
-        std::string alarm;
-        if (threshold.level == thresholds::Level::CRITICAL)
-        {
-            iface = thresholdInterfaceCritical;
-            if (threshold.direction == thresholds::Direction::HIGH)
-            {
-                level = "CriticalHigh";
-                alarm = "CriticalAlarmHigh";
-            }
-            else
-            {
-                level = "CriticalLow";
-                alarm = "CriticalAlarmLow";
-            }
-        }
-        else if (threshold.level == thresholds::Level::WARNING)
-        {
-            iface = thresholdInterfaceWarning;
-            if (threshold.direction == thresholds::Direction::HIGH)
-            {
-                level = "WarningHigh";
-                alarm = "WarningAlarmHigh";
-            }
-            else
-            {
-                level = "WarningLow";
-                alarm = "WarningAlarmLow";
-            }
-        }
-        else
-        {
-            std::cerr << "Unknown threshold level" << threshold.level << "\n";
-            continue;
-        }
-        if (!iface)
-        {
-            std::cout << "trying to set uninitialized interface\n";
-            continue;
-        }
-
-        iface->register_property(
-            level, std::round(threshold.value * roundFactor) / roundFactor,
-            [&](const double &request, double &oldValue) {
-                oldValue = request; // todo, just let the config do this?
-                threshold.value = request;
-                thresholds::persistThreshold(
-                    configuration, "xyz.openbmc_project.Configuration.ADC",
-                    threshold, conn);
-                return 1;
-            });
-        iface->register_property(alarm, false);
-    }
-    if (!sensorInterface->initialize())
-    {
-        std::cerr << "error initializing value interface\n";
-    }
-    if (thresholdInterfaceWarning && !thresholdInterfaceWarning->initialize())
-    {
-        std::cerr << "error initializing warning threshold interface\n";
-    }
-
-    if (thresholdInterfaceCritical && !thresholdInterfaceCritical->initialize())
-    {
-        std::cerr << "error initializing critical threshold interface\n";
-    }
-}
diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
index 24e30c8..aebaa4c 100644
--- a/src/CPUSensor.cpp
+++ b/src/CPUSensor.cpp
@@ -28,6 +28,8 @@
 #include <string>
 
 static constexpr size_t warnAfterErrorCount = 10;
+static constexpr double maxReading = 127;
+static constexpr double minReading = -128;
 
 CPUSensor::CPUSensor(const std::string &path, const std::string &objectType,
                      sdbusplus::asio::object_server &objectServer,
@@ -36,13 +38,11 @@
                      std::vector<thresholds::Threshold> &&_thresholds,
                      const std::string &sensorConfiguration) :
     Sensor(boost::replace_all_copy(sensorName, " ", "_"), path,
-           std::move(_thresholds)),
-    objectType(objectType), objServer(objectServer), dbusConnection(conn),
-    configuration(sensorConfiguration),
+           std::move(_thresholds), sensorConfiguration, objectType, maxReading,
+           minReading),
+    objServer(objectServer), dbusConnection(conn),
+    inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), errCount(0)
 
-    inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), errCount(0),
-    // todo, get these from config
-    maxValue(127), minValue(-128)
 {
     sensorInterface = objectServer.add_interface(
         "/xyz/openbmc_project/sensors/temperature/" + name,
@@ -163,100 +163,3 @@
 {
     thresholds::checkThresholds(this);
 }
-
-void CPUSensor::updateValue(const double &newValue)
-{
-    // Indicate that it is internal set call
-    internalSet = true;
-    sensorInterface->set_property("Value", newValue);
-    internalSet = false;
-    value = newValue;
-    checkThresholds();
-}
-
-void CPUSensor::setInitialProperties(
-    std::shared_ptr<sdbusplus::asio::connection> &conn)
-{
-    // todo, get max and min from configuration
-    sensorInterface->register_property("MaxValue", maxValue);
-    sensorInterface->register_property("MinValue", minValue);
-    sensorInterface->register_property(
-        "Value", value, [&](const double &newValue, double &oldValue) {
-            return setSensorValue(newValue, oldValue);
-        });
-
-    for (auto &threshold : thresholds)
-    {
-        std::shared_ptr<sdbusplus::asio::dbus_interface> iface;
-        std::string level;
-        std::string alarm;
-        if (threshold.level == thresholds::Level::CRITICAL)
-        {
-            iface = thresholdInterfaceCritical;
-            if (threshold.direction == thresholds::Direction::HIGH)
-            {
-                level = "CriticalHigh";
-                alarm = "CriticalAlarmHigh";
-            }
-            else
-            {
-                level = "CriticalLow";
-                alarm = "CriticalAlarmLow";
-            }
-        }
-        else if (threshold.level == thresholds::Level::WARNING)
-        {
-            iface = thresholdInterfaceWarning;
-            if (threshold.direction == thresholds::Direction::HIGH)
-            {
-                level = "WarningHigh";
-                alarm = "WarningAlarmHigh";
-            }
-            else
-            {
-                level = "WarningLow";
-                alarm = "WarningAlarmLow";
-            }
-        }
-        else
-        {
-            std::cerr << "Unknown threshold level" << threshold.level << "\n";
-            continue;
-        }
-        if (!iface)
-        {
-            std::cout << "trying to set uninitialized interface\n";
-            continue;
-        }
-        if (threshold.writeable)
-        {
-            iface->register_property(
-                level, threshold.value,
-                [&](const double &request, double &oldValue) {
-                    oldValue = request; // todo, just let the config do this?
-                    threshold.value = request;
-                    thresholds::persistThreshold(configuration, objectType,
-                                                 threshold, conn);
-                    return 1;
-                });
-        }
-        else
-        {
-            iface->register_property(level, threshold.value);
-        }
-        iface->register_property(alarm, false);
-    }
-    if (!sensorInterface->initialize())
-    {
-        std::cerr << "error initializing value interface\n";
-    }
-    if (thresholdInterfaceWarning && !thresholdInterfaceWarning->initialize())
-    {
-        std::cerr << "error initializing warning threshold interface\n";
-    }
-
-    if (thresholdInterfaceCritical && !thresholdInterfaceCritical->initialize())
-    {
-        std::cerr << "error initializing critical threshold interface\n";
-    }
-}
diff --git a/src/FanMain.cpp b/src/FanMain.cpp
index ea03ba7..365fd90 100644
--- a/src/FanMain.cpp
+++ b/src/FanMain.cpp
@@ -264,7 +264,7 @@
         }
 
         tachSensors[sensorName] = std::make_unique<TachSensor>(
-            path.string(), objectServer, dbusConnection,
+            path.string(), baseType, objectServer, dbusConnection,
             std::move(presenceSensor), redundancy, io, sensorName,
             std::move(sensorThresholds), *interfacePath);
     }
diff --git a/src/HwmonTempSensor.cpp b/src/HwmonTempSensor.cpp
index 48e3fa6..8966957 100644
--- a/src/HwmonTempSensor.cpp
+++ b/src/HwmonTempSensor.cpp
@@ -30,6 +30,9 @@
 static constexpr unsigned int sensorScaleFactor = 1000;
 static constexpr size_t warnAfterErrorCount = 10;
 
+static constexpr double maxReading = 127;
+static constexpr double minReading = -128;
+
 HwmonTempSensor::HwmonTempSensor(
     const std::string &path, const std::string &objectType,
     sdbusplus::asio::object_server &objectServer,
@@ -38,12 +41,10 @@
     std::vector<thresholds::Threshold> &&_thresholds,
     const std::string &sensorConfiguration) :
     Sensor(boost::replace_all_copy(sensorName, " ", "_"), path,
-           std::move(_thresholds)),
-    objectType(objectType), configuration(sensorConfiguration),
+           std::move(_thresholds), sensorConfiguration, objectType, maxReading,
+           minReading),
     objServer(objectServer), inputDev(io, open(path.c_str(), O_RDONLY)),
-    waitTimer(io), errCount(0),
-    // todo, get these from config
-    maxValue(127), minValue(-128)
+    waitTimer(io), errCount(0)
 {
     sensorInterface = objectServer.add_interface(
         "/xyz/openbmc_project/sensors/temperature/" + name,
@@ -150,94 +151,4 @@
 void HwmonTempSensor::checkThresholds(void)
 {
     thresholds::checkThresholds(this);
-}
-
-void HwmonTempSensor::updateValue(const double &newValue)
-{
-    // Indicate that it is internal set call
-    internalSet = true;
-    sensorInterface->set_property("Value", newValue);
-    internalSet = false;
-    value = newValue;
-    checkThresholds();
-}
-
-void HwmonTempSensor::setInitialProperties(
-    std::shared_ptr<sdbusplus::asio::connection> &conn)
-{
-    // todo, get max and min from configuration
-    sensorInterface->register_property("MaxValue", maxValue);
-    sensorInterface->register_property("MinValue", minValue);
-    sensorInterface->register_property(
-        "Value", value, [&](const double &newValue, double &oldValue) {
-            return setSensorValue(newValue, oldValue);
-        });
-
-    for (auto &threshold : thresholds)
-    {
-        std::shared_ptr<sdbusplus::asio::dbus_interface> iface;
-        std::string level;
-        std::string alarm;
-        if (threshold.level == thresholds::Level::CRITICAL)
-        {
-            iface = thresholdInterfaceCritical;
-            if (threshold.direction == thresholds::Direction::HIGH)
-            {
-                level = "CriticalHigh";
-                alarm = "CriticalAlarmHigh";
-            }
-            else
-            {
-                level = "CriticalLow";
-                alarm = "CriticalAlarmLow";
-            }
-        }
-        else if (threshold.level == thresholds::Level::WARNING)
-        {
-            iface = thresholdInterfaceWarning;
-            if (threshold.direction == thresholds::Direction::HIGH)
-            {
-                level = "WarningHigh";
-                alarm = "WarningAlarmHigh";
-            }
-            else
-            {
-                level = "WarningLow";
-                alarm = "WarningAlarmLow";
-            }
-        }
-        else
-        {
-            std::cerr << "Unknown threshold level" << threshold.level << "\n";
-            continue;
-        }
-        if (!iface)
-        {
-            std::cout << "trying to set uninitialized interface\n";
-            continue;
-        }
-        iface->register_property(
-            level, threshold.value,
-            [&](const double &request, double &oldValue) {
-                oldValue = request; // todo, just let the config do this?
-                threshold.value = request;
-                thresholds::persistThreshold(configuration, objectType,
-                                             threshold, conn);
-                return 1;
-            });
-        iface->register_property(alarm, false);
-    }
-    if (!sensorInterface->initialize())
-    {
-        std::cerr << "error initializing value interface\n";
-    }
-    if (thresholdInterfaceWarning && !thresholdInterfaceWarning->initialize())
-    {
-        std::cerr << "error initializing warning threshold interface\n";
-    }
-
-    if (thresholdInterfaceCritical && !thresholdInterfaceCritical->initialize())
-    {
-        std::cerr << "error initializing critical threshold interface\n";
-    }
-}
+}
\ No newline at end of file
diff --git a/src/TachSensor.cpp b/src/TachSensor.cpp
index d125d0b..63ced19 100644
--- a/src/TachSensor.cpp
+++ b/src/TachSensor.cpp
@@ -31,7 +31,10 @@
 static constexpr unsigned int pwmPollMs = 500;
 static constexpr size_t warnAfterErrorCount = 10;
 
-TachSensor::TachSensor(const std::string &path,
+static constexpr double maxReading = 25000;
+static constexpr double minReading = 0;
+
+TachSensor::TachSensor(const std::string &path, const std::string &objectType,
                        sdbusplus::asio::object_server &objectServer,
                        std::shared_ptr<sdbusplus::asio::connection> &conn,
                        std::unique_ptr<PresenceSensor> &&presence,
@@ -40,13 +43,11 @@
                        std::vector<thresholds::Threshold> &&_thresholds,
                        const std::string &sensorConfiguration) :
     Sensor(boost::replace_all_copy(fanName, " ", "_"), path,
-           std::move(_thresholds)),
+           std::move(_thresholds), sensorConfiguration, objectType, maxReading,
+           minReading),
     objServer(objectServer), dbusConnection(conn),
     presence(std::move(presence)), redundancy(redundancy),
-    configuration(sensorConfiguration),
-    inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), errCount(0),
-    // todo, get these from config
-    maxValue(25000), minValue(0)
+    inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), errCount(0)
 {
     sensorInterface = objectServer.add_interface(
         "/xyz/openbmc_project/sensors/fan_tach/" + name,
@@ -183,98 +184,6 @@
     }
 }
 
-void TachSensor::updateValue(const double &newValue)
-{
-    // Indicate that it is internal set call
-    internalSet = true;
-    sensorInterface->set_property("Value", newValue);
-    internalSet = false;
-    value = newValue;
-    checkThresholds();
-}
-
-void TachSensor::setInitialProperties(
-    std::shared_ptr<sdbusplus::asio::connection> &conn)
-{
-    // todo, get max and min from configuration
-    sensorInterface->register_property("MaxValue", maxValue);
-    sensorInterface->register_property("MinValue", minValue);
-    sensorInterface->register_property(
-        "Value", value, [&](const double &newValue, double &oldValue) {
-            return setSensorValue(newValue, oldValue);
-        });
-
-    for (auto &threshold : thresholds)
-    {
-        std::shared_ptr<sdbusplus::asio::dbus_interface> iface;
-        std::string level;
-        std::string alarm;
-        if (threshold.level == thresholds::Level::CRITICAL)
-        {
-            iface = thresholdInterfaceCritical;
-            if (threshold.direction == thresholds::Direction::HIGH)
-            {
-                level = "CriticalHigh";
-                alarm = "CriticalAlarmHigh";
-            }
-            else
-            {
-                level = "CriticalLow";
-                alarm = "CriticalAlarmLow";
-            }
-        }
-        else if (threshold.level == thresholds::Level::WARNING)
-        {
-            iface = thresholdInterfaceWarning;
-            if (threshold.direction == thresholds::Direction::HIGH)
-            {
-                level = "WarningHigh";
-                alarm = "WarningAlarmHigh";
-            }
-            else
-            {
-                level = "WarningLow";
-                alarm = "WarningAlarmLow";
-            }
-        }
-        else
-        {
-            std::cerr << "Unknown threshold level" << threshold.level << "\n";
-            continue;
-        }
-        if (!iface)
-        {
-            std::cout << "trying to set uninitialized interface\n";
-            continue;
-        }
-        iface->register_property(
-            level, threshold.value,
-            [&](const double &request, double &oldValue) {
-                oldValue = request; // todo, just let the config do this?
-                threshold.value = request;
-                thresholds::persistThreshold(
-                    configuration,
-                    "xyz.openbmc_project.Configuration.AspeedFan", threshold,
-                    conn);
-                return 1;
-            });
-        iface->register_property(alarm, false);
-    }
-    if (!sensorInterface->initialize())
-    {
-        std::cerr << "error initializing value interface\n";
-    }
-    if (thresholdInterfaceWarning && !thresholdInterfaceWarning->initialize())
-    {
-        std::cerr << "error initializing warning threshold interface\n";
-    }
-
-    if (thresholdInterfaceCritical && !thresholdInterfaceCritical->initialize())
-    {
-        std::cerr << "error initializing critical threshold interface\n";
-    }
-}
-
 PresenceSensor::PresenceSensor(const size_t index, bool inverted,
                                boost::asio::io_service &io) :
     inverted(inverted),