xref: /openbmc/phosphor-pid-control/sensors/sensor.hpp (revision da4a5dd133b88ebfeb69e89d05b381f81ba70e50)
1863b9246SPatrick Venture #pragma once
2863b9246SPatrick Venture 
3863b9246SPatrick Venture #include "interfaces.hpp"
4863b9246SPatrick Venture 
5*da4a5dd1SPatrick Venture #include <chrono>
6*da4a5dd1SPatrick 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*da4a5dd1SPatrick Venture     Sensor(std::string name, int64_t timeout) : _name(name), _timeout(timeout)
15*da4a5dd1SPatrick Venture     {
16*da4a5dd1SPatrick Venture     }
17863b9246SPatrick Venture 
18*da4a5dd1SPatrick Venture     virtual ~Sensor()
19*da4a5dd1SPatrick Venture     {
20*da4a5dd1SPatrick Venture     }
21863b9246SPatrick Venture 
22863b9246SPatrick Venture     virtual ReadReturn read(void) = 0;
23863b9246SPatrick Venture     virtual void write(double value) = 0;
24863b9246SPatrick Venture 
25863b9246SPatrick Venture     std::string GetName(void) const
26863b9246SPatrick Venture     {
27863b9246SPatrick Venture         return _name;
28863b9246SPatrick Venture     }
29863b9246SPatrick Venture 
30863b9246SPatrick Venture     /* Returns the configurable timeout period
31863b9246SPatrick Venture      * for this sensor in seconds (undecorated).
32863b9246SPatrick Venture      */
33863b9246SPatrick Venture     int64_t GetTimeout(void) const
34863b9246SPatrick Venture     {
35863b9246SPatrick Venture         return _timeout;
36863b9246SPatrick Venture     }
37863b9246SPatrick Venture 
38863b9246SPatrick Venture   private:
39863b9246SPatrick Venture     std::string _name;
40863b9246SPatrick Venture     int64_t _timeout;
41863b9246SPatrick Venture };
42