blob: b003531e52dd1a2b42180130cd40a1487746df99 [file] [log] [blame]
Matthew Barth93341e02021-04-14 13:56:28 -05001/**
2 * Copyright © 2021 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
18#include "../manager.hpp"
19#include "action.hpp"
Matthew Barth54b5a242021-05-21 11:02:52 -050020#include "trigger_aliases.hpp"
Matthew Barth93341e02021-04-14 13:56:28 -050021
22#include <nlohmann/json.hpp>
23
24#include <chrono>
25
26namespace phosphor::fan::control::json::trigger::timer
27{
28
29using json = nlohmann::json;
30
31/**
32 * @brief Parse and return the timer trigger's type
33 *
34 * @param[in] jsonObj - JSON object for the timer trigger
35 *
36 * Gets the type of this timer
37 */
38TimerType getType(const json& jsonObj);
39
40/**
41 * @brief Parse and return the timer's interval
42 *
43 * @param[in] jsonObj - JSON object for the timer trigger
44 *
45 * Gets the interval of this timer
46 */
47std::chrono::microseconds getInterval(const json& jsonObj);
48
49/**
50 * @brief Trigger to run an event based on a timer
51 *
52 * @param[in] jsonObj - JSON object for the trigger
53 * @param[in] eventName - Name of event creating the trigger
Matthew Barth93341e02021-04-14 13:56:28 -050054 * @param[in] actions - Actions associated with the trigger
55 *
56 * When fan control starts (or restarts), all events with 'timer' triggers
57 * have their timers started. Once the timer expires, per its configuration,
58 * the corresponding event's actions are run.
59 */
Matthew Barth54b5a242021-05-21 11:02:52 -050060enableTrigger triggerTimer(const json& jsonObj, const std::string& eventName,
Matthew Barth54b5a242021-05-21 11:02:52 -050061 std::vector<std::unique_ptr<ActionBase>>& actions);
Matthew Barth93341e02021-04-14 13:56:28 -050062
63} // namespace phosphor::fan::control::json::trigger::timer