blob: 7fc896d61ef92d3487eb9e6366fc34ee7d984aea [file] [log] [blame]
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05301#pragma once
2
Patrick Williamsed80e882022-03-17 05:03:51 -05003#include <xyz/openbmc_project/Led/Physical/server.hpp>
4
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05305#include <set>
Andrew Geisslerd02c3cb2020-05-16 10:28:02 -05006#include <string>
Patrick Williamsf2044032022-03-17 05:12:30 -05007#include <unordered_map>
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +05308
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05309namespace phosphor
10{
11namespace led
12{
13/** @namespace Layout
14 * @brief Depicts the LED and their mappings and group actions
15 */
16namespace Layout
17{
Patrick Williamsed80e882022-03-17 05:03:51 -050018
19using Action = sdbusplus::xyz::openbmc_project::Led::server::Physical::Action;
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053020
Patrick Venture91ac8d32018-11-01 17:03:22 -070021/** @brief Name of the LED and it's proposed action.
22 * This structure is supplied as configuration at build time
23 */
24struct LedAction
25{
26 std::string name;
27 Action action;
28 uint8_t dutyOn;
29 uint16_t period;
30 Action priority;
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053031
Patrick Venture91ac8d32018-11-01 17:03:22 -070032 // Order LEDs such that same LEDs are grouped next to
33 // each other and the same LEDs are in priority order
34 // with the highest priority coming first
35 bool operator<(const LedAction& right) const
36 {
37 if (name == right.name)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053038 {
Patrick Venture91ac8d32018-11-01 17:03:22 -070039 if (action == right.action)
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053040 {
Patrick Venture91ac8d32018-11-01 17:03:22 -070041 return false;
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053042 }
Patrick Venture91ac8d32018-11-01 17:03:22 -070043 else if (action == priority)
44 {
45 return true;
46 }
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053047 }
Patrick Venture91ac8d32018-11-01 17:03:22 -070048 return name < right.name;
49 }
50};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053051} // namespace Layout
Patrick Williams158b2c12022-03-17 05:57:44 -050052
53using ActionSet = std::set<Layout::LedAction>;
54using GroupMap = std::unordered_map<std::string, ActionSet>;
55
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053056} // namespace led
57} // namespace phosphor