blob: 89ef128c281234e61e19e1518134af1ddcaee8b9 [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;
James Feist36b7d8e2018-10-05 15:39:01 -070032
33 virtual bool getFailed(void) const
34 {
35 return false;
36 }
Patrick Venturee6206562018-03-08 15:36:53 -080037};
38
39/*
40 * A WriteInterface is a plug-in for the PluggableSensor and anyone implementing
41 * this basically is providing a way to write a sensor.
42 */
43class WriteInterface
44{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070045 public:
46 WriteInterface(int64_t min, int64_t max) : _min(min), _max(max)
47 {
48 }
Patrick Venturee6206562018-03-08 15:36:53 -080049
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070050 virtual ~WriteInterface()
51 {
52 }
Patrick Venturee6206562018-03-08 15:36:53 -080053
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070054 virtual void write(double value) = 0;
Patrick Venturee6206562018-03-08 15:36:53 -080055
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070056 /*
57 * All WriteInterfaces have min/max available in case they want to error
58 * check.
59 */
60 int64_t getMin(void)
61 {
62 return _min;
63 }
64 int64_t getMax(void)
65 {
66 return _max;
67 }
68
69 private:
70 int64_t _min;
71 int64_t _max;
Patrick Venturee6206562018-03-08 15:36:53 -080072};