blob: bdd99b30e00c28654d009f95c2d953335b34d8b9 [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 Barth3174e722020-09-15 15:13:40 -050018#include "json/event.hpp"
Matthew Barthfcfa0522020-08-24 16:40:24 -050019#include "json/fan.hpp"
Matthew Barthdfd4a052020-09-02 16:31:51 -050020#include "json/group.hpp"
Matthew Bartha227a162020-08-05 10:51:45 -050021#include "json/manager.hpp"
Matthew Barth2331d182020-08-18 15:00:27 -050022#include "json/profile.hpp"
Matthew Barth4f0d3b72020-08-27 14:32:15 -050023#include "json/zone.hpp"
Matthew Barth23ac24c2020-08-04 13:55:43 -050024#include "types.hpp"
25
26#include <sdbusplus/bus.hpp>
27
Matthew Barth413e4d02020-09-29 10:44:37 -050028#include <algorithm>
29#include <cstdlib>
Matthew Bartha3a8cc52021-01-15 12:40:25 -060030#include <string>
Matthew Barth413e4d02020-09-29 10:44:37 -050031#include <tuple>
32#include <vector>
33
Matthew Barthd87f89f2020-07-30 10:41:32 -050034namespace phosphor::fan::control
Matthew Barth23ac24c2020-08-04 13:55:43 -050035{
36
Matthew Barth413e4d02020-09-29 10:44:37 -050037bool checkEntry(const std::vector<std::string>& activeProfiles,
38 const std::vector<std::string>& entryProfiles)
39{
40 // Include entry if its list of profiles to be included in is empty
41 if (entryProfiles.empty())
42 {
43 // Entry always to be included
44 return true;
45 }
46 else
47 {
48 for (const auto& profile : activeProfiles)
49 {
50 auto iter =
51 std::find(entryProfiles.begin(), entryProfiles.end(), profile);
52 if (iter != entryProfiles.end())
53 {
54 // Entry configured to be included in active profile
55 return true;
56 }
57 }
58 }
59 return false;
60}
61
Matthew Barth06764942021-03-04 09:28:40 -060062const unsigned int getPowerOnDelay(sdbusplus::bus::bus& bus,
63 const sdeventplus::Event& event)
Matthew Barth2dc5aba2020-08-04 14:23:34 -050064{
Matthew Barth06764942021-03-04 09:28:40 -060065 json::Manager mgr{bus, event};
Matthew Bartha227a162020-08-05 10:51:45 -050066 return mgr.getPowerOnDelay();
Matthew Barth2dc5aba2020-08-04 14:23:34 -050067}
68
Matthew Barth23ac24c2020-08-04 13:55:43 -050069} // namespace phosphor::fan::control