Add redundancy sensor and cleanup

Add fan redundancy sensor and move some class members
into the base class. Asio now protects against setting
the same number twice, allow it now to simplify code.

Change-Id: Idb6b5ff4746da92be62c4756fe442d5a5ed23f4f
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/sensors/include/TachSensor.hpp b/sensors/include/TachSensor.hpp
index 2dc6216..36e3eaa 100644
--- a/sensors/include/TachSensor.hpp
+++ b/sensors/include/TachSensor.hpp
@@ -1,6 +1,8 @@
 #pragma once
 
 #include <Thresholds.hpp>
+#include <boost/container/flat_map.hpp>
+#include <boost/container/flat_set.hpp>
 #include <sdbusplus/asio/object_server.hpp>
 #include <sensor.hpp>
 
@@ -23,23 +25,40 @@
     boost::asio::ip::tcp::socket inputDev;
     int fd;
 };
+
+class RedundancySensor
+{
+  public:
+    RedundancySensor(size_t count, const std::vector<std::string> &children,
+                     sdbusplus::asio::object_server &objectServer);
+    ~RedundancySensor();
+
+    void update(const std::string &name, bool failed);
+
+  private:
+    size_t count;
+    std::shared_ptr<sdbusplus::asio::dbus_interface> iface;
+    sdbusplus::asio::object_server &objectServer;
+    boost::container::flat_map<std::string, bool> statuses;
+};
+
 class TachSensor : public Sensor
 {
   public:
-    std::string name;
     std::string configuration;
     TachSensor(const std::string &path,
                sdbusplus::asio::object_server &objectServer,
                std::shared_ptr<sdbusplus::asio::connection> &conn,
                std::unique_ptr<PresenceSensor> &&presence,
+               std::unique_ptr<RedundancySensor> &redundancy,
                boost::asio::io_service &io, const std::string &fanName,
                std::vector<thresholds::Threshold> &&thresholds,
                const std::string &sensorConfiguration);
     ~TachSensor();
 
   private:
-    std::string path;
     sdbusplus::asio::object_server &objServer;
+    std::unique_ptr<RedundancySensor> &redundancy;
     std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
     std::unique_ptr<PresenceSensor> presence;
     boost::asio::posix::stream_descriptor inputDev;