blob: 97eb3fe82776a1d8588f6d3dc433545930452660 [file] [log] [blame]
Matt Spinler1962e082020-08-05 13:44:53 -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 "service_indicators.hpp"
17
18#include <phosphor-logging/log.hpp>
19
20namespace openpower::pels::service_indicators
21{
22
23using namespace phosphor::logging;
24
25std::unique_ptr<Policy> getPolicy(const DataInterfaceBase& dataIface)
26{
27 // At the moment there is just one type of policy.
28 return std::make_unique<LightPath>(dataIface);
29}
30
31bool LightPath::ignore(const PEL& pel) const
32{
33 // TODO
34 return false;
35}
36
37void LightPath::activate(const PEL& pel)
38{
39 if (ignore(pel))
40 {
41 return;
42 }
43
44 // Now that we've gotten this far, we'll need to turn on
45 // the system attention indicator if we don't find other
46 // indicators to turn on.
47 bool sai = true;
48 auto src = pel.primarySRC();
49 const auto& calloutsObj = (*src)->callouts();
50
51 if (calloutsObj && !calloutsObj->callouts().empty())
52 {
53 const auto& callouts = calloutsObj->callouts();
54
55 // From the callouts, find the location codes whose
56 // LEDs need to be turned on.
57 auto locCodes = getLocationCodes(callouts);
58 if (!locCodes.empty())
59 {
60 // Find the LED groups for those location codes.
61 auto ledPaths = getLEDGroupPaths(locCodes);
62 if (!ledPaths.empty())
63 {
64 // Tell the LED groups to assert their LEDs.
65 assertLEDs(ledPaths);
66 sai = false;
67 }
68 }
69 }
70
71 if (sai)
72 {
73 log<level::INFO>("The System Attention Indicator needs to be turned "
74 "on, when available");
75 }
76}
77
78std::vector<std::string> LightPath::getLocationCodes(
79 const std::vector<std::unique_ptr<src::Callout>>& callouts) const
80{
81 // TODO
82 return {};
83}
84
85std::vector<std::string> LightPath::getLEDGroupPaths(
86 const std::vector<std::string>& locationCodes) const
87{
88 // TODO
89 return {};
90}
91
92void LightPath::assertLEDs(const std::vector<std::string>& ledGroups) const
93{
94 // TODO
95}
96
97} // namespace openpower::pels::service_indicators