sensor: Implement sensor "PRIORITY"

This commit introduces the `xyz.openbmc_project.Common.Priority`
interface to define the priority of sensors. If a sensor's priority
attribute is specified, this interface is created with the 'priority'
attribute. However, if the priority attribute is not specified, this
interface is not created.

The `xyz.openbmc_project.Common.Priority` interface is used to indicate
the priority level of fan sensors. It provides information about
primary and secondary RPM sensors for dual rotor fans, allowing for a
more specific description of the sensor's priority.

phosphor-dbus-interfaces commit:
https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/66779

Tested: Build phosphor-hwmon successfully

'''
1. Retrieve the priority level of the secondary sensor

busctl introspect xyz.openbmc_project.Hwmon-xxx .Hwmon1 \
/xyz/openbmc_project/sensors/fan_tach/fan1_1  xyz.openbmc_project.Common.Priority

NAME                                TYPE      SIGNATURE RESULT/VALUE FLAGS
.Priority                           property  u         1            emits-change writable

2. If the "PRIORITY" is not specified in the sensor's configuration file

busctl introspect xyz.openbmc_project.Hwmon-xxx .Hwmon1 \
/xyz/openbmc_project/sensors/fan_tach/fan1_0  xyz.openbmc_project.Common.Priority
NAME TYPE SIGNATURE RESULT/VALUE FLAGS

3. Change the sensor priority

busctl set-property xyz.openbmc_project.Hwmon-xxx.Hwmon1 \
/xyz/openbmc_project/sensors/fan_tach/fan1_1 xyz.openbmc_project.Common.Priority \
 Priority u 0

busctl introspect xyz.openbmc_project.Hwmon-xxx .Hwmon1 \
/xyz/openbmc_project/sensors/fan_tach/fan1_1  xyz.openbmc_project.Common.Priority
NAME                                TYPE      SIGNATURE RESULT/VALUE FLAGS
.Priority                           property  u         0            emits-change writable
'''

Change-Id: I7a226cf105756bc32e04f6724428d93e84dfb72a
Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
diff --git a/mainloop.cpp b/mainloop.cpp
index e38b156..cfc5b5e 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -176,16 +176,18 @@
     std::string id = getID(sensor);
     std::string label;
     std::string accuracy;
+    std::string priority;
 
     if (!id.empty())
     {
         // Ignore inputs without a label.
         label = env::getEnv("LABEL", sensor.first.first, id);
         accuracy = env::getEnv("ACCURACY", sensor.first.first, id);
+        priority = env::getEnv("PRIORITY", sensor.first.first, id);
     }
 
-    return std::make_tuple(std::move(id), std::move(label),
-                           std::move(accuracy));
+    return std::make_tuple(std::move(id), std::move(label), std::move(accuracy),
+                           std::move(priority));
 }
 
 /**
@@ -254,6 +256,19 @@
         catch (const std::invalid_argument&)
         {}
 
+        // Add priority interface
+        auto priorityStr = std::get<sensorPriority>(properties);
+        try
+        {
+            if (!priorityStr.empty())
+            {
+                auto priority = std::stoul(priorityStr);
+                sensorObj->addPriority(info, priority);
+            }
+        }
+        catch (const std::invalid_argument&)
+        {}
+
         // Add status interface based on _fault file being present
         sensorObj->addStatus(info);
         valueInterface = sensorObj->addValue(retryIO, info, _timedoutMap);