blob: c16d19e56be16779ea744c8f3b3aa22904e40173 [file] [log] [blame]
Patrick Venturee6206562018-03-08 15:36:53 -08001#pragma once
2
3#include <chrono>
4
5
6struct ReadReturn {
7 double value;
8 std::chrono::high_resolution_clock::time_point updated;
Patrick Venturebd6b4762018-06-14 09:24:42 -07009
10 bool operator==(const ReadReturn &rhs) const {
11 return (this->value == rhs.value && this->updated == rhs.updated);
12 }
Patrick Venturee6206562018-03-08 15:36:53 -080013};
14
15
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 */
20class ReadInterface
21{
22 public:
23 ReadInterface() { }
24
25 virtual ~ReadInterface() { }
26
27 virtual ReadReturn read(void) = 0;
28};
29
30/*
31 * A WriteInterface is a plug-in for the PluggableSensor and anyone implementing
32 * this basically is providing a way to write a sensor.
33 */
34class WriteInterface
35{
36 public:
37 WriteInterface(int64_t min, int64_t max)
38 : _min(min),
39 _max(max)
40 { }
41
42 virtual ~WriteInterface() { }
43
44 virtual void write(double value) = 0;
45
46 /*
47 * All WriteInterfaces have min/max available in case they want to error
48 * check.
49 */
50 int64_t getMin(void)
51 {
52 return _min;
53 }
54 int64_t getMax(void)
55 {
56 return _max;
57 }
58 private:
59 int64_t _min;
60 int64_t _max;
61};