George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
| 3 | #include "lamptest.hpp" |
| 4 | |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame^] | 5 | #include <phosphor-logging/log.hpp> |
| 6 | |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 7 | namespace phosphor |
| 8 | { |
| 9 | namespace led |
| 10 | { |
| 11 | |
| 12 | void LampTest::stop() |
| 13 | { |
| 14 | timer.setEnabled(false); |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame^] | 15 | |
| 16 | // Set all the Physical action to Off |
| 17 | for (const auto& path : physicalLEDPaths) |
| 18 | { |
| 19 | manager.drivePhysicalLED(path, Layout::Action::Off, 0, 0); |
| 20 | } |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | void LampTest::start() |
| 24 | { |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame^] | 25 | // Get paths of all the Physical LED objects |
| 26 | physicalLEDPaths = dBusHandler.getSubTreePaths(PHY_LED_PATH, PHY_LED_IFACE); |
| 27 | |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 28 | // restart lamp test, it contains initiate or reset the timer. |
| 29 | timer.restart(std::chrono::seconds(LAMP_TEST_TIMEOUT_IN_SECS)); |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame^] | 30 | |
| 31 | // Set all the Physical action to On for lamp test |
| 32 | for (const auto& path : physicalLEDPaths) |
| 33 | { |
| 34 | manager.drivePhysicalLED(path, Layout::Action::On, 0, 0); |
| 35 | } |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | void LampTest::timeOutHandler() |
| 39 | { |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame^] | 40 | using namespace phosphor::logging; |
| 41 | |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 42 | // set the Asserted property of lamp test to false |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame^] | 43 | if (!groupObj) |
| 44 | { |
| 45 | log<level::ERR>("the Group object is nullptr"); |
| 46 | throw std::runtime_error("the Group object is nullptr"); |
| 47 | } |
| 48 | |
| 49 | groupObj->asserted(false); |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 50 | } |
| 51 | |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame^] | 52 | void LampTest::requestHandler(Group* group, bool value) |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 53 | { |
George Liu | 87fd11c | 2020-11-23 16:40:14 +0800 | [diff] [blame^] | 54 | if (groupObj == NULL) |
| 55 | { |
| 56 | groupObj = std::move(group); |
| 57 | } |
| 58 | |
George Liu | c777bef | 2020-11-23 17:04:21 +0800 | [diff] [blame] | 59 | if (value) |
| 60 | { |
| 61 | start(); |
| 62 | } |
| 63 | else |
| 64 | { |
| 65 | stop(); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | } // namespace led |
| 70 | } // namespace phosphor |