blob: dc5f3e08ec99e5656ae659d2943fef4e0d891ae6 [file] [log] [blame]
Patrick Venture863b9242018-03-08 08:29:23 -08001#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 */
12class 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