-
Notifications
You must be signed in to change notification settings - Fork 182
/
Copy pathsensor_base.py
173 lines (131 loc) · 3.83 KB
/
sensor_base.py
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
"""
sensor_base.py
Abstract base class for implementing a platform-specific class with which
to interact with a sensor module in SONiC
"""
from . import device_base
class SensorBase(device_base.DeviceBase):
"""
Abstract base class for interfacing with a sensor module
"""
@classmethod
def get_type(cls):
"""
Specifies the type of the sensor such as current/voltage etc.
Returns:
Sensor type
"""
raise NotImplementedError
def get_value(self):
"""
Retrieves measurement reported by sensor
Returns:
Sensor measurement
"""
raise NotImplementedError
@classmethod
def get_unit(cls):
"""
Retrieves unit of measurement reported by sensor
Returns:
Sensor measurement unit
"""
raise NotImplementedError
def get_high_threshold(self):
"""
Retrieves the high threshold of sensor
Returns:
High threshold
"""
raise NotImplementedError
def get_low_threshold(self):
"""
Retrieves the low threshold
Returns:
Low threshold
"""
raise NotImplementedError
def set_high_threshold(self, value):
"""
Sets the high threshold value of sensor
Args:
value: High threshold value to set
Returns:
A boolean, True if threshold is set successfully, False if not
"""
raise NotImplementedError
def set_low_threshold(self, value):
"""
Sets the low threshold value of sensor
Args:
value: Value
Returns:
A boolean, True if threshold is set successfully, False if not
"""
raise NotImplementedError
def get_high_critical_threshold(self):
"""
Retrieves the high critical threshold value of sensor
Returns:
The high critical threshold value of sensor
"""
raise NotImplementedError
def get_low_critical_threshold(self):
"""
Retrieves the low critical threshold value of sensor
Returns:
The low critical threshold value of sensor
"""
raise NotImplementedError
def set_high_critical_threshold(self, value):
"""
Sets the critical high threshold value of sensor
Args:
value: Critical high threshold Value
Returns:
A boolean, True if threshold is set successfully, False if not
"""
raise NotImplementedError
def set_low_critical_threshold(self, value):
"""
Sets the critical low threshold value of sensor
Args:
value: Critial low threshold Value
Returns:
A boolean, True if threshold is set successfully, False if not
"""
raise NotImplementedError
def get_minimum_recorded(self):
"""
Retrieves the minimum recorded value of sensor
Returns:
The minimum recorded value of sensor
"""
raise NotImplementedError
def get_maximum_recorded(self):
"""
Retrieves the maximum recorded value of sensor
Returns:
The maximum recorded value of sensor
"""
raise NotImplementedError
class VoltageSensorBase(SensorBase):
"""
Abstract base class for interfacing with a voltage sensor module
"""
@classmethod
def get_type(cls):
return "SENSOR_TYPE_VOLTAGE"
@classmethod
def get_unit(cls):
return "mV"
class CurrentSensorBase(SensorBase):
"""
Abstract base class for interfacing with a current sensor module
"""
@classmethod
def get_type(cls):
return "SENSOR_TYPE_CURRENT"
@classmethod
def get_unit(cls):
return "mA"