Improve cpusensor performance

The cpusensor service is still making some redundant accesses for
reading hwmon attributes on every scanning. Actually, threshold
update is needed only when CPU package's Tcontrol target is
changed so this commit make it do that only when Tcontrol value
is changed.

Tested:
  Compare cpu resource consumption of cpusensor service using top.
  It should eat less cpu resources than before.

Change-Id: Ieb582996fc5c9c07abbfc7ac0d1b37f593269d00
Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
diff --git a/include/CPUSensor.hpp b/include/CPUSensor.hpp
index a38c84e..f66e655 100644
--- a/include/CPUSensor.hpp
+++ b/include/CPUSensor.hpp
@@ -10,20 +10,30 @@
     CPUSensor(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& fanName,
+              boost::asio::io_service& io, const std::string& sensorName,
               std::vector<thresholds::Threshold>&& thresholds,
-              const std::string& configuration);
+              const std::string& configuration, int cpuId, bool show);
     ~CPUSensor();
     static constexpr unsigned int sensorScaleFactor = 1000;
     static constexpr unsigned int sensorPollMs = 1000;
+    static constexpr size_t warnAfterErrorCount = 10;
+    static constexpr double maxReading = 127;
+    static constexpr double minReading = -128;
+    static constexpr const char* labelTcontrol = "Tcontrol";
 
   private:
     sdbusplus::asio::object_server& objServer;
     boost::asio::posix::stream_descriptor inputDev;
     boost::asio::deadline_timer waitTimer;
     boost::asio::streambuf readBuf;
+    std::string nameTcontrol;
+    double privTcontrol;
+    bool show;
     int errCount;
     void setupRead(void);
     void handleResponse(const boost::system::error_code& err);
     void checkThresholds(void) override;
 };
+
+extern boost::container::flat_map<std::string, std::unique_ptr<CPUSensor>>
+    gCpuSensors;