blob: 65773c1f142cff05b34846bc97f2bd261a199394 [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 Bartha227a162020-08-05 10:51:45 -050019#include "json/manager.hpp"
Matthew Barth2331d182020-08-18 15:00:27 -050020#include "json/profile.hpp"
Matthew Barth4f0d3b72020-08-27 14:32:15 -050021#include "json/zone.hpp"
Matthew Barth23ac24c2020-08-04 13:55:43 -050022#include "types.hpp"
23
24#include <sdbusplus/bus.hpp>
25
Matthew Barthd87f89f2020-07-30 10:41:32 -050026namespace phosphor::fan::control
Matthew Barth23ac24c2020-08-04 13:55:43 -050027{
28
29const std::vector<ZoneGroup> getZoneGroups(sdbusplus::bus::bus& bus)
30{
31 std::vector<ZoneGroup> zoneGrps;
32
Matthew Barth2331d182020-08-18 15:00:27 -050033 // Profiles are optional
34 auto profiles = getConfig<json::Profile>(bus, true);
Matthew Barthfcfa0522020-08-24 16:40:24 -050035 // Fans to be controlled
36 auto fans = getConfig<json::Fan>(bus);
Matthew Barth4f0d3b72020-08-27 14:32:15 -050037 // Zones within the system
38 auto zones = getConfig<json::Zone>(bus);
Matthew Barth2331d182020-08-18 15:00:27 -050039
40 // TODO Create zone groups after loading all JSON config files
41
Matthew Barth23ac24c2020-08-04 13:55:43 -050042 return zoneGrps;
43}
44
Matthew Barth2dc5aba2020-08-04 14:23:34 -050045const unsigned int getPowerOnDelay(sdbusplus::bus::bus& bus)
46{
Matthew Bartha227a162020-08-05 10:51:45 -050047 json::Manager mgr{bus};
48 return mgr.getPowerOnDelay();
Matthew Barth2dc5aba2020-08-04 14:23:34 -050049}
50
Matthew Barth23ac24c2020-08-04 13:55:43 -050051} // namespace phosphor::fan::control