main.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. //
  3. // 20210425, hl_dispatch 和 hl_dispatch_B的版本进行同步, 此时调度管理的功能全部完成.后续可能还需要日志记录.
  4. //
  5. #include <iostream>
  6. #include "./error_code/error_code.h"
  7. //#include "LogFiles.h"
  8. #include <glog/logging.h>
  9. #include "./communication/communication_socket_base.h"
  10. #include "./tool/thread_pool.h"
  11. #include "./system/system_communication.h"
  12. #include "./system/system_executor.h"
  13. #include "./tool/common_data.h"
  14. #include <algorithm> // std::for_each
  15. GOOGLE_GLOG_DLL_DECL void shut_down_logging(const char* data, int size)
  16. {
  17. time_t tt;
  18. time( &tt );
  19. tt = tt + 8*3600; // transform the time zone
  20. tm* t= gmtime( &tt );
  21. char buf[255]={0};
  22. sprintf(buf,"./%d%02d%02d-%02d%02d%02d-dump.txt",
  23. t->tm_year + 1900,
  24. t->tm_mon + 1,
  25. t->tm_mday,
  26. t->tm_hour,
  27. t->tm_min,
  28. t->tm_sec);
  29. FILE* tp_file=fopen(buf,"w");
  30. fprintf(tp_file,data,strlen(data));
  31. fclose(tp_file);
  32. }
  33. #include <chrono>
  34. using namespace std;
  35. int main(int argc,char* argv[])
  36. {
  37. int t_id = 0;
  38. if ( argc == 2 )
  39. {
  40. t_id = stoi(argv[1]);
  41. }
  42. Error_manager t_error;
  43. const char* logPath = "./";
  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. //#define MAIN_TEST 1
  55. #ifdef MAIN_TEST
  56. System_executor::get_instance_references().system_executor_init(10);
  57. System_communication::get_instance_references().communication_init();
  58. System_communication::get_instance_references().set_encapsulate_cycle_time(1000);
  59. while (1)
  60. {
  61. std::string test_string;
  62. std::cin >> test_string ;
  63. if ( test_string == "9" )
  64. {
  65. }
  66. std::this_thread::sleep_for(std::chrono::seconds(1));
  67. }
  68. return 0;
  69. #endif
  70. return 0;
  71. }