main.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import glog, signal
  2. from tofManager import *
  3. import SDK.ZX.async_communication as cm
  4. import SDK.ZX.async_communication_etc_pb2 as rce
  5. import SDK.ZX.tool as zx_tool
  6. if __name__ == '__main__':
  7. # 加载配置
  8. rabbitmq_etc = zx_tool.getProtobufJsonConfig(os.path.dirname(os.path.abspath(__file__)) + "/etc/rabbitmq.json", rce.RabbitmqEtc())
  9. print(rabbitmq_etc)
  10. g_rabbitmq = cm.RabbitAsyncCommunicator(rabbitmq_etc.ip, rabbitmq_etc.port,
  11. rabbitmq_etc.user, rabbitmq_etc.password)
  12. statu_ex_keys = []
  13. for bind in rabbitmq_etc.binds:
  14. key = [bind.ex, bind.route_key]
  15. statu_ex_keys.append(key)
  16. glog.info(statu_ex_keys)
  17. # 初始化
  18. g_rabbitmq.Init(None, statu_ex_keys)
  19. g_rabbitmq.start()
  20. tofs = TofManager()
  21. tofs.searchAllCamera()
  22. etc = tofs.getAllCameraEtc()
  23. tofs.openAllCamera()
  24. tofs.startAllCameraStream()
  25. # 绑定rabbitmq
  26. g_rabbitmq.bind_statu_callback(statu_ex_keys[0][0], statu_ex_keys[0][1], tofs.exec)
  27. while True:
  28. message = input("input q or Q exit this progress\n")
  29. if message == "q" or message == "Q":
  30. break
  31. # 释放
  32. tofs.stopAllCameraStream()
  33. tofs.closeAllCamera()
  34. # 强制结束进程
  35. pid = os.getpid()
  36. os.kill(pid, 1)