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: |
Patrick Venture | df766f2 | 2018-10-13 09:30:58 -0700 | [diff] [blame] | 14 | Sensor(const std::string& name, int64_t timeout) : |
15 | _name(name), _timeout(timeout) | ||||
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 16 | { |
17 | } | ||||
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 18 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 19 | virtual ~Sensor() |
20 | { | ||||
21 | } | ||||
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 22 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 23 | virtual ReadReturn read(void) = 0; |
24 | virtual void write(double value) = 0; | ||||
James Feist | 36b7d8e | 2018-10-05 15:39:01 -0700 | [diff] [blame] | 25 | virtual bool getFailed(void) |
26 | { | ||||
27 | return false; | ||||
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 | std::string GetName(void) const |
31 | { | ||||
32 | return _name; | ||||
33 | } | ||||
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 34 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 35 | /* Returns the configurable timeout period |
36 | * for this sensor in seconds (undecorated). | ||||
37 | */ | ||||
38 | int64_t GetTimeout(void) const | ||||
39 | { | ||||
40 | return _timeout; | ||||
41 | } | ||||
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 42 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 43 | private: |
44 | std::string _name; | ||||
45 | int64_t _timeout; | ||||
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 46 | }; |