-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sensor.py
64 lines (64 loc) · 2.05 KB
/
Sensor.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
__author__ = 'mcordoba'
#base class for all peripheral sensors
from threading import Thread,Lock
import time
import Adafruit_BBIO.GPIO as GPIO
from Adafruit_I2C import Adafruit_I2C
class Sensor():
def __init__(self,hexAddress,channelNumber):
"""
Abstract/Base class for all of the peripherals. Base constructor that can be called
:param hexAddress: hex address of the device on the I2C bus
:type hexAddress: hex/int
:param channelNumber: channel # of the device on the MMS unit
:type channelNumber: int
:return: Sensor object
:rtype: Sensor
"""
self.channelNumber = channelNumber
self._address = hexAddress
def getID(self):
"""
Gets the hex I2C ID of the sensor
:return: hex I2C id of the sensor
:rtype: hex/int
"""
return self._address
def setRecorder(self,recorder):
"""
Sets a recording for the sensor
:param recorder: recorder object to bind to the sensor
:type recorder: Recording
:return: None
:rtype: None
"""
if recorder is None:
self.hasRecording = False
recorder = self.recorder
self.recorder = None
del recorder #clean up memory space
else:
self.hasRecording = True
self.recorder = recorder
self.recorder.setSensorMetaData(self.getMetaDataInfo())
def getData(self):
"""
Abstract function that must be overridden by classes that inherit from this
:return: None
:rtype: None
"""
raise NotImplementedError
def getValue(self):
"""
Abstract function that must be overridden by classes that inherit from this
:return: None
:rtype: None
"""
raise NotImplementedError
def getMetaDataInfo(self):
"""
Abstract function that must be overridden by classes that inherit from this
:return: None
:rtype: None
"""
raise NotImplementedError