blob: 9ff0584a7cadf04a412c18be95c66a34febcd29a [file] [log] [blame]
Patrick Venture863b9242018-03-08 08:29:23 -08001#pragma once
2
Patrick Venture863b9242018-03-08 08:29:23 -08003#include "interfaces.hpp"
4
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07005#include <chrono>
6#include <string>
Patrick Venture863b9242018-03-08 08:29:23 -08007
8/**
9 * Abstract base class for all sensors.
10 */
11class Sensor
12{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070013 public:
14 Sensor(std::string name, int64_t timeout) : _name(name), _timeout(timeout)
15 {
16 }
Patrick Venture863b9242018-03-08 08:29:23 -080017
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070018 virtual ~Sensor()
19 {
20 }
Patrick Venture863b9242018-03-08 08:29:23 -080021
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070022 virtual ReadReturn read(void) = 0;
23 virtual void write(double value) = 0;
Patrick Venture863b9242018-03-08 08:29:23 -080024
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070025 std::string GetName(void) const
26 {
27 return _name;
28 }
Patrick Venture863b9242018-03-08 08:29:23 -080029
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070030 /* Returns the configurable timeout period
31 * for this sensor in seconds (undecorated).
32 */
33 int64_t GetTimeout(void) const
34 {
35 return _timeout;
36 }
Patrick Venture863b9242018-03-08 08:29:23 -080037
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070038 private:
39 std::string _name;
40 int64_t _timeout;
Patrick Venture863b9242018-03-08 08:29:23 -080041};