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/occ_status.cpp b/occ_status.cpp
index 5abf6dd..ff44c9d 100644
--- a/occ_status.cpp
+++ b/occ_status.cpp
@@ -38,6 +38,17 @@
             // Reset last OCC state
             lastState = 0;
 
+            if (device.master())
+            {
+                if (!pcap)
+                {
+                    // Create the power cap monitor object for master OCC
+                    pcap = std::make_unique<powercap::PowerCap>(*this);
+                }
+                // Update powercap bounds from OCC
+                pcap->updatePcapBounds();
+            }
+
             // Call into Manager to let know that we have bound
             if (this->managerCallBack)
             {
@@ -202,6 +213,13 @@
                 fmt::format("Status::readOccState: OCC{} state 0x{:02X}",
                             instance, state)
                     .c_str());
+            if (state & 0xFFFFFFF8)
+            {
+                log<level::ERR>(
+                    fmt::format("Status::readOccState: INVALID STATE from {}!!",
+                                filename.c_str())
+                        .c_str());
+            }
             lastState = state;
 
 #ifdef POWER10
@@ -372,5 +390,19 @@
 }
 #endif // POWER10
 
+fs::path Status::getHwmonPath() const
+{
+    using namespace std::literals::string_literals;
+
+    // Build the base HWMON path
+    fs::path prefixPath = fs::path{OCC_HWMON_PATH + "occ-hwmon."s +
+                                   std::to_string(instance + 1) + "/hwmon/"s};
+    // Get the hwmonXX directory name, there better only be 1 dir
+    assert(std::distance(fs::directory_iterator(prefixPath),
+                         fs::directory_iterator{}) == 1);
+
+    return *fs::directory_iterator(prefixPath);
+}
+
 } // namespace occ
 } // namespace open_power