Implement PSU Power Sensor

Implement Power Supply Input Power Sensor.

Tested By:
With the related change in entity-manager, after run psusensor in
BMC console, xyz.openbmc_project.PSUSensor has been created and
PSU pin dbus interface has been created with correct Thresholds
and value. Ipmitool sensor list can show PSU pin sensor.

Change-Id: Ib057a9ecca7bf317eb8d98af1ddb8be39841a54f
Signed-off-by: Cheng C Yang <cheng.c.yang@linux.intel.com>
diff --git a/include/PSUSensor.hpp b/include/PSUSensor.hpp
new file mode 100644
index 0000000..8de480f
--- /dev/null
+++ b/include/PSUSensor.hpp
@@ -0,0 +1,57 @@
+#pragma once
+
+#include <Thresholds.hpp>
+#include <sdbusplus/asio/object_server.hpp>
+#include <sensor.hpp>
+
+enum class SensorType
+{
+    tempSensor,
+    currSensor,
+    powerSensor,
+    voltSensor
+};
+
+class PSUSensor : public Sensor
+{
+  public:
+    PSUSensor(const std::string& path, const std::string& objectType,
+              sdbusplus::asio::object_server& objectServer,
+              std::shared_ptr<sdbusplus::asio::connection>& conn,
+              boost::asio::io_service& io, const std::string& sensorName,
+              std::vector<thresholds::Threshold>&& thresholds,
+              const std::string& sensorConfiguration,
+              std::string& sensorTypeName, unsigned int factor, double max,
+              double min);
+    ~PSUSensor();
+
+  private:
+    sdbusplus::asio::object_server& objServer;
+    boost::asio::posix::stream_descriptor inputDev;
+    boost::asio::deadline_timer waitTimer;
+    boost::asio::streambuf readBuf;
+    int errCount;
+    unsigned int sensorFactor;
+    void setupRead(void);
+    void handleResponse(const boost::system::error_code& err);
+    void checkThresholds(void) override;
+
+    static constexpr unsigned int sensorPollMs = 500;
+    static constexpr size_t warnAfterErrorCount = 10;
+};
+
+class PSUProperty
+{
+  public:
+    PSUProperty(std::string name, double max, double min, unsigned int factor) :
+        sensorTypeName(name), maxReading(max), minReading(min),
+        sensorScaleFactor(factor)
+    {
+    }
+    ~PSUProperty() = default;
+
+    std::string sensorTypeName;
+    double maxReading;
+    double minReading;
+    unsigned int sensorScaleFactor;
+};