Update OperationalStatus interface according to the Present property value

When the Present property value changes, the corresponding OperationalStatus
interface needs to be updated at the same time.
Refer to:
https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/xyz/
openbmc_project/State/Decorator/OperationalStatus.interface.yaml

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I9eee9196125cf82605b20009b49a3ed7f65be53a
diff --git a/phosphor-power-supply/power_supply.cpp b/phosphor-power-supply/power_supply.cpp
index 9735b6d..271009b 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -197,8 +197,10 @@
     std::string header;
     std::string sn;
     using PropertyMap =
-        std::map<std::string, std::variant<std::string, std::vector<uint8_t>>>;
+        std::map<std::string,
+                 std::variant<std::string, std::vector<uint8_t>, bool>>;
     PropertyMap assetProps;
+    PropertyMap operProps;
     PropertyMap versionProps;
     PropertyMap ipzvpdDINFProps;
     PropertyMap ipzvpdVINIProps;
@@ -302,6 +304,10 @@
         interfaces.emplace(DINF_IFACE, std::move(ipzvpdDINFProps));
         interfaces.emplace(VINI_IFACE, std::move(ipzvpdVINIProps));
 
+        // Update the Functional
+        operProps.emplace(FUNCTIONAL_PROP, present);
+        interfaces.emplace(OPERATIONAL_STATE_IFACE, std::move(operProps));
+
         auto path = inventoryPath.substr(strlen(INVENTORY_OBJ_PATH));
         object.emplace(path, std::move(interfaces));
 
diff --git a/power-supply/power_supply.cpp b/power-supply/power_supply.cpp
index 9543afb..195e750 100644
--- a/power-supply/power_supply.cpp
+++ b/power-supply/power_supply.cpp
@@ -611,10 +611,11 @@
     using namespace sdbusplus::message;
 
     // Build the object map and send it to the inventory
-    using Properties = std::map<std::string, std::variant<std::string>>;
+    using Properties = std::map<std::string, std::variant<std::string, bool>>;
     using Interfaces = std::map<std::string, Properties>;
     using Object = std::map<object_path, Interfaces>;
     Properties assetProps;
+    Properties operProps;
     Interfaces interfaces;
     Object object;
 
@@ -642,7 +643,9 @@
         }
     }
 
+    operProps.emplace(FUNCTIONAL_PROP, present);
     interfaces.emplace(ASSET_IFACE, std::move(assetProps));
+    interfaces.emplace(OPERATIONAL_STATE_IFACE, std::move(operProps));
 
     // For Notify(), just send the relative path of the inventory
     // object so remove the INVENTORY_OBJ_PATH prefix
diff --git a/types.hpp b/types.hpp
index df67013..b79bbb9 100644
--- a/types.hpp
+++ b/types.hpp
@@ -10,6 +10,8 @@
 constexpr auto ASSET_IFACE = "xyz.openbmc_project.Inventory.Decorator.Asset";
 constexpr auto PSU_INVENTORY_IFACE =
     "xyz.openbmc_project.Inventory.Item.PowerSupply";
+constexpr auto OPERATIONAL_STATE_IFACE =
+    "xyz.openbmc_project.State.Decorator.OperationalStatus";
 constexpr auto VERSION_IFACE = "xyz.openbmc_project.Software.Version";
 #ifdef IBM_VPD
 constexpr auto DINF_IFACE = "com.ibm.ipzvpd.DINF";
@@ -20,6 +22,7 @@
 constexpr auto MESSAGE_PROP = "Message";
 constexpr auto RESOLVED_PROP = "Resolved";
 constexpr auto PRESENT_PROP = "Present";
+constexpr auto FUNCTIONAL_PROP = "Functional";
 
 constexpr auto INVENTORY_OBJ_PATH = "/xyz/openbmc_project/inventory";
 constexpr auto POWER_OBJ_PATH = "/org/openbmc/control/power0";