MessageListener.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. from hub import methods, Global
  2. import threading
  3. import time
  4. import json
  5. import os
  6. # --- for linux
  7. # save_dir = f"/home/server/logs"
  8. # --- for windows
  9. # save_dir = r'C:\SRI-DINO.Server-py\logs' # sri内网测试环境
  10. save_dir = r'C:\logs' # sri内网测试环境
  11. class MessageListener(object):
  12. """
  13. """
  14. @classmethod
  15. def run(cls, background_is=True):
  16. from lib.UserWorkRecord import UserWorkRecord
  17. UserWorkRecord.init()
  18. from lib.MessageListenerC001 import subscribe_c001
  19. from lib.MessageListenerV001 import subscribe_v001
  20. from lib.MessageListenerZJV1 import subscribe_Veh0533
  21. from lib.MessageListenerZJV2 import subscribe_Veh0534
  22. from lib.MessageListenerZJV3 import subscribe_Veh0535
  23. from lib.MessageListenerZJV4 import subscribe_Veh0537
  24. from lib.MessageListenerZJV5 import subscribe_Veh0538
  25. thread_list = [
  26. threading.Thread(target=subscribe_c001),
  27. threading.Thread(target=subscribe_v001),
  28. threading.Thread(target=subscribe_Veh0533),
  29. threading.Thread(target=subscribe_Veh0534),
  30. threading.Thread(target=subscribe_Veh0535),
  31. threading.Thread(target=subscribe_Veh0537),
  32. threading.Thread(target=subscribe_Veh0538),
  33. ]
  34. for thread in thread_list:
  35. thread.setDaemon(True)
  36. thread.start()
  37. if background_is:
  38. return
  39. for thread in thread_list:
  40. thread.join()
  41. if __name__ == '__main__':
  42. # --- test ---
  43. MessageListener.run()