-
Notifications
You must be signed in to change notification settings - Fork 0
/
SensorData.py
96 lines (90 loc) · 1.8 KB
/
SensorData.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
from app import db
from datetime import datetime
class SensorDataModel(db.Model):
__tablename__ = 'sensor_records'
id = db.Column(
db.Integer,
primary_key=True
)
internal_id = db.Column(
db.String(16),
index=False,
unique=False,
nullable=False
)
latitude = db.Column(
db.String(16),
index=False,
unique=False,
nullable=False
)
longitude = db.Column(
db.String(16),
index=False,
unique=False,
nullable=False
)
altitude = db.Column(
db.String(16),
index=False,
unique=False,
nullable=False
)
recorded = db.Column(
db.DateTime,
index=False,
unique=False,
nullable=False
)
pm25 = db.Column(
db.String(16)
)
pm100 = db.Column(
db.String(16)
)
o31 = db.Column(
db.String(16)
)
o38 = db.Column(
db.String(16)
)
co = db.Column(
db.String(16)
)
so2 = db.Column(
db.String(16)
)
no2 = db.Column(
db.String(16)
)
temp = db.Column(
db.String(16)
)
humi = db.Column(
db.String(16)
)
press = db.Column(
db.String(16)
)
pm1 = db.Column(
db.String(16)
)
nh3 = db.Column(
db.String(16)
)
co2 = db.Column(
db.String(16)
)
rad = db.Column(
db.String(16)
)
sound = db.Column(
db.String(16)
)
def __repr__(self):
return '<SensorData {}>'.format(self.string_coords())
def string_coords(self):
return str(self.latitude) + '-' + str(self.longitude)
def as_dict(self):
r = {c.name: getattr(self, c.name) for c in self.__table__.columns}
return r