blob: 6d617b4006a6fa2576591677c904c0b9cb1efd2e [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 <map>
6#include <set>
Andrew Geisslerd02c3cb2020-05-16 10:28:02 -05007#include <string>
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
52} // namespace led
53} // namespace phosphor