monitor: Support for running with power off

Put in the remaining changes necessary so that fan monitor doesn't need
to be killed when power turns off.

This includes things like:
* Support for starting before the Present property is on D-Bus.
* Support for starting before the config file name is available.
* Stopping any running timers when power is turned off.
* Checking the power off rules when power turns on.

Most, but not all, of the changes are common between the JSON and YAML
modes, but this only truly supported when compiled for JSON.

This also removes the init vs monitor modes of operation, if compiled
for JSON.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ic2c6848f24511c9dc763227e05bbebb4c8c80cd1
diff --git a/monitor/fan.hpp b/monitor/fan.hpp
index 5e3802e..45d1586 100644
--- a/monitor/fan.hpp
+++ b/monitor/fan.hpp
@@ -178,6 +178,13 @@
      */
     void process(TachSensor& sensor);
 
+    /**
+     * @brief The function that runs when the power state changes
+     *
+     * @param[in] powerStateOn - If power is now on or not
+     */
+    void powerStateChanged(bool powerStateOn);
+
   private:
     /**
      * @brief Returns true if the sensor input is not within
@@ -215,6 +222,15 @@
     void presenceChanged(sdbusplus::message::message& msg);
 
     /**
+     * @brief Called when there is an interfacesAdded signal on the
+     *        fan D-Bus path so the code can look for the 'Present'
+     *        property value.
+     *
+     * @param[in] msg - The message from the interfacesAdded signal
+     */
+    void presenceIfaceAdded(sdbusplus::message::message& msg);
+
+    /**
      * @brief the dbus object
      */
     sdbusplus::bus::bus& _bus;
@@ -289,6 +305,12 @@
     sdbusplus::bus::match::match _presenceMatch;
 
     /**
+     * @brief The match object for the interfacesAdded signal
+     *        for the interface that has the Present property.
+     */
+    sdbusplus::bus::match::match _presenceIfaceAddedMatch;
+
+    /**
      * @brief The current presence state
      */
     bool _present = false;