1 #pragma once 2 #include <sdbusplus/server.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 using FanDefinition = 39 std::tuple<std::string, std::vector<std::string>, std::string>; 40 41 constexpr auto pathPos = 0; 42 constexpr auto intfPos = 1; 43 constexpr auto propPos = 2; 44 using Group = std::vector<std::tuple<std::string, std::string, std::string>>; 45 using ZoneHandler = std::function<void(Zone&)>; 46 using SignalHandler = std::function<void(sdbusplus::bus::bus&, 47 sdbusplus::message::message&, Zone&)>; 48 using MethodHandler = std::function<void(Zone&, const Group&)>; 49 using Action = std::function<void(Zone&, const Group&)>; 50 using Trigger = std::function<void(Zone&, const std::string&, const Group&, 51 const std::vector<Action>&)>; 52 53 constexpr auto adGroupPos = 0; 54 constexpr auto adActionsPos = 1; 55 using ActionData = std::vector<std::tuple<Group, 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 = 62 std::tuple<std::string, std::string, std::string, PropertyVariantType>; 63 64 constexpr auto namePos = 0; 65 constexpr auto hasOwnerPos = 1; 66 using Service = std::tuple<std::string, bool>; 67 68 constexpr auto intervalPos = 0; 69 constexpr auto typePos = 1; 70 enum class TimerType 71 { 72 oneshot, 73 repeating, 74 }; 75 using TimerConf = std::tuple<std::chrono::microseconds, TimerType>; 76 77 // TODO Remove event group (groupPos) 78 // Bind groups directly to list of actions after optimized code generated 79 constexpr auto sseNamePos = 0; 80 constexpr auto groupPos = 1; 81 constexpr auto actionsPos = 2; 82 constexpr auto triggerPos = 3; 83 using SetSpeedEvent = 84 std::tuple<std::string, Group, ActionData, std::vector<Trigger>>; 85 86 constexpr auto eventGroupPos = 0; 87 constexpr auto eventMatchPos = 1; 88 constexpr auto eventHandlerPos = 2; 89 constexpr auto eventActionsPos = 3; 90 using EventData = 91 std::tuple<Group, std::string, SignalHandler, 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 = 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