Expose power cap min/max on dbus

The min and max power cap values will be read from sysfs files and then
the data will be put on the dbus. This will allow users to know the
valid range of power cap available.

The PowerCap object was moved from Manager to Status.

Change-Id: I5196cc8645f84c31a5282cf844109bae47b09bf7
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
diff --git a/powercap.hpp b/powercap.hpp
index 6dab352..34df45f 100644
--- a/powercap.hpp
+++ b/powercap.hpp
@@ -2,22 +2,25 @@
 
 #include "config.h"
 
-#include "occ_status.hpp"
 #include "utils.hpp"
 
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/bus/match.hpp>
 
 #include <filesystem>
+#include <regex>
 
 namespace open_power
 {
 namespace occ
 {
+class Status;
+
 namespace powercap
 {
 
 namespace sdbusRule = sdbusplus::bus::match::rules;
+namespace fs = std::filesystem;
 
 /** @class PowerCap
  *  @brief Monitors for changes to the power cap and notifies occ
@@ -38,9 +41,7 @@
      *
      * @param[in] occStatus - The occ status object
      */
-    explicit PowerCap(Status& occStatus,
-                      const std::string& occMasterName = OCC_MASTER_NAME) :
-        occMasterName(occMasterName),
+    explicit PowerCap(Status& occStatus) :
         occStatus(occStatus),
         pcapMatch(
             utils::getBus(),
@@ -61,6 +62,9 @@
      */
     uint32_t getOccInput(uint32_t pcap, bool pcapEnabled);
 
+    /** @brief Read the power cap bounds from sysfs and update DBus */
+    void updatePcapBounds();
+
   private:
     /** @brief Callback for pcap setting changes
      *
@@ -95,20 +99,30 @@
      * The file is of the form "powerX_cap_user", where X is any
      * number.
      *
-     * @param[in] path - The directory to look for the file in
+     * @param[in] expr - Regular expression of file to find
      *
-     * @return std::string - The filename, or empty string if not found.
+     * @return full path/filename, or empty path if not found.
      */
-    std::string getPcapFilename(const std::filesystem::path& path);
-
-    /** @brief The master occ name */
-    std::string occMasterName;
+    fs::path getPcapFilename(const std::regex& expr);
 
     /* @brief OCC Status object */
     Status& occStatus;
 
     /** @brief Used to subscribe to dbus pcap property changes **/
     sdbusplus::bus::match_t pcapMatch;
+
+    /** @brief Path to the sysfs files holding the cap properties **/
+    fs::path pcapBasePathname;
+
+    /** @brief Update the power cap bounds on DBus
+     *
+     * @param[in]  softMin - soft minimum power cap in Watts
+     * @param[in]  hardMin - hard minimum power cap in Watts
+     * @param[in]  pcapMax - maximum power cap in Watts
+     *
+     * @return true if all parms were written successfully
+     */
+    bool updateDbusPcap(uint32_t softMin, uint32_t hardMin, uint32_t pcapMax);
 };
 
 } // namespace powercap