lamp test: Add vritual lamp test function
- This feature adds the functionality that enables force updating
certain physical LEDs and skip updating certain physical LEDs as
part of lamp test.
- This is a generic feature that gives more control over handing
physical LEDs.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I6f06ed103b1ceefdaa774b7a74a4a392609000ed
diff --git a/lamptest.hpp b/lamptest.hpp
index 1797dce..d69667a 100644
--- a/lamptest.hpp
+++ b/lamptest.hpp
@@ -1,8 +1,11 @@
#pragma once
+#include "config.h"
+
#include "group.hpp"
#include "manager.hpp"
+#include <nlohmann/json.hpp>
#include <sdeventplus/utility/timer.hpp>
#include <queue>
@@ -37,7 +40,11 @@
LampTest(const sdeventplus::Event& event, Manager& manager) :
timer(event, std::bind(std::mem_fn(&LampTest::timeOutHandler), this)),
manager(manager), groupObj(NULL)
- {}
+ {
+ // Get the force update and/or skipped physical LEDs names from the
+ // lamp-test-led-overrides.json file during lamp
+ getPhysicalLEDNamesFromJson(LAMP_TEST_LED_OVERRIDES_JSON);
+ }
/** @brief the lamp test request handler
*
@@ -86,6 +93,14 @@
/** @brief Physical LED states prior to lamp test */
Manager::group physicalLEDStatesPriorToLampTest;
+ /** @brief Vector of names of physical LEDs, whose changes will be forcibly
+ * updated even during lamp test. */
+ std::vector<std::string> forceUpdateLEDs;
+
+ /** @brief Vector of names of physical LEDs, that will be exempted from lamp
+ * test */
+ std::vector<std::string> skipUpdateLEDs;
+
/** @brief Start and restart lamp test depending on what is the current
* state. */
void start();
@@ -116,6 +131,14 @@
* @param[in] value - the Asserted property value
*/
void doHostLampTest(bool value);
+
+ /** @brief Get physical LED names from lamp test JSON config file
+ *
+ * @param[in] path - path of LED JSON file
+ *
+ * return
+ */
+ void getPhysicalLEDNamesFromJson(const fs::path& path);
};
} // namespace led