xref: /openbmc/phosphor-pid-control/sensors/sensor.hpp (revision 863b9246dd43464da91ec789deaa42d15c45f84d)
1*863b9246SPatrick Venture #pragma once
2*863b9246SPatrick Venture 
3*863b9246SPatrick Venture #include <chrono>
4*863b9246SPatrick Venture #include <string>
5*863b9246SPatrick Venture 
6*863b9246SPatrick Venture #include "interfaces.hpp"
7*863b9246SPatrick Venture 
8*863b9246SPatrick Venture 
9*863b9246SPatrick Venture /**
10*863b9246SPatrick Venture  * Abstract base class for all sensors.
11*863b9246SPatrick Venture  */
12*863b9246SPatrick Venture class Sensor
13*863b9246SPatrick Venture {
14*863b9246SPatrick Venture     public:
15*863b9246SPatrick Venture         Sensor(std::string name, int64_t timeout)
16*863b9246SPatrick Venture             : _name(name), _timeout(timeout)
17*863b9246SPatrick Venture         { }
18*863b9246SPatrick Venture 
19*863b9246SPatrick Venture         virtual ~Sensor() { }
20*863b9246SPatrick Venture 
21*863b9246SPatrick Venture         virtual ReadReturn read(void) = 0;
22*863b9246SPatrick Venture         virtual void write(double value) = 0;
23*863b9246SPatrick Venture 
24*863b9246SPatrick Venture         std::string GetName(void) const
25*863b9246SPatrick Venture         {
26*863b9246SPatrick Venture             return _name;
27*863b9246SPatrick Venture         }
28*863b9246SPatrick Venture 
29*863b9246SPatrick Venture         /* Returns the configurable timeout period
30*863b9246SPatrick Venture          * for this sensor in seconds (undecorated).
31*863b9246SPatrick Venture          */
32*863b9246SPatrick Venture         int64_t GetTimeout(void) const
33*863b9246SPatrick Venture         {
34*863b9246SPatrick Venture             return _timeout;
35*863b9246SPatrick Venture         }
36*863b9246SPatrick Venture 
37*863b9246SPatrick Venture     private:
38*863b9246SPatrick Venture         std::string _name;
39*863b9246SPatrick Venture         int64_t _timeout;
40*863b9246SPatrick Venture };
41*863b9246SPatrick Venture 
42