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