Create fan monitor init mode

Allowing fan monitor to run in an init mode will set the fans to a
functional state at each poweron for fans that were non-functional at
poweroff. Then fan monitor can be started in monitor mode after the fans
have ramped up to full speed and can begin being monitored for faults.

This also allows for the removal of fan monitor doing a sd_notify prior
to fan control starting.

Change-Id: I634c9b4ec8bb30860dea54c8abd1cd6c56831d25
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index 6d88d2a..054c67d 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -37,7 +37,8 @@
     "xyz.openbmc_project.State.Decorator.OperationalStatus";
 
 
-Fan::Fan(sdbusplus::bus::bus& bus,
+Fan::Fan(Mode mode,
+         sdbusplus::bus::bus& bus,
          phosphor::fan::event::EventPtr&  events,
          const FanDefinition& def) :
     _bus(bus),
@@ -45,33 +46,36 @@
     _deviation(std::get<fanDeviationField>(def)),
     _numSensorFailsForNonFunc(std::get<numSensorFailsForNonfuncField>(def))
 {
-    auto& sensors = std::get<sensorListField>(def);
-
-    for (auto& s : sensors)
-    {
-        try
-        {
-            _sensors.emplace_back(
-                    std::make_unique<TachSensor>(
-                            bus,
-                            *this,
-                            std::get<sensorNameField>(s),
-                            std::get<hasTargetField>(s),
-                            std::get<timeoutField>(def),
-                            events));
-        }
-        catch (InvalidSensorError& e)
-        {
-
-        }
-    }
-
     //Start from a known state of functional
     updateInventory(true);
 
-    //The TachSensors will now have already read the input
-    //and target values, so check them.
-    tachChanged();
+    // Setup tach sensors for monitoring when in monitor mode
+    if (mode != Mode::init)
+    {
+        auto& sensors = std::get<sensorListField>(def);
+        for (auto& s : sensors)
+        {
+            try
+            {
+                _sensors.emplace_back(
+                        std::make_unique<TachSensor>(
+                                bus,
+                                *this,
+                                std::get<sensorNameField>(s),
+                                std::get<hasTargetField>(s),
+                                std::get<timeoutField>(def),
+                                events));
+            }
+            catch (InvalidSensorError& e)
+            {
+
+            }
+        }
+
+        //The TachSensors will now have already read the input
+        //and target values, so check them.
+        tachChanged();
+    }
 }