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