summaryrefslogtreecommitdiffstats
path: root/pid
diff options
context:
space:
mode:
authorJames Feist <james.feist@linux.intel.com>2019-02-26 11:26:36 -0800
committerPatrick Venture <venture@google.com>2019-02-26 20:37:47 +0000
commitf81f28860b91727b03845381f7afcc5c93274d57 (patch)
treec52db9764cc7cb7d81ddbbab8a252598a61c3883 /pid
parent3484bedaf611a106eeaf418b6cede2c2e42095c8 (diff)
downloadphosphor-pid-control-f81f28860b91727b03845381f7afcc5c93274d57.tar.gz
phosphor-pid-control-f81f28860b91727b03845381f7afcc5c93274d57.zip
Expand conf namespace
Put rest of conf.hpp in the conf namespace. This is largely a sed replace, and wrapping from_json in conf namespace as it failed to build. Change-Id: I9fe5c7b2fface44618c43af2367035afc39bcb64 Signed-off-by: James Feist <james.feist@linux.intel.com>
Diffstat (limited to 'pid')
-rw-r--r--pid/builder.cpp8
-rw-r--r--pid/builder.hpp4
-rw-r--r--pid/buildjson.cpp18
-rw-r--r--pid/buildjson.hpp3
4 files changed, 19 insertions, 14 deletions
diff --git a/pid/builder.cpp b/pid/builder.cpp
index 2faa1cc..1fbfbd4 100644
--- a/pid/builder.cpp
+++ b/pid/builder.cpp
@@ -36,8 +36,8 @@ static std::string getControlPath(int64_t zone)
}
std::unordered_map<int64_t, std::unique_ptr<PIDZone>>
- buildZones(std::map<int64_t, PIDConf>& zonePids,
- std::map<int64_t, struct ZoneConfig>& zoneConfigs,
+ buildZones(std::map<int64_t, conf::PIDConf>& zonePids,
+ std::map<int64_t, struct conf::ZoneConfig>& zoneConfigs,
SensorManager& mgr, sdbusplus::bus::bus& modeControlBus)
{
std::unordered_map<int64_t, std::unique_ptr<PIDZone>> zones;
@@ -60,7 +60,7 @@ std::unordered_map<int64_t, std::unique_ptr<PIDZone>>
throw std::runtime_error(err);
}
- const PIDConf& pidConfig = zi.second;
+ const conf::PIDConf& pidConfig = zi.second;
auto zone = std::make_unique<PIDZone>(
zoneId, zoneConf->second.minThermalOutput,
@@ -74,7 +74,7 @@ std::unordered_map<int64_t, std::unique_ptr<PIDZone>>
{
std::vector<std::string> inputs;
std::string name = pit.first;
- const struct ControllerInfo* info = &pit.second;
+ const struct conf::ControllerInfo* info = &pit.second;
std::cerr << "PID name: " << name << "\n";
diff --git a/pid/builder.hpp b/pid/builder.hpp
index 2b28663..e500503 100644
--- a/pid/builder.hpp
+++ b/pid/builder.hpp
@@ -8,6 +8,6 @@
#include <unordered_map>
std::unordered_map<int64_t, std::unique_ptr<PIDZone>>
- buildZones(std::map<int64_t, PIDConf>& zonePids,
- std::map<int64_t, struct ZoneConfig>& zoneConfigs,
+ buildZones(std::map<int64_t, conf::PIDConf>& zonePids,
+ std::map<int64_t, struct conf::ZoneConfig>& zoneConfigs,
SensorManager& mgr, sdbusplus::bus::bus& modeControlBus);
diff --git a/pid/buildjson.cpp b/pid/buildjson.cpp
index b620439..d31b6bc 100644
--- a/pid/buildjson.cpp
+++ b/pid/buildjson.cpp
@@ -24,7 +24,9 @@
using json = nlohmann::json;
-void from_json(const json& j, ControllerInfo& c)
+namespace conf
+{
+void from_json(const json& j, conf::ControllerInfo& c)
{
j.at("type").get_to(c.type);
j.at("inputs").get_to(c.inputs);
@@ -67,22 +69,24 @@ void from_json(const json& j, ControllerInfo& c)
j.at("negativeHysteresis").get_to(c.pidInfo.negativeHysteresis);
}
}
+} // namespace conf
-std::pair<std::map<int64_t, PIDConf>, std::map<int64_t, struct ZoneConfig>>
+std::pair<std::map<int64_t, conf::PIDConf>,
+ std::map<int64_t, struct conf::ZoneConfig>>
buildPIDsFromJson(const json& data)
{
// zone -> pids
- std::map<int64_t, PIDConf> pidConfig;
+ std::map<int64_t, conf::PIDConf> pidConfig;
// zone -> configs
- std::map<int64_t, struct ZoneConfig> zoneConfig;
+ std::map<int64_t, struct conf::ZoneConfig> zoneConfig;
/* TODO: if zones is empty, that's invalid. */
auto zones = data["zones"];
for (const auto& zone : zones)
{
int64_t id;
- PIDConf thisZone;
- struct ZoneConfig thisZoneConfig;
+ conf::PIDConf thisZone;
+ struct conf::ZoneConfig thisZoneConfig;
/* TODO: using at() throws a specific exception we can catch */
id = zone["id"];
@@ -93,7 +97,7 @@ std::pair<std::map<int64_t, PIDConf>, std::map<int64_t, struct ZoneConfig>>
for (const auto& pid : pids)
{
auto name = pid["name"];
- auto item = pid.get<ControllerInfo>();
+ auto item = pid.get<conf::ControllerInfo>();
thisZone[name] = item;
}
diff --git a/pid/buildjson.hpp b/pid/buildjson.hpp
index 626c982..d4e86a7 100644
--- a/pid/buildjson.hpp
+++ b/pid/buildjson.hpp
@@ -14,5 +14,6 @@ using json = nlohmann::json;
* @param[in] data - the json data
* @return the pidConfig, and the zoneConfig
*/
-std::pair<std::map<int64_t, PIDConf>, std::map<int64_t, struct ZoneConfig>>
+std::pair<std::map<int64_t, conf::PIDConf>,
+ std::map<int64_t, struct conf::ZoneConfig>>
buildPIDsFromJson(const json& data);
OpenPOWER on IntegriCloud