xref: /openbmc/phosphor-pid-control/sensors/sensor.hpp (revision df766f251f25e32ccbfe1e3ea429f118478422bd)
1863b9246SPatrick Venture #pragma once
2863b9246SPatrick Venture 
3863b9246SPatrick Venture #include "interfaces.hpp"
4863b9246SPatrick Venture 
5da4a5dd1SPatrick Venture #include <chrono>
6da4a5dd1SPatrick Venture #include <string>
7863b9246SPatrick Venture 
8863b9246SPatrick Venture /**
9863b9246SPatrick Venture  * Abstract base class for all sensors.
10863b9246SPatrick Venture  */
11863b9246SPatrick Venture class Sensor
12863b9246SPatrick Venture {
13863b9246SPatrick Venture   public:
14*df766f25SPatrick Venture     Sensor(const std::string& name, int64_t timeout) :
15*df766f25SPatrick Venture         _name(name), _timeout(timeout)
16da4a5dd1SPatrick Venture     {
17da4a5dd1SPatrick Venture     }
18863b9246SPatrick Venture 
19da4a5dd1SPatrick Venture     virtual ~Sensor()
20da4a5dd1SPatrick Venture     {
21da4a5dd1SPatrick Venture     }
22863b9246SPatrick Venture 
23863b9246SPatrick Venture     virtual ReadReturn read(void) = 0;
24863b9246SPatrick Venture     virtual void write(double value) = 0;
25863b9246SPatrick Venture 
26863b9246SPatrick Venture     std::string GetName(void) const
27863b9246SPatrick Venture     {
28863b9246SPatrick Venture         return _name;
29863b9246SPatrick Venture     }
30863b9246SPatrick Venture 
31863b9246SPatrick Venture     /* Returns the configurable timeout period
32863b9246SPatrick Venture      * for this sensor in seconds (undecorated).
33863b9246SPatrick Venture      */
34863b9246SPatrick Venture     int64_t GetTimeout(void) const
35863b9246SPatrick Venture     {
36863b9246SPatrick Venture         return _timeout;
37863b9246SPatrick Venture     }
38863b9246SPatrick Venture 
39863b9246SPatrick Venture   private:
40863b9246SPatrick Venture     std::string _name;
41863b9246SPatrick Venture     int64_t _timeout;
42863b9246SPatrick Venture };
43