1 #pragma once
2 #include <sdbusplus/bus/match.hpp>
3 #include <sdeventplus/clock.hpp>
4 #include <sdeventplus/utility/timer.hpp>
5 
6 #include <string>
7 #include <tuple>
8 #include <vector>
9 
10 namespace phosphor
11 {
12 namespace fan
13 {
14 namespace control
15 {
16 
17 class Zone;
18 
19 constexpr auto propertyNamePos = 0;
20 constexpr auto propertyInterfacePos = 1;
21 constexpr auto propertyPathPos = 2;
22 constexpr auto propertyValuePos = 3;
23 
24 // TODO openbmc/openbmc#1769: Support more property types.
25 using ConditionProperty =
26     std::tuple<std::string, std::string, std::string, bool>;
27 
28 constexpr auto conditionTypePos = 0;
29 constexpr auto conditionPropertyListPos = 1;
30 using Condition = std::tuple<std::string, std::vector<ConditionProperty>>;
31 
32 using PropertyVariantType =
33     std::variant<bool, int32_t, int64_t, double, std::string>;
34 
35 constexpr auto fanNamePos = 0;
36 constexpr auto sensorListPos = 1;
37 constexpr auto targetInterfacePos = 2;
38 constexpr auto targetControlPathPos = 3;
39 using FanDefinition =
40     std::tuple<std::string, std::vector<std::string>, std::string, std::string>;
41 
42 constexpr auto pathPos = 0;
43 constexpr auto intfPos = 1;
44 constexpr auto propPos = 2;
45 using Group = std::vector<std::tuple<std::string, std::string, std::string>>;
46 using ZoneHandler = std::function<void(Zone&)>;
47 using SignalHandler =
48     std::function<void(sdbusplus::bus_t&, sdbusplus::message_t&, Zone&)>;
49 using MethodHandler = std::function<void(Zone&, const Group&)>;
50 using Action = std::function<void(Zone&, const Group&)>;
51 using Trigger = std::function<void(Zone&, const std::string&, const Group&,
52                                    const std::vector<Action>&)>;
53 
54 constexpr auto adGroupPos = 0;
55 constexpr auto adActionsPos = 1;
56 using ActionData = std::vector<std::tuple<Group, std::vector<Action>>>;
57 
58 constexpr auto pcPathPos = 0;
59 constexpr auto pcIntfPos = 1;
60 constexpr auto pcPropPos = 2;
61 constexpr auto pcValuePos = 3;
62 using PrecondGroup =
63     std::tuple<std::string, std::string, std::string, PropertyVariantType>;
64 
65 constexpr auto namePos = 0;
66 constexpr auto hasOwnerPos = 1;
67 using Service = std::tuple<std::string, bool>;
68 
69 constexpr auto intervalPos = 0;
70 constexpr auto typePos = 1;
71 enum class TimerType
72 {
73     oneshot,
74     repeating,
75 };
76 using TimerConf = std::tuple<std::chrono::microseconds, TimerType>;
77 
78 // TODO Remove event group (groupPos)
79 // Bind groups directly to list of actions after optimized code generated
80 constexpr auto sseNamePos = 0;
81 constexpr auto groupPos = 1;
82 constexpr auto actionsPos = 2;
83 constexpr auto triggerPos = 3;
84 using SetSpeedEvent =
85     std::tuple<std::string, Group, ActionData, 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 =
92     std::tuple<Group, std::string, SignalHandler, std::vector<Action>>;
93 
94 constexpr auto timerEventDataPos = 0;
95 constexpr auto timerTimerPos = 1;
96 using Timer = sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>;
97 using TimerEvent = std::tuple<std::unique_ptr<EventData>, Timer>;
98 
99 constexpr auto signalEventDataPos = 0;
100 constexpr auto signalMatchPos = 1;
101 using SignalEvent = std::tuple<std::unique_ptr<EventData>,
102                                std::unique_ptr<sdbusplus::bus::match_t>>;
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 =
113     std::tuple<size_t, uint64_t, uint64_t, size_t, size_t,
114                std::vector<ZoneHandler>, std::vector<FanDefinition>,
115                std::vector<SetSpeedEvent>>;
116 
117 constexpr auto conditionListPos = 0;
118 constexpr auto zoneListPos = 1;
119 using ZoneGroup =
120     std::tuple<std::vector<Condition>, std::vector<ZoneDefinition>>;
121 
122 } // namespace control
123 } // namespace fan
124 } // namespace phosphor
125