Add lampTest class for LED
- Add the framework of the lamp test class.
- For the lamp test path in led group, Initiate lamp test when the
Asserted property is true, Stop the lamp test when the Asserted
property is false or the timer expires.
Tested:
- stat lamp test:
busctl set-property xyz.openbmc_project.LED.GroupManager
/xyz/openbmc_project/led/groups/lamp_test
xyz.openbmc_project.Led.Group Asserted b true
- stop lamp test:
busctl set-property xyz.openbmc_project.LED.GroupManager
/xyz/openbmc_project/led/groups/lamp_test
xyz.openbmc_project.Led.Group Asserted b false
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I7e6fe0ffc4679288ab90050742d2680051e61905
diff --git a/lamptest.cpp b/lamptest.cpp
new file mode 100644
index 0000000..743bf29
--- /dev/null
+++ b/lamptest.cpp
@@ -0,0 +1,39 @@
+#include "config.h"
+
+#include "lamptest.hpp"
+
+namespace phosphor
+{
+namespace led
+{
+
+void LampTest::stop()
+{
+ timer.setEnabled(false);
+}
+
+void LampTest::start()
+{
+ // restart lamp test, it contains initiate or reset the timer.
+ timer.restart(std::chrono::seconds(LAMP_TEST_TIMEOUT_IN_SECS));
+}
+
+void LampTest::timeOutHandler()
+{
+ // set the Asserted property of lamp test to false
+}
+
+void LampTest::requestHandler(bool value)
+{
+ if (value)
+ {
+ start();
+ }
+ else
+ {
+ stop();
+ }
+}
+
+} // namespace led
+} // namespace phosphor