blob: 2c287cf316248050fe165582fff3d01e4f05821c [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:
Patrick Venturedf766f22018-10-13 09:30:58 -070014 Sensor(const std::string& name, int64_t timeout) :
15 _name(name), _timeout(timeout)
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070016 {
17 }
Patrick Venture863b9242018-03-08 08:29:23 -080018
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070019 virtual ~Sensor()
20 {
21 }
Patrick Venture863b9242018-03-08 08:29:23 -080022
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070023 virtual ReadReturn read(void) = 0;
24 virtual void write(double value) = 0;
Patrick Venture863b9242018-03-08 08:29:23 -080025
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070026 std::string GetName(void) const
27 {
28 return _name;
29 }
Patrick Venture863b9242018-03-08 08:29:23 -080030
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070031 /* Returns the configurable timeout period
32 * for this sensor in seconds (undecorated).
33 */
34 int64_t GetTimeout(void) const
35 {
36 return _timeout;
37 }
Patrick Venture863b9242018-03-08 08:29:23 -080038
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070039 private:
40 std::string _name;
41 int64_t _timeout;
Patrick Venture863b9242018-03-08 08:29:23 -080042};