blob: bf4554572d9ad4adf66198a32e7f4ab1e65c1262 [file] [log] [blame]
Patrick Venturee6206562018-03-08 15:36:53 -08001#pragma once
2
3#include <chrono>
4
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07005struct ReadReturn
6{
Patrick Venturee6206562018-03-08 15:36:53 -08007 double value;
8 std::chrono::high_resolution_clock::time_point updated;
Patrick Venturebd6b4762018-06-14 09:24:42 -07009
Patrick Venturee2ec0f62018-09-04 12:30:27 -070010 bool operator==(const ReadReturn& rhs) const
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070011 {
Patrick Venturebd6b4762018-06-14 09:24:42 -070012 return (this->value == rhs.value && this->updated == rhs.updated);
13 }
Patrick Venturee6206562018-03-08 15:36:53 -080014};
15
Patrick Venturee6206562018-03-08 15:36:53 -080016/*
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{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070022 public:
23 ReadInterface()
24 {
25 }
Patrick Venturee6206562018-03-08 15:36:53 -080026
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070027 virtual ~ReadInterface()
28 {
29 }
Patrick Venturee6206562018-03-08 15:36:53 -080030
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070031 virtual ReadReturn read(void) = 0;
Patrick Venturee6206562018-03-08 15:36:53 -080032};
33
34/*
35 * A WriteInterface is a plug-in for the PluggableSensor and anyone implementing
36 * this basically is providing a way to write a sensor.
37 */
38class WriteInterface
39{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070040 public:
41 WriteInterface(int64_t min, int64_t max) : _min(min), _max(max)
42 {
43 }
Patrick Venturee6206562018-03-08 15:36:53 -080044
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070045 virtual ~WriteInterface()
46 {
47 }
Patrick Venturee6206562018-03-08 15:36:53 -080048
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070049 virtual void write(double value) = 0;
Patrick Venturee6206562018-03-08 15:36:53 -080050
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070051 /*
52 * All WriteInterfaces have min/max available in case they want to error
53 * check.
54 */
55 int64_t getMin(void)
56 {
57 return _min;
58 }
59 int64_t getMax(void)
60 {
61 return _max;
62 }
63
64 private:
65 int64_t _min;
66 int64_t _max;
Patrick Venturee6206562018-03-08 15:36:53 -080067};