blob: ffce377a00aa882103a44b71f0d71ed8d9d6b2fe [file] [log] [blame]
George Liuc777bef2020-11-23 17:04:21 +08001#pragma once
2
George Liu87fd11c2020-11-23 16:40:14 +08003#include "group.hpp"
George Liuc777bef2020-11-23 17:04:21 +08004#include "manager.hpp"
5
6#include <sdeventplus/utility/timer.hpp>
7
8#include <vector>
9
10namespace phosphor
11{
12namespace led
13{
14
15/** @class LampTest
16 * @brief Manager LampTest feature
17 */
18class LampTest
19{
20 public:
21 LampTest() = delete;
22 ~LampTest() = default;
23 LampTest(const LampTest&) = delete;
24 LampTest& operator=(const LampTest&) = delete;
25 LampTest(LampTest&&) = default;
26 LampTest& operator=(LampTest&&) = default;
27
28 /** @brief Constructs LED LampTest
29 *
30 * Constructs timer and when the timeout occurs, the stop method is called
31 * back to stop timer and also end the lamp test.
32 *
33 * @param[in] event - sd event handler
34 * @param[in] manager - reference to manager instance
35 */
36 LampTest(const sdeventplus::Event& event, Manager& manager) :
37 timer(event, std::bind(std::mem_fn(&LampTest::timeOutHandler), this)),
George Liu87fd11c2020-11-23 16:40:14 +080038 manager(manager), groupObj(NULL)
George Liuc777bef2020-11-23 17:04:21 +080039 {}
40
41 /** @brief the lamp test request handler
42 *
George Liu87fd11c2020-11-23 16:40:14 +080043 * @param[in] group - Pointer to Group object
George Liuc777bef2020-11-23 17:04:21 +080044 * @param[in] value - true: start lamptest
45 * false: stop lamptest
46 * @return
47 */
George Liu87fd11c2020-11-23 16:40:14 +080048 void requestHandler(Group* group, bool value);
George Liuc777bef2020-11-23 17:04:21 +080049
50 private:
51 /** @brief Timer used for LEDs lamp test period */
52 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> timer;
53
54 /** @brief Reference to Manager object */
55 Manager& manager;
56
George Liu87fd11c2020-11-23 16:40:14 +080057 /** DBusHandler class handles the D-Bus operations */
58 DBusHandler dBusHandler;
59
60 /** @brief Pointer to Group object */
61 Group* groupObj;
62
63 /** all the Physical paths */
64 std::vector<std::string> physicalLEDPaths;
65
George Liuc777bef2020-11-23 17:04:21 +080066 /** @brief Start and restart lamp test depending on what is the current
67 * state. */
68 void start();
69
70 /** @brief Stop lamp test. */
71 void stop();
72
73 /** @brief This method gets called when the lamp test procedure is done as
74 * part of timeout. */
75 void timeOutHandler();
76};
77
78} // namespace led
79} // namespace phosphor