-
Notifications
You must be signed in to change notification settings - Fork 0
/
ibQuery.py
29 lines (26 loc) · 1.08 KB
/
ibQuery.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
#!/usr/bin/env python
class ibQuery:
def __init__(self, data_type, isoblue_id):
self.query_param = self._get_query_param(data_type)
self.first_row = self._get_first_row(data_type)
def _get_query_param(self, data_type):
'''
Return query parameters based on the query data type.
Return None if no matching data type.
'''
return {
'hb': "`ts`, `isoblue_id`, `wifins`, `cellns`, `netled`, `statled`",
'gps': "`ts`, `isoblue_id`, `lat`, `lon`, `alt`, `speed`",
'isobus': "`ts`, `isoblue_id`, `pgn`, `payload`",
}.get(data_type, None)
def _get_first_row(self, data_type):
'''
Return csv header line based on data type and where isoblue_id presents.
Return None if no matching data type.
'''
return {
'hb': ['ts', 'isoblue_id', 'wifins', 'cellns', 'netled', \
'statled'],
'gps': ['ts', 'isoblue_id', 'lat', 'lon', 'alt', 'speed'],
'isobus': ['ts', 'isoblue_id', 'pgn', 'payload'],
}.get(data_type, None)