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