1*ed7fb7aeSJayanth Othayoth /**
2*ed7fb7aeSJayanth Othayoth  * Copyright © 2022 IBM Corporation
3*ed7fb7aeSJayanth Othayoth  *
4*ed7fb7aeSJayanth Othayoth  * Licensed under the Apache License, Version 2.0 (the "License");
5*ed7fb7aeSJayanth Othayoth  * you may not use this file except in compliance with the License.
6*ed7fb7aeSJayanth Othayoth  * You may obtain a copy of the License at
7*ed7fb7aeSJayanth Othayoth  *
8*ed7fb7aeSJayanth Othayoth  *     http://www.apache.org/licenses/LICENSE-2.0
9*ed7fb7aeSJayanth Othayoth  *
10*ed7fb7aeSJayanth Othayoth  * Unless required by applicable law or agreed to in writing, software
11*ed7fb7aeSJayanth Othayoth  * distributed under the License is distributed on an "AS IS" BASIS,
12*ed7fb7aeSJayanth Othayoth  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*ed7fb7aeSJayanth Othayoth  * See the License for the specific language governing permissions and
14*ed7fb7aeSJayanth Othayoth  * limitations under the License.
15*ed7fb7aeSJayanth Othayoth  */
16*ed7fb7aeSJayanth Othayoth #pragma once
17*ed7fb7aeSJayanth Othayoth 
18*ed7fb7aeSJayanth Othayoth #include "extensions/phal/create_pel.hpp"
19*ed7fb7aeSJayanth Othayoth 
20*ed7fb7aeSJayanth Othayoth #include <fmt/format.h>
21*ed7fb7aeSJayanth Othayoth 
22*ed7fb7aeSJayanth Othayoth #include <sdeventplus/utility/timer.hpp>
23*ed7fb7aeSJayanth Othayoth 
24*ed7fb7aeSJayanth Othayoth #include <chrono>
25*ed7fb7aeSJayanth Othayoth 
26*ed7fb7aeSJayanth Othayoth namespace openpower::phal::clock
27*ed7fb7aeSJayanth Othayoth {
28*ed7fb7aeSJayanth Othayoth 
29*ed7fb7aeSJayanth Othayoth /* Dbus event timer */
30*ed7fb7aeSJayanth Othayoth using Timer = sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>;
31*ed7fb7aeSJayanth Othayoth 
32*ed7fb7aeSJayanth Othayoth /**
33*ed7fb7aeSJayanth Othayoth  * @class Manager - Represents the clock daily management functions
34*ed7fb7aeSJayanth Othayoth  *
35*ed7fb7aeSJayanth Othayoth  */
36*ed7fb7aeSJayanth Othayoth class Manager
37*ed7fb7aeSJayanth Othayoth {
38*ed7fb7aeSJayanth Othayoth   public:
39*ed7fb7aeSJayanth Othayoth     Manager() = delete;
40*ed7fb7aeSJayanth Othayoth     Manager(const Manager&) = delete;
41*ed7fb7aeSJayanth Othayoth     Manager(Manager&&) = delete;
42*ed7fb7aeSJayanth Othayoth     Manager& operator=(const Manager&) = delete;
43*ed7fb7aeSJayanth Othayoth     Manager& operator=(Manager&&) = delete;
44*ed7fb7aeSJayanth Othayoth     ~Manager() = default;
45*ed7fb7aeSJayanth Othayoth 
46*ed7fb7aeSJayanth Othayoth     /**
47*ed7fb7aeSJayanth Othayoth      * Constructor
48*ed7fb7aeSJayanth Othayoth      * Starts the functions required to capture clock daily logger data.
49*ed7fb7aeSJayanth Othayoth      *
50*ed7fb7aeSJayanth Othayoth      * @param[in] event - sdeventplus event loop
51*ed7fb7aeSJayanth Othayoth      */
52*ed7fb7aeSJayanth Othayoth     Manager(const sdeventplus::Event& event);
53*ed7fb7aeSJayanth Othayoth 
54*ed7fb7aeSJayanth Othayoth     /**
55*ed7fb7aeSJayanth Othayoth      * @brief Add a dbus timer
56*ed7fb7aeSJayanth Othayoth      */
57*ed7fb7aeSJayanth Othayoth     void addTimer();
58*ed7fb7aeSJayanth Othayoth 
59*ed7fb7aeSJayanth Othayoth     /**
60*ed7fb7aeSJayanth Othayoth      * @brief Callback when a timer expires
61*ed7fb7aeSJayanth Othayoth      */
62*ed7fb7aeSJayanth Othayoth     void timerExpired();
63*ed7fb7aeSJayanth Othayoth 
64*ed7fb7aeSJayanth Othayoth     /**
65*ed7fb7aeSJayanth Othayoth      * @brief utility function to create clock data log
66*ed7fb7aeSJayanth Othayoth      */
67*ed7fb7aeSJayanth Othayoth     void createClockDataLog();
68*ed7fb7aeSJayanth Othayoth 
69*ed7fb7aeSJayanth Othayoth   private:
70*ed7fb7aeSJayanth Othayoth     /* The sdeventplus even loop to use */
71*ed7fb7aeSJayanth Othayoth     sdeventplus::Event _event;
72*ed7fb7aeSJayanth Othayoth 
73*ed7fb7aeSJayanth Othayoth     /** @brief Timer used for LEDs lamp test period */
74*ed7fb7aeSJayanth Othayoth     sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> timer;
75*ed7fb7aeSJayanth Othayoth };
76*ed7fb7aeSJayanth Othayoth 
77*ed7fb7aeSJayanth Othayoth } // namespace openpower::phal::clock
78