main.cpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // Created by zx on 2020/6/18.
  3. //
  4. #include <iostream>
  5. #include "./error_code/error_code.h"
  6. #include "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. #define LIVOX_NUMBER 2
  16. GOOGLE_GLOG_DLL_DECL void shut_down_logging(const char* data, int size)
  17. {
  18. time_t tt;
  19. time( &tt );
  20. tt = tt + 8*3600; // transform the time zone
  21. tm* t= gmtime( &tt );
  22. char buf[255]={0};
  23. sprintf(buf,"./%d%02d%02d-%02d%02d%02d-dump.txt",
  24. t->tm_year + 1900,
  25. t->tm_mon + 1,
  26. t->tm_mday,
  27. t->tm_hour,
  28. t->tm_min,
  29. t->tm_sec);
  30. FILE* tp_file=fopen(buf,"w");
  31. fprintf(tp_file,data,strlen(data));
  32. fclose(tp_file);
  33. }
  34. void test_whole_process()
  35. {
  36. System_executor::get_instance_references().execute_for_measure("key_for_test_only", 5, std::chrono::system_clock::now());
  37. }
  38. int main(int argc,char* argv[])
  39. {
  40. Error_manager t_error;
  41. Error_manager t_result ;
  42. const char* logPath = "./";
  43. google::InitGoogleLogging("LidarMeasurement");
  44. google::SetStderrLogging(google::INFO);
  45. google::SetLogDestination(0, logPath);
  46. google::SetLogFilenameExtension("zxlog");
  47. google::InstallFailureSignalHandler();
  48. google::InstallFailureWriter(&shut_down_logging);
  49. FLAGS_colorlogtostderr = true; // Set log color
  50. FLAGS_logbufsecs = 0; // Set log output speed(s)
  51. FLAGS_max_log_size = 1024; // Set max log file size(GB)
  52. FLAGS_stop_logging_if_full_disk = true;
  53. // std::cout << " huli test :::: " << " wanji_manager_init = " << 1 << std::endl;
  54. // 定义服务的终端id
  55. int t_terminal_id = 0;
  56. if ( argc == 2 )
  57. {
  58. std::cout << " huli test :::: " << " argv[1] = " << argv[1] << std::endl;
  59. t_terminal_id = atoi(argv[1]);
  60. }
  61. std::cout << " huli test :::: " << " t_terminal_id = " << t_terminal_id << std::endl;
  62. // 初始化
  63. Wanji_manager::get_instance_references().wanji_manager_init();
  64. std::cout << "wanji_manager = " << Wanji_manager::get_instance_references().check_status() << std::endl;
  65. System_executor::get_instance_references().system_executor_init(4, t_terminal_id);
  66. std::cout << "System_executor = " << System_executor::get_instance_references().get_system_executor_status() << std::endl;
  67. System_communication::get_instance_references().communication_init();
  68. // prev_test_pred_task();
  69. test_whole_process();
  70. // 反初始化
  71. System_communication::get_instance_references().communication_uninit();
  72. System_executor::get_instance_references().system_executor_uninit();
  73. return 0;
  74. }