Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 1 | #pragma once |
2 | |||||
3 | #include <chrono> | ||||
4 | |||||
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 5 | struct ReadReturn |
6 | { | ||||
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 7 | double value; |
8 | std::chrono::high_resolution_clock::time_point updated; | ||||
Patrick Venture | bd6b476 | 2018-06-14 09:24:42 -0700 | [diff] [blame] | 9 | |
Patrick Venture | e2ec0f6 | 2018-09-04 12:30:27 -0700 | [diff] [blame] | 10 | bool operator==(const ReadReturn& rhs) const |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 11 | { |
Patrick Venture | bd6b476 | 2018-06-14 09:24:42 -0700 | [diff] [blame] | 12 | return (this->value == rhs.value && this->updated == rhs.updated); |
13 | } | ||||
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 14 | }; |
15 | |||||
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 16 | /* |
17 | * A ReadInterface is a plug-in for the PluggableSensor and anyone implementing | ||||
18 | * this basically is providing a way to read a sensor. | ||||
19 | */ | ||||
20 | class ReadInterface | ||||
21 | { | ||||
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 22 | public: |
23 | ReadInterface() | ||||
Patrick Venture | a83a3ec | 2020-08-04 09:52:05 -0700 | [diff] [blame] | 24 | {} |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 25 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 26 | virtual ~ReadInterface() |
Patrick Venture | a83a3ec | 2020-08-04 09:52:05 -0700 | [diff] [blame] | 27 | {} |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 28 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 29 | virtual ReadReturn read(void) = 0; |
James Feist | 36b7d8e | 2018-10-05 15:39:01 -0700 | [diff] [blame] | 30 | |
31 | virtual bool getFailed(void) const | ||||
32 | { | ||||
33 | return false; | ||||
34 | } | ||||
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 35 | }; |
36 | |||||
37 | /* | ||||
38 | * A WriteInterface is a plug-in for the PluggableSensor and anyone implementing | ||||
39 | * this basically is providing a way to write a sensor. | ||||
40 | */ | ||||
41 | class WriteInterface | ||||
42 | { | ||||
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 43 | public: |
44 | WriteInterface(int64_t min, int64_t max) : _min(min), _max(max) | ||||
Patrick Venture | a83a3ec | 2020-08-04 09:52:05 -0700 | [diff] [blame] | 45 | {} |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 46 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 47 | virtual ~WriteInterface() |
Patrick Venture | a83a3ec | 2020-08-04 09:52:05 -0700 | [diff] [blame] | 48 | {} |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 49 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 50 | virtual void write(double value) = 0; |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 51 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 52 | /* |
53 | * All WriteInterfaces have min/max available in case they want to error | ||||
54 | * check. | ||||
55 | */ | ||||
56 | int64_t getMin(void) | ||||
57 | { | ||||
58 | return _min; | ||||
59 | } | ||||
60 | int64_t getMax(void) | ||||
61 | { | ||||
62 | return _max; | ||||
63 | } | ||||
64 | |||||
65 | private: | ||||
66 | int64_t _min; | ||||
67 | int64_t _max; | ||||
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 68 | }; |