George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame^] | 3 | #include "group.hpp" |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 4 | #include "manager.hpp" |
| 5 | |
| 6 | #include <sdeventplus/utility/timer.hpp> |
| 7 | |
| 8 | #include <vector> |
| 9 | |
| 10 | namespace phosphor |
| 11 | { |
| 12 | namespace led |
| 13 | { |
| 14 | |
| 15 | /** @class LampTest |
| 16 | * @brief Manager LampTest feature |
| 17 | */ |
| 18 | class 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 Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame^] | 38 | manager(manager), groupObj(NULL) |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 39 | {} |
| 40 | |
| 41 | /** @brief the lamp test request handler |
| 42 | * |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame^] | 43 | * @param[in] group - Pointer to Group object |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 44 | * @param[in] value - true: start lamptest |
| 45 | * false: stop lamptest |
| 46 | * @return |
| 47 | */ |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame^] | 48 | void requestHandler(Group* group, bool value); |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 49 | |
| 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 Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame^] | 57 | /** 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 Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 66 | /** @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 |