Determine pcap value to send to occ

Change-Id: Ie60aac151f5fd8ce091020ce756834e4877cbc93
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
diff --git a/powercap.cpp b/powercap.cpp
index 2ecad0c..7e8c0db 100644
--- a/powercap.cpp
+++ b/powercap.cpp
@@ -54,6 +54,19 @@
     return mapperResponse.begin()->first;
 }
 
+uint32_t PowerCap::getOccInput(uint32_t pcap, bool pcapEnabled)
+{
+    if (!pcapEnabled)
+    {
+        // Pcap disabled, return 0 to indicate disabled
+        return 0;
+    }
+
+    // If pcap is not disabled then just return the pcap with the derating
+    // factor applied.
+    return( (static_cast<uint64_t>(pcap) * PS_DERATING_FACTOR) /100);
+}
+
 uint32_t PowerCap::getPcap()
 {
     auto settingService = getService(PCAP_PATH,PCAP_INTERFACE);
@@ -144,7 +157,9 @@
                      entry("PCAP_ENABLED=%u",pcapEnabled));
 
     // Determine desired action to write to occ
-    // TODO
+    auto occInput = getOccInput(pcap, pcapEnabled);
+    log<level::DEBUG>("Writing new power cap setting to OCC",
+                     entry("OCC_PCAP_VAL=%u",occInput));
 
     // Write action to occ
     // TODO