Update physical LEDs as part of Lamp test

- Add the getSubTreePaths method for utils and update all physical
  LEDs.

- Uses GetSubTreePath on Physical LED paths and interfaces and
  updates all the LEDs to ON as part of start or restart of the test.

- When the lamp test is stopped or the timer expires, all the LEDs
  are turned OFF.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I27727db62fe963a1a7c8b391d73801bcaf9efeec
diff --git a/lamptest.cpp b/lamptest.cpp
index 743bf29..04db6fd 100644
--- a/lamptest.cpp
+++ b/lamptest.cpp
@@ -2,6 +2,8 @@
 
 #include "lamptest.hpp"
 
+#include <phosphor-logging/log.hpp>
+
 namespace phosphor
 {
 namespace led
@@ -10,21 +12,50 @@
 void LampTest::stop()
 {
     timer.setEnabled(false);
+
+    // Set all the Physical action to Off
+    for (const auto& path : physicalLEDPaths)
+    {
+        manager.drivePhysicalLED(path, Layout::Action::Off, 0, 0);
+    }
 }
 
 void LampTest::start()
 {
+    // Get paths of all the Physical LED objects
+    physicalLEDPaths = dBusHandler.getSubTreePaths(PHY_LED_PATH, PHY_LED_IFACE);
+
     // restart lamp test, it contains initiate or reset the timer.
     timer.restart(std::chrono::seconds(LAMP_TEST_TIMEOUT_IN_SECS));
+
+    // Set all the Physical action to On for lamp test
+    for (const auto& path : physicalLEDPaths)
+    {
+        manager.drivePhysicalLED(path, Layout::Action::On, 0, 0);
+    }
 }
 
 void LampTest::timeOutHandler()
 {
+    using namespace phosphor::logging;
+
     // set the Asserted property of lamp test to false
+    if (!groupObj)
+    {
+        log<level::ERR>("the Group object is nullptr");
+        throw std::runtime_error("the Group object is nullptr");
+    }
+
+    groupObj->asserted(false);
 }
 
-void LampTest::requestHandler(bool value)
+void LampTest::requestHandler(Group* group, bool value)
 {
+    if (groupObj == NULL)
+    {
+        groupObj = std::move(group);
+    }
+
     if (value)
     {
         start();