-
Notifications
You must be signed in to change notification settings - Fork 0
/
RawObject.py
57 lines (48 loc) · 1.36 KB
/
RawObject.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
import hashlib
import json
class RawObject(object):
"""
RawObject should encapsulate raw object data
"""
# Attributes:
__rawData = None # (jsonobject)
__MD5 = None # (string)
__sensorName = None # (string)
__date = None # (date)
def __init__(self, rawData, sensorName, date):
self.__date = date
self.__MD5 = hashlib.md5 ()
self.__rawData = rawData
self.__sensorName = sensorName
# Operations
def getRawData(self):
"""function getRawData
returns bytearray
"""
return self.__rawData
def getJsonData(self):
"""function getJsonData
returns JsonObject
raise NotImplementedError()
"""
data = {
"rawData" : self.__rawData,
# "md5" : self.__MD5.hexdigest (),
"date" : self.__date,
"sensorName" : self.__sensorName
}
self.__MD5.update ( json.dumps(data) )
data = {
"rawData" : self.__rawData,
"md5" : self.__MD5.hexdigest (),
"date" : self.__date,
"sensorName" : self.__sensorName
}
return json.dumps(data)
# def getMD5(self):
"""function getMD5
raise NotImplementedError()
"""
return self.__md5.hexdigest()
def getDate(self):
return self.__date