monitor: Use only init mode when using JSON

Fan monitor is currently split into 2 modes - 'init' which is used
right after a power on, and 'monitor', which is used later after the
fans-ready target is started.  Normally, the 'init' mode just sets the
fans to functional and then exits, and the real monitoring work is done
in the 'monitor' mode.

In the future this application will need to be able to check for fan
problems as soon as it starts up after power on so that it can handle
shutting down due to missing fans.  To prepare for this, move all
functionality into the init mode, and just exit immediately when called
to run in the monitor mode.  Only do this when compiled to use the JSON
configuration, as this is new and I don't want to change how the
existing YAML setups work.

This also creates a new 'monitor_start_delay' entry in the JSON to say
how long to wait after startup before actually doing any sensor
monitoring, which then gives the same behavior as how the monitor mode
would delay by waiting for the fan control ready target, which itself is
started by fan control --init after a hardcoded delay.  This field is
optional to preserve backwards compatibility and defaults to 0s.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I623a233f50233e734f50cd9e80139c60467518d8
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 01baada..5e85ba7 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -83,8 +83,10 @@
     setFunctional(true);
 
     // Load in current Target and Input values when entering monitor mode
+#ifndef MONITOR_USE_JSON
     if (mode != Mode::init)
     {
+#endif
         try
         {
             // Use getProperty directly to allow a missing sensor object
@@ -122,7 +124,9 @@
                 _bus, match.c_str(),
                 [this](auto& msg) { this->handleTargetChange(msg); });
         }
+#ifndef MONITOR_USE_JSON
     }
+#endif
 }
 
 std::string TachSensor::getMatchString(const std::string& interface)