openpower-occ-control:failure to read OCC state.

Failure to read OCC state set the OCCs sensors to Nan/Not Functional
Tested: cronus error inject on OCC with and without OCC resets.
Signed-off-by: Sheldon Bailey <baileysh@us.ibm.com>
Change-Id: I2a6bb6a431f09ea816979b3a482b54a28e21db53
Signed-off-by: Sheldon Bailey <baileysh@us.ibm.com>
diff --git a/occ_manager.cpp b/occ_manager.cpp
index a3f246c..eb116e7 100644
--- a/occ_manager.cpp
+++ b/occ_manager.cpp
@@ -162,7 +162,7 @@
         pmode,
 #endif
         std::bind(std::mem_fn(&Manager::statusCallBack), this,
-                  std::placeholders::_1)
+                  std::placeholders::_1, std::placeholders::_2)
 #ifdef PLDM
             ,
         std::bind(std::mem_fn(&pldm::Interface::resetOCC), pldmHandle.get(),
@@ -201,7 +201,7 @@
                                                                   ));
 }
 
-void Manager::statusCallBack(bool status)
+void Manager::statusCallBack(instanceID instance, bool status)
 {
     using InternalFailure =
         sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
@@ -210,7 +210,10 @@
     // here just in case something changes in the future
     if ((activeCount == 0) && (!status))
     {
-        log<level::ERR>("Invalid update on OCCActive");
+        log<level::ERR>(
+            fmt::format("Invalid update on OCCActive with OCC{}", instance)
+                .c_str());
+
         elog<InternalFailure>();
     }
 
@@ -278,15 +281,11 @@
                 waitForAllOccsTimer->setEnabled(false);
             }
 #endif
-
-#ifdef READ_OCC_SENSORS
-            // Clear OCC sensors
-            for (auto& obj : statusObjects)
-            {
-                setSensorValueToNaN(obj->getOccInstanceID());
-            }
-#endif
         }
+#ifdef READ_OCC_SENSORS
+        // Clear OCC sensors
+        setSensorValueToNonFunctional(instance);
+#endif
     }
 }
 
@@ -501,7 +500,7 @@
             // OCC is not running yet
 #ifdef READ_OCC_SENSORS
             auto id = obj->getOccInstanceID();
-            setSensorValueToNaN(id);
+            setSensorValueToNonFunctional(id);
 #endif
             continue;
         }
@@ -842,6 +841,22 @@
     return;
 }
 
+void Manager::setSensorValueToNonFunctional(uint32_t id) const
+{
+    for (const auto& [sensorPath, occId] : existingSensors)
+    {
+        if (occId == id)
+        {
+            dbus::OccDBusSensors::getOccDBus().setValue(
+                sensorPath, std::numeric_limits<double>::quiet_NaN());
+
+            dbus::OccDBusSensors::getOccDBus().setOperationalStatus(sensorPath,
+                                                                    false);
+        }
+    }
+    return;
+}
+
 void Manager::getSensorValues(std::unique_ptr<Status>& occ)
 {
     static bool tracedError[8] = {0};