regulators: Implements support for not action
Enhance the configuration file parser to support the not action element.
Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: Ia88eee705a9fae28a816aeb6dff9e0b6f0deba39
diff --git a/phosphor-regulators/src/config_file_parser.cpp b/phosphor-regulators/src/config_file_parser.cpp
index e458ba7..5f0181e 100644
--- a/phosphor-regulators/src/config_file_parser.cpp
+++ b/phosphor-regulators/src/config_file_parser.cpp
@@ -120,9 +120,8 @@
}
else if (element.contains("not"))
{
- // TODO: Not implemented yet
- // action = parseNot(element["not"]);
- // ++propertyCount;
+ action = parseNot(element["not"]);
+ ++propertyCount;
}
else if (element.contains("or"))
{
@@ -576,6 +575,14 @@
return std::make_unique<I2CWriteBytesAction>(reg, values, masks);
}
+std::unique_ptr<NotAction> parseNot(const json& element)
+{
+ // Required action to execute
+ std::unique_ptr<Action> action = parseAction(element);
+
+ return std::make_unique<NotAction>(std::move(action));
+}
+
std::unique_ptr<PMBusWriteVoutCommandAction>
parsePMBusWriteVoutCommand(const json& element)
{
diff --git a/phosphor-regulators/src/config_file_parser.hpp b/phosphor-regulators/src/config_file_parser.hpp
index d81e403..e2476a2 100644
--- a/phosphor-regulators/src/config_file_parser.hpp
+++ b/phosphor-regulators/src/config_file_parser.hpp
@@ -27,6 +27,7 @@
#include "i2c_write_bit_action.hpp"
#include "i2c_write_byte_action.hpp"
#include "i2c_write_bytes_action.hpp"
+#include "not_action.hpp"
#include "pmbus_write_vout_command_action.hpp"
#include "presence_detection.hpp"
#include "rail.hpp"
@@ -440,6 +441,18 @@
}
/**
+ * Parses a JSON element containing a not action.
+ *
+ * Returns the corresponding C++ NotAction object.
+ *
+ * Throws an exception if parsing fails.
+ *
+ * @param element JSON element
+ * @return NotAction object
+ */
+std::unique_ptr<NotAction> parseNot(const nlohmann::json& element);
+
+/**
* Parses a JSON element containing a pmbus_write_vout_command action.
*
* Returns the corresponding C++ PMBusWriteVoutCommandAction object.