psusensor: Add support for the 'PowerState' parameter

When CPU is powered off, some sensor reading values are expected
to go below low thresholds. To prevent unnecessary sensor readings
and redundant threshold event trigger in cases like that add support
for the 'PowerState' JSON configuration parameter similar to other
'dbus-sensors' apps.
Use 'checkThresholdsPowerDelay' function in a threshold check like
it is done in ADCSensor app. This is necessary as PSU data can drop
faster than a change in a power state is noticed.

Tested on the AMD EthanolX CRB with ISL68137:

When the PowerState is set to "On" and the platform is powered off,
no transactions are observed on the corresponding I2C bus.

When the PowerState is set to "Always" monitoring is always enabled
and I2C transactions are always observed regardless the platform
power state.

These commands were used to monitor transactions
on the I2C bus:
$ echo 1 > /sys/kernel/debug/tracing/tracing_on
$ echo 1 > /sys/kernel/debug/tracing/events/i2c/i2c_read/enable
$ cat /sys/kernel/debug/tracing/trace_pipe

Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Change-Id: Ic7b36e48828adf4eb2f7714965a4a1df4eb5ac3e
diff --git a/src/Utils.cpp b/src/Utils.cpp
index 5a5064f..1a14911 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -240,6 +240,20 @@
     return biosHasPost;
 }
 
+bool readingStateGood(const PowerState& powerState)
+{
+    if (powerState == PowerState::on && !isPowerOn())
+    {
+        return false;
+    }
+    if (powerState == PowerState::biosPost && (!hasBiosPost() || !isPowerOn()))
+    {
+        return false;
+    }
+
+    return true;
+}
+
 static void
     getPowerStatus(const std::shared_ptr<sdbusplus::asio::connection>& conn,
                    size_t retries = 2)
@@ -557,4 +571,4 @@
 bool getManufacturingMode()
 {
     return manufacturingMode;
-}
\ No newline at end of file
+}