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: 14df766f25SPatrick Venture Sensor(const std::string& name, int64_t timeout) : 15df766f25SPatrick 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; 2536b7d8ebSJames Feist virtual bool getFailed(void) 2636b7d8ebSJames Feist { 2736b7d8ebSJames Feist return false; 2836b7d8ebSJames Feist }; 29863b9246SPatrick Venture 30*563a356fSPatrick Venture std::string getName(void) const 31863b9246SPatrick Venture { 32863b9246SPatrick Venture return _name; 33863b9246SPatrick Venture } 34863b9246SPatrick Venture 35863b9246SPatrick Venture /* Returns the configurable timeout period 36863b9246SPatrick Venture * for this sensor in seconds (undecorated). 37863b9246SPatrick Venture */ 38*563a356fSPatrick Venture int64_t getTimeout(void) const 39863b9246SPatrick Venture { 40863b9246SPatrick Venture return _timeout; 41863b9246SPatrick Venture } 42863b9246SPatrick Venture 43863b9246SPatrick Venture private: 44863b9246SPatrick Venture std::string _name; 45863b9246SPatrick Venture int64_t _timeout; 46863b9246SPatrick Venture }; 47