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