-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.py
38 lines (31 loc) · 1.06 KB
/
application.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
from pimp_my_engine.logger.obd_logger import ObdRecorder
from pimp_my_engine.core.dtypes.obd_collector import ObdCollector
from threading import Thread, Condition
import obd
import logging
logging.basicConfig(filename='autotag_service.log', level=logging.INFO)
logger = logging.getLogger(__name__)
def data_collection_thread(obd_collector, condition):
logger.info('Data collection thread running')
obd_recorder = ObdRecorder(obd_collector)
commands = ['RPM']
obd_recorder.connect()
obd_recorder.register_callbacks(commands)
obd_recorder.start_recording()
# wait to stop recording
logger.info('Data collection is running')
condition.acquire()
condition.wait()
condition.release()
logger.info('Data collection thread dies now')
obd_recorder.stop_recording()
def main():
obd_collector = ObdCollector()
condition = Condition()
dcthread = Thread(
target = data_collection_thread,
args = [obd_collector,condition]
)
dcthread.start()
if __name__ == '__main__':
main()