xref: /openbmc/phosphor-led-manager/manager/ledlayout.hpp (revision 7217c0354245f9096adb4301945951e030d322c8)
1 #pragma once
2 
3 #include <map>
4 #include <set>
5 #include <string>
6 
7 namespace phosphor
8 {
9 namespace led
10 {
11 /** @namespace Layout
12  *  @brief Depicts the LED and their mappings and group actions
13  */
14 namespace Layout
15 {
16 /** @brief Define possible actions on a given LED.
17  *  For the BLINK operation, follow 50-50 duty cycle
18  */
19 enum Action
20 {
21     Off,
22     On,
23     Blink,
24 };
25 
26 /** @brief Name of the LED and it's proposed action.
27  *  This structure is supplied as configuration at build time
28  */
29 struct LedAction
30 {
31     std::string name;
32     Action action;
33     uint8_t dutyOn;
34     uint16_t period;
35     Action priority;
36 
37     // Order LEDs such that same LEDs are grouped next to
38     // each other and the same LEDs are in priority order
39     // with the highest priority coming first
40     bool operator<(const LedAction& right) const
41     {
42         if (name == right.name)
43         {
44             if (action == right.action)
45             {
46                 return false;
47             }
48             else if (action == priority)
49             {
50                 return true;
51             }
52         }
53         return name < right.name;
54     }
55 };
56 } // namespace Layout
57 } // namespace led
58 } // namespace phosphor
59