regulators: Create DBusSensor class
Create the DBusSensor class that represents a voltage regulator sensor
on D-Bus.
Each voltage rail in the system may provide multiple types of sensor
data, such as temperature, output voltage, and output current. A
DBusSensor tracks one of these data types for a voltage rail.
Class supports the following sensor operations:
* Create sensor
* Set sensor value
* Disable sensor (when system is powered off)
* Set sensor to error state (when unable to read value due to I2C error)
* Delete sensor
Note: A different class will implement the ObjectManager interface for
all voltage regulator sensors. That will be in a future commit.
Tested:
* Created a sensor of each supported type (vout, iout, etc.)
* Set the value of a sensor
* Tested update policies: hysteresis, highest, lowest
* Disabled a sensor
* Set a sensor to the error state
* Verified all D-Bus signals emitted
* InterfacesAdded signal emitted with all info when sensor created
* PropertiesChanged signal emitted when sensor properties change
* InterfacesRemoved signal emitted when sensor deleted
* See https://gist.github.com/smccarney/5ae989da1977162ae1a21c208d5302fc
for complete test plan.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I655277e6bf0a31a8778a54e87d5864f9951b045e
diff --git a/phosphor-regulators/src/sensors.hpp b/phosphor-regulators/src/sensors.hpp
index d23a2b7..b37c8c3 100644
--- a/phosphor-regulators/src/sensors.hpp
+++ b/phosphor-regulators/src/sensors.hpp
@@ -25,7 +25,7 @@
/**
* Voltage regulator sensor type.
*/
-enum class SensorType
+enum class SensorType : unsigned char
{
/**
* Output current.
@@ -90,7 +90,7 @@
* @param type sensor type
* @return sensor type name
*/
-std::string toString(SensorType type)
+inline std::string toString(SensorType type)
{
std::string name{};
switch (type)