xref: /openbmc/phosphor-fan-presence/control/types.hpp (revision 3e781064f534ae0c822ac4c4f5590635633aa394)
1 #pragma once
2 #include <string>
3 #include <tuple>
4 #include <vector>
5 #include <sdbusplus/server.hpp>
6 #include "timer.hpp"
7 
8 namespace phosphor
9 {
10 namespace fan
11 {
12 namespace control
13 {
14 
15 class Zone;
16 
17 constexpr auto propertyNamePos = 0;
18 constexpr auto propertyInterfacePos = 1;
19 constexpr auto propertyPathPos = 2;
20 constexpr auto propertyValuePos = 3;
21 
22 // TODO openbmc/openbmc#1769: Support more property types.
23 using ConditionProperty = std::tuple<std::string,
24                           std::string,
25                           std::string,
26                           bool>;
27 
28 constexpr auto conditionTypePos = 0;
29 constexpr auto conditionPropertyListPos = 1;
30 using Condition = std::tuple<std::string,
31                              std::vector<ConditionProperty>>;
32 
33 using PropertyVariantType = sdbusplus::message::variant<bool,
34                                                         int64_t,
35                                                         std::string>;
36 
37 constexpr auto fanNamePos = 0;
38 constexpr auto sensorListPos = 1;
39 constexpr auto targetInterfacePos = 2;
40 using FanDefinition = std::tuple<std::string,
41                                  std::vector<std::string>,
42                                  std::string>;
43 
44 constexpr auto intfPos = 0;
45 constexpr auto propPos = 1;
46 using Group = std::map<std::string, std::tuple<std::string, std::string>>;
47 using Handler = std::function<void(sdbusplus::bus::bus&,
48                                    sdbusplus::message::message&,
49                                    Zone&)>;
50 using Action = std::function<void(Zone&, const Group&)>;
51 
52 constexpr auto pcPathPos = 0;
53 constexpr auto pcIntfPos = 1;
54 constexpr auto pcPropPos = 2;
55 constexpr auto pcValuePos = 3;
56 using PrecondGroup = std::tuple<std::string,
57                                 std::string,
58                                 std::string,
59                                 PropertyVariantType>;
60 
61 constexpr auto namePos = 0;
62 constexpr auto hasOwnerPos = 1;
63 using Service = std::tuple<std::string, bool>;
64 
65 constexpr auto intervalPos = 0;
66 constexpr auto typePos = 1;
67 using Timer = std::tuple<std::chrono::seconds,
68                          util::Timer::TimerType>;
69 
70 constexpr auto sigMatchPos = 0;
71 constexpr auto sigHandlerPos = 1;
72 using Signal = std::tuple<std::string, Handler>;
73 
74 constexpr auto groupPos = 0;
75 constexpr auto actionsPos = 1;
76 constexpr auto timerPos = 2;
77 constexpr auto signalsPos = 3;
78 using SetSpeedEvent = std::tuple<Group,
79                                  std::vector<Action>,
80                                  Timer,
81                                  std::vector<Signal>>;
82 
83 constexpr auto eventGroupPos = 0;
84 constexpr auto eventMatchPos = 1;
85 constexpr auto eventHandlerPos = 2;
86 constexpr auto eventActionsPos = 3;
87 using EventData = std::tuple<Group, std::string, Handler, std::vector<Action>>;
88 
89 constexpr auto timerEventDataPos = 0;
90 constexpr auto timerTimerPos = 1;
91 using TimerEvent =
92     std::tuple<std::unique_ptr<EventData>,
93                std::unique_ptr<phosphor::fan::util::Timer>>;
94 
95 constexpr auto signalEventDataPos = 0;
96 constexpr auto signalMatchPos = 1;
97 using SignalEvent =
98     std::tuple<std::unique_ptr<EventData>,
99                std::unique_ptr<sdbusplus::server::match::match>>;
100 
101 constexpr auto zoneNumPos = 0;
102 constexpr auto fullSpeedPos = 1;
103 constexpr auto floorSpeedPos = 2;
104 constexpr auto incDelayPos = 3;
105 constexpr auto decIntervalPos = 4;
106 constexpr auto fanListPos = 5;
107 constexpr auto setSpeedEventsPos = 6;
108 using ZoneDefinition = std::tuple<size_t,
109                                   uint64_t,
110                                   uint64_t,
111                                   size_t,
112                                   size_t,
113                                   std::vector<FanDefinition>,
114                                   std::vector<SetSpeedEvent>>;
115 
116 constexpr auto conditionListPos = 0;
117 constexpr auto zoneListPos = 1;
118 using ZoneGroup = std::tuple<std::vector<Condition>,
119                              std::vector<ZoneDefinition>>;
120 
121 }
122 }
123 }
124