main.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // Created by zx on 2020/6/18.
  3. //
  4. #include <iostream>
  5. #include "./error_code/error_code.h"
  6. #include "./wanji_lidar/LogFiles.h"
  7. #include <glog/logging.h>
  8. #include "./communication/communication_socket_base.h"
  9. #include "./tool/thread_pool.h"
  10. #include "./system/system_communication.h"
  11. #include "./system/system_executor.h"
  12. // #include "./wanji_lidar/wanji_lidar_device.h"
  13. #include "./tool/proto_tool.h"
  14. #include "./wanji_lidar/wanji_manager.h"
  15. #include "./velodyne_lidar/velodyne_manager.h"
  16. #define LIVOX_NUMBER 2
  17. GOOGLE_GLOG_DLL_DECL void shut_down_logging(const char* data, int size)
  18. {
  19. time_t tt;
  20. time( &tt );
  21. tt = tt + 8*3600; // transform the time zone
  22. tm* t= gmtime( &tt );
  23. char buf[255]={0};
  24. sprintf(buf,"./%d%02d%02d-%02d%02d%02d-dump.txt",
  25. t->tm_year + 1900,
  26. t->tm_mon + 1,
  27. t->tm_mday,
  28. t->tm_hour,
  29. t->tm_min,
  30. t->tm_sec);
  31. FILE* tp_file=fopen(buf,"w");
  32. fprintf(tp_file,data,strlen(data));
  33. fclose(tp_file);
  34. }
  35. void test_whole_process()
  36. {
  37. System_executor::get_instance_references().execute_for_measure("key_for_test_only", 0, std::chrono::system_clock::now());
  38. }
  39. int main(int argc,char* argv[])
  40. {
  41. Error_manager t_error;
  42. Error_manager t_result ;
  43. const char* logPath = "./log/";
  44. google::InitGoogleLogging("LidarMeasurement");
  45. google::SetStderrLogging(google::INFO);
  46. google::SetLogDestination(0, logPath);
  47. google::SetLogFilenameExtension("zxlog");
  48. google::InstallFailureSignalHandler();
  49. google::InstallFailureWriter(&shut_down_logging);
  50. FLAGS_colorlogtostderr = true; // Set log color
  51. FLAGS_logbufsecs = 0; // Set log output speed(s)
  52. FLAGS_max_log_size = 1024; // Set max log file size(GB)
  53. FLAGS_stop_logging_if_full_disk = true;
  54. // std::cout << " huli test :::: " << " wanji_manager_init = " << 1 << std::endl;
  55. // 定义服务的终端id
  56. int t_terminal_id = 0;
  57. if ( argc == 2 )
  58. {
  59. std::cout << " huli test :::: " << " argv[1] = " << argv[1] << std::endl;
  60. t_terminal_id = atoi(argv[1]);
  61. }
  62. std::cout << " huli test :::: " << " t_terminal_id = " << t_terminal_id << std::endl;
  63. // 初始化
  64. // Wanji_manager::get_instance_references().wanji_manager_init();
  65. // std::cout << "wanji_manager = " << Wanji_manager::get_instance_references().check_status().to_string() << std::endl;
  66. Error_manager ec = Velodyne_manager::get_instance_references().velodyne_manager_init(t_terminal_id);
  67. std::cout << "veodyne_manager = " << Velodyne_manager::get_instance_references().check_status().to_string() << std::endl;
  68. if(ec != SUCCESS)
  69. {
  70. LOG(ERROR) << "velodyne_manager init failed: " << ec.to_string();
  71. return -1;
  72. }
  73. ec = System_executor::get_instance_references().system_executor_init(4, t_terminal_id);
  74. std::cout << "System_executor = " << System_executor::get_instance_references().get_system_executor_status() << std::endl;
  75. if(ec != SUCCESS)
  76. {
  77. LOG(ERROR) << "system executor init failed: " << ec.to_string();
  78. return -1;
  79. }
  80. usleep(1000 * 500);
  81. ec = System_communication::get_instance_references().communication_init();
  82. if(ec != SUCCESS)
  83. {
  84. LOG(ERROR) << "system communication init failed: " << ec.to_string();
  85. return -1;
  86. }
  87. System_communication::get_instance_references().set_encapsulate_cycle_time(110);
  88. // prev_test_pred_task();
  89. // test_whole_process();
  90. // usleep(1000*5000);
  91. char ch='x' ;
  92. while(ch != 'q') {
  93. std::cout<<"please input q to quit system."<<std::endl;
  94. std::cin >> ch;
  95. }
  96. // 反初始化
  97. System_communication::get_instance_references().communication_uninit();
  98. System_executor::get_instance_references().system_executor_uninit();
  99. // Wanji_manager::get_instance_references().wanji_manager_uninit();
  100. Velodyne_manager::get_instance_references().Velodyne_manager_uninit();
  101. return 0;
  102. }