control: Parse optional "manager.json"
Parse the optional "manager.json" configuration file which currently
provides a single optional attribute "power_on_delay". When the
"power_on_delay" attribute is not present, it is defaulted to 0.
An example "manager.json" file:
```
{
"power_on_delay": 20
}
```
Tested:
Power on delay of 0 when no "manager.json" file present
Power on delay of 0 when no "power_on_delay" JSON attribute present
Power on delay set to value given in "power_on_delay"
Change-Id: I5506ad4e853bdea249b9a794ce335261fdfcaa9f
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/manager.hpp b/control/json/manager.hpp
new file mode 100644
index 0000000..30669eb
--- /dev/null
+++ b/control/json/manager.hpp
@@ -0,0 +1,72 @@
+/**
+ * Copyright © 2020 IBM Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <nlohmann/json.hpp>
+#include <sdbusplus/bus.hpp>
+
+namespace phosphor::fan::control::json
+{
+
+using json = nlohmann::json;
+
+/**
+ * @class Manager - Represents the fan control manager's configuration
+ *
+ * A fan control manager configuration is optional, therefore the "manager.json"
+ * file is also optional. The manager configuration is used to populate
+ * fan control's manager parameters which are used in how the application
+ * operates, not in how the fans are controlled.
+ *
+ * When no manager configuration exists, the fan control application starts,
+ * processes any configured events and then begins controlling fans according
+ * to those events.
+ */
+class Manager
+{
+ public:
+ Manager() = delete;
+ Manager(const Manager&) = delete;
+ Manager(Manager&&) = delete;
+ Manager& operator=(const Manager&) = delete;
+ Manager& operator=(Manager&&) = delete;
+ ~Manager() = default;
+
+ /**
+ * Constructor
+ * Parses and populates the fan control manager attributes from a json file
+ *
+ * @param[in] bus - sdbusplus bus object
+ */
+ explicit Manager(sdbusplus::bus::bus& bus);
+
+ /**
+ * @brief Get the configured power on delay(OPTIONAL)
+ *
+ * @return Power on delay in seconds
+ * Configured power on delay in seconds, otherwise 0
+ */
+ unsigned int getPowerOnDelay();
+
+ private:
+ /* JSON file name for manager configuration attributes */
+ static constexpr auto confFileName = "manager.json";
+
+ /* The parsed JSON object */
+ json _jsonObj;
+};
+
+} // namespace phosphor::fan::control::json