control: Construct base zone group from JSON
Pulls together the profiles, zones, and fans JSON configurations to
construct a single zone group to be used as fan control's configuration.
This base zone group includes all that is necessary to get a basic fan
control configuration that will hold fans at the zone's given full
speed. A single zone group is created since the active state of any
configured profiles is checked while creating the zone group.
*Note that "profiles" in JSON configs replace what was called
"Conditions" in YAML based configs.
Tested:
Loaded profile based configurations
Loaded non-profile based configurations
Loaded combination of profile and non-profile based configurations
Change-Id: Id010c899a7633824b80c5cef21c848eadfb66243
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/manager.cpp b/control/manager.cpp
index ff8afef..bdea542 100644
--- a/control/manager.cpp
+++ b/control/manager.cpp
@@ -92,13 +92,21 @@
// Create the appropriate Zone objects based on the
// actual system configuration.
#ifdef CONTROL_USE_JSON
- auto zoneLayouts = getZoneGroups(bus);
+ for (auto& group : getZoneGroups(bus))
+ {
+ // Create a Zone object for each zone in the group
+ for (auto& z : std::get<zoneListPos>(group))
+ {
+ fs::path path{CONTROL_OBJPATH};
+ path /= std::to_string(std::get<zoneNumPos>(z));
+ _zones.emplace(
+ std::get<zoneNumPos>(z),
+ std::make_unique<Zone>(mode, _bus, path.string(), event, z));
+ }
+ }
#else
- auto zoneLayouts = _zoneLayouts;
-#endif
-
// Find the 1 ZoneGroup that meets all of its conditions
- for (auto& group : zoneLayouts)
+ for (auto& group : _zoneLayouts)
{
auto& conditions = std::get<conditionListPos>(group);
@@ -122,6 +130,7 @@
break;
}
}
+#endif
if (mode == Mode::control)
{