Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 1 | #pragma once |
2 | |||||
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 3 | #include "interfaces.hpp" |
4 | |||||
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame^] | 5 | #include <chrono> |
6 | #include <string> | ||||
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 7 | |
8 | /** | ||||
9 | * Abstract base class for all sensors. | ||||
10 | */ | ||||
11 | class Sensor | ||||
12 | { | ||||
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame^] | 13 | public: |
14 | Sensor(std::string name, int64_t timeout) : _name(name), _timeout(timeout) | ||||
15 | { | ||||
16 | } | ||||
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 17 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame^] | 18 | virtual ~Sensor() |
19 | { | ||||
20 | } | ||||
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 21 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame^] | 22 | virtual ReadReturn read(void) = 0; |
23 | virtual void write(double value) = 0; | ||||
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 24 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame^] | 25 | std::string GetName(void) const |
26 | { | ||||
27 | return _name; | ||||
28 | } | ||||
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 29 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame^] | 30 | /* 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 Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 37 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame^] | 38 | private: |
39 | std::string _name; | ||||
40 | int64_t _timeout; | ||||
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 41 | }; |