1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- from hub import methods, Global
- import threading
- import traceback
- import time
- import json
- import os
- class MessageListener:
- """
- """
- @classmethod
- def run(cls, background_is=True):
- from lib.UserWorkRecord import UserWorkRecord
- UserWorkRecord.init()
- from lib.TopicListener import TopicListener
- t1 = TopicListener('Cockpit/CanBus/CanId001/Cop001', 'method_c001')
- t2 = TopicListener('Vehicle/ControlVehicle/Veh001', 'method_v001')
- v1 = TopicListener('Vehicle/ControlVehicle/Veh0533', 'method_v001')
- v2 = TopicListener('Vehicle/ControlVehicle/Veh0534', 'method_v001')
- v3 = TopicListener('Vehicle/ControlVehicle/Veh0535', 'method_v001')
- v4 = TopicListener('Vehicle/ControlVehicle/Veh0537', 'method_v001')
- v5 = TopicListener('Vehicle/ControlVehicle/Veh0538', 'method_v001')
- thread_list = [
- threading.Thread(target=t1.subscribe),
- threading.Thread(target=t2.subscribe),
- threading.Thread(target=v1.subscribe),
- threading.Thread(target=v2.subscribe),
- threading.Thread(target=v3.subscribe),
- threading.Thread(target=v4.subscribe),
- threading.Thread(target=v5.subscribe),
- ]
- for thread in thread_list:
- thread.setDaemon(True)
- thread.start()
- if background_is:
- return
- for thread in thread_list:
- thread.join()
- if __name__ == '__main__':
- # --- test ---
- MessageListener.run()
|