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