blob: b16bfc1a127ffe66b2a1fc6f06399c251ccbc7ec [file] [log] [blame]
Matthew Barthd87f89f2020-07-30 10:41:32 -05001/**
2 * Copyright © 2020 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include "json_parser.hpp"
17
Matthew Barthfcfa0522020-08-24 16:40:24 -050018#include "json/fan.hpp"
Matthew Barthdfd4a052020-09-02 16:31:51 -050019#include "json/group.hpp"
Matthew Bartha227a162020-08-05 10:51:45 -050020#include "json/manager.hpp"
Matthew Barth2331d182020-08-18 15:00:27 -050021#include "json/profile.hpp"
Matthew Barth4f0d3b72020-08-27 14:32:15 -050022#include "json/zone.hpp"
Matthew Barth23ac24c2020-08-04 13:55:43 -050023#include "types.hpp"
24
25#include <sdbusplus/bus.hpp>
26
Matthew Barthd87f89f2020-07-30 10:41:32 -050027namespace phosphor::fan::control
Matthew Barth23ac24c2020-08-04 13:55:43 -050028{
29
30const std::vector<ZoneGroup> getZoneGroups(sdbusplus::bus::bus& bus)
31{
32 std::vector<ZoneGroup> zoneGrps;
33
Matthew Barth2331d182020-08-18 15:00:27 -050034 // Profiles are optional
35 auto profiles = getConfig<json::Profile>(bus, true);
Matthew Barthfcfa0522020-08-24 16:40:24 -050036 // Fans to be controlled
37 auto fans = getConfig<json::Fan>(bus);
Matthew Barth4f0d3b72020-08-27 14:32:15 -050038 // Zones within the system
39 auto zones = getConfig<json::Zone>(bus);
Matthew Barthdfd4a052020-09-02 16:31:51 -050040 // Groups to include in events
41 auto groups = getConfig<json::Group>(bus);
Matthew Barth2331d182020-08-18 15:00:27 -050042
43 // TODO Create zone groups after loading all JSON config files
44
Matthew Barth23ac24c2020-08-04 13:55:43 -050045 return zoneGrps;
46}
47
Matthew Barth2dc5aba2020-08-04 14:23:34 -050048const unsigned int getPowerOnDelay(sdbusplus::bus::bus& bus)
49{
Matthew Bartha227a162020-08-05 10:51:45 -050050 json::Manager mgr{bus};
51 return mgr.getPowerOnDelay();
Matthew Barth2dc5aba2020-08-04 14:23:34 -050052}
53
Matthew Barth23ac24c2020-08-04 13:55:43 -050054} // namespace phosphor::fan::control