control: Store zone data in the dump

Store the Zone class's attributes in the debug dump.

    "zones": {
        "0": {
            "active": true,
            "decrease_allowed": {},
            "decrease_delta": 0,
            "decrease_interval": 30,
            "default_ceiling": 11200,
            "default_floor": 8000,
            "floor": 8000,
            "floor_change": {},
            "holds": {},
            "increase_delay": 5,
            "increase_delta": 0,
            "persisted_props": {},
            "power_on_target": 11200,
            "requested_target_base": 0,
            "target": 11200
        }
    }

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I9e84f95f892b1cb549b0c988e0f79e8bb5d659c2
diff --git a/control/json/manager.cpp b/control/json/manager.cpp
index 01365e7..42c267b 100644
--- a/control/json/manager.cpp
+++ b/control/json/manager.cpp
@@ -108,6 +108,10 @@
     FlightRecorder::instance().dump(data);
     dumpCache(data);
 
+    std::for_each(_zones.begin(), _zones.end(), [&data](const auto& zone) {
+        data["zones"][zone.second->getName()] = zone.second->dump();
+    });
+
     std::ofstream file{Manager::dumpFile};
     if (!file)
     {
diff --git a/control/json/zone.cpp b/control/json/zone.cpp
index 7966ae1..6701c83 100644
--- a/control/json/zone.cpp
+++ b/control/json/zone.cpp
@@ -360,6 +360,29 @@
     }
 }
 
+json Zone::dump() const
+{
+    json output;
+
+    output["active"] = _isActive;
+    output["floor"] = _floor;
+    output["target"] = _target;
+    output["increase_delta"] = _incDelta;
+    output["decrease_delta"] = _decDelta;
+    output["power_on_target"] = _poweronTarget;
+    output["default_ceiling"] = _defaultCeiling;
+    output["default_floor"] = _defaultFloor;
+    output["increase_delay"] = _incDelay.count();
+    output["decrease_interval"] = _decInterval.count();
+    output["requested_target_base"] = _requestTargetBase;
+    output["floor_change"] = _floorChange;
+    output["decrease_allowed"] = _decAllowed;
+    output["persisted_props"] = _propsPersisted;
+    output["holds"] = _holds;
+
+    return output;
+}
+
 /**
  * Properties of interfaces supported by the zone configuration that return
  * a handler function that sets the zone's property value(s) and persist
diff --git a/control/json/zone.hpp b/control/json/zone.hpp
index ddc17c1..fadfe13 100644
--- a/control/json/zone.hpp
+++ b/control/json/zone.hpp
@@ -377,6 +377,13 @@
         };
     }
 
+    /**
+     * @brief Dump the attributes into JSON
+     *
+     * @return json - JSON object with the attributes
+     */
+    json dump() const;
+
   private:
     /* The zone's associated dbus object */
     std::unique_ptr<DBusZone> _dbusZone;