main.cpp 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. //
  2. // huli test 20200223
  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 "./dispatch/dispatch_manager.h"
  13. #include "./dispatch/dispatch_communication.h"
  14. #include <algorithm> // std::for_each
  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. #include <chrono>
  35. using namespace std;
  36. void myfunction (int i) { // function:
  37. std::cout << ' ' << i;
  38. }
  39. class AAA
  40. {
  41. public:
  42. int a;
  43. };
  44. class BBB:public AAA
  45. {
  46. public:
  47. int b;
  48. };
  49. class CCC:public AAA
  50. {
  51. public:
  52. int c;
  53. };
  54. int main(int argc,char* argv[])
  55. {
  56. const char* logPath = "./";
  57. google::InitGoogleLogging("LidarMeasurement");
  58. google::SetStderrLogging(google::INFO);
  59. google::SetLogDestination(0, logPath);
  60. google::SetLogFilenameExtension("zxlog");
  61. google::InstallFailureSignalHandler();
  62. google::InstallFailureWriter(&shut_down_logging);
  63. FLAGS_colorlogtostderr = true; // Set log color
  64. FLAGS_logbufsecs = 0; // Set log output speed(s)
  65. FLAGS_max_log_size = 1024; // Set max log file size(GB)
  66. FLAGS_stop_logging_if_full_disk = true;
  67. Error_manager t_error;
  68. t_error = Dispatch_communication::get_instance_references().communication_init();
  69. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  70. std::cout << "Dispatch_communication = " << Dispatch_communication::get_instance_references().get_status() << std::endl;
  71. std::this_thread::sleep_for(std::chrono::seconds(2));
  72. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  73. std::cout << "Dispatch_communication = " << Dispatch_communication::get_instance_references().get_status() << std::endl;
  74. std::cout << " ---------------------------------------------------" << std::endl;
  75. std::cout << " ---------------------------------------------------" << std::endl;
  76. Catcher t_catcher;
  77. t_error = t_catcher.dispatch_device_base_init(1);
  78. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  79. std::this_thread::sleep_for(std::chrono::seconds(2));
  80. std::shared_ptr<Task_Base> tp_task_Base(new Catcher_task);
  81. Catcher_task * tp_catcher_task = (Catcher_task *)tp_task_Base.get();
  82. tp_catcher_task->task_init(NULL,std::chrono::milliseconds(15000));
  83. tp_catcher_task->m_request_key = "ABCDEF";
  84. tp_catcher_task->m_request_x = 123;
  85. tp_catcher_task->m_request_y = 456;
  86. tp_catcher_task->m_request_b = 80;
  87. tp_catcher_task->m_request_z = 789;
  88. tp_catcher_task->m_request_d1 = 333;
  89. tp_catcher_task->m_request_d2 = 444;
  90. tp_catcher_task->m_request_wheelbase = 555;
  91. tp_catcher_task->m_request_clamp_motion = Catcher_task::E_CLAMP_LOOSE;
  92. t_error = t_catcher.execute_task(tp_task_Base, Dispatch_device_base::E_ONE_LEVEL);
  93. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  94. std::cout << " ---------------------------------------------------" << std::endl;
  95. char zxczxcxzc ;
  96. std::cin >> zxczxcxzc ;
  97. while ( 1 )
  98. {
  99. std::cout << " huli test :::: " << " ===================================== " << std::endl;
  100. std::cout << " huli test :::: " << " tp_catcher_task->get_task_statu = " << tp_catcher_task->get_task_statu() << std::endl;
  101. std::cout << " huli test :::: " << " tp_catcher_task->m_respons_status = " << tp_catcher_task->m_respons_status << std::endl;
  102. std::cout << " huli test :::: " << " m_respons_key = " << tp_catcher_task->m_respons_key << std::endl;
  103. std::cout << " huli test :::: " << " m_respons_status = " << tp_catcher_task->m_respons_status << std::endl;
  104. std::cout << " huli test :::: " << " m_respons_x = " << tp_catcher_task->m_respons_x << std::endl;
  105. std::cout << " huli test :::: " << " m_respons_y = " << tp_catcher_task->m_respons_y << std::endl;
  106. std::cout << " huli test :::: " << " m_respons_b = " << tp_catcher_task->m_respons_b << std::endl;
  107. std::cout << " huli test :::: " << " m_respons_z = " << tp_catcher_task->m_respons_z << std::endl;
  108. std::cout << " huli test :::: " << " m_respons_d1 = " << tp_catcher_task->m_respons_d1 << std::endl;
  109. std::cout << " huli test :::: " << " m_respons_d2 = " << tp_catcher_task->m_respons_d2 << std::endl;
  110. std::cout << " huli test :::: " << " m_respons_wheelbase = " << tp_catcher_task->m_respons_wheelbase << std::endl;
  111. std::cout << " huli test :::: " << " m_respons_clamp_motion = " << tp_catcher_task->m_respons_clamp_motion << std::endl;
  112. std::cout << " huli test :::: " << " t_carrier_base.get_carrier_status() = " << t_catcher.get_dispatch_device_status() << std::endl;
  113. std::cout << " huli test :::: " << " t_carrier_base.get_carrier_status() = " << t_catcher.get_actual_device_status() << std::endl;
  114. std::cout << " ---------------------------------------------------" << std::endl;
  115. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  116. }
  117. Catcher t_catcher;
  118. t_error = t_catcher.dispatch_device_base_init(1);
  119. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  120. std::this_thread::sleep_for(std::chrono::seconds(2));
  121. std::shared_ptr<Task_Base> tp_task_Base(new Catcher_task);
  122. Catcher_task * tp_catcher_task = (Catcher_task *)tp_task_Base.get();
  123. tp_catcher_task->task_init(NULL,std::chrono::milliseconds(15000));
  124. tp_catcher_task->m_request_key = "ABCDEF";
  125. tp_catcher_task->m_request_x = 123;
  126. tp_catcher_task->m_request_y = 456;
  127. tp_catcher_task->m_request_b = 80;
  128. tp_catcher_task->m_request_z = 789;
  129. tp_catcher_task->m_request_d1 = 333;
  130. tp_catcher_task->m_request_d2 = 444;
  131. tp_catcher_task->m_request_wheelbase = 555;
  132. tp_catcher_task->m_request_clamp_motion = Catcher_task::E_CLAMP_LOOSE;
  133. t_error = t_catcher.execute_task(tp_task_Base, Dispatch_device_base::E_ONE_LEVEL);
  134. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  135. std::cout << " ---------------------------------------------------" << std::endl;
  136. char zxczxcxzc ;
  137. std::cin >> zxczxcxzc ;
  138. while ( 1 )
  139. {
  140. std::cout << " huli test :::: " << " ===================================== " << std::endl;
  141. std::cout << " huli test :::: " << " tp_catcher_task->get_task_statu = " << tp_catcher_task->get_task_statu() << std::endl;
  142. std::cout << " huli test :::: " << " tp_catcher_task->m_respons_status = " << tp_catcher_task->m_respons_status << std::endl;
  143. std::cout << " huli test :::: " << " m_respons_key = " << tp_catcher_task->m_respons_key << std::endl;
  144. std::cout << " huli test :::: " << " m_respons_status = " << tp_catcher_task->m_respons_status << std::endl;
  145. std::cout << " huli test :::: " << " m_respons_x = " << tp_catcher_task->m_respons_x << std::endl;
  146. std::cout << " huli test :::: " << " m_respons_y = " << tp_catcher_task->m_respons_y << std::endl;
  147. std::cout << " huli test :::: " << " m_respons_b = " << tp_catcher_task->m_respons_b << std::endl;
  148. std::cout << " huli test :::: " << " m_respons_z = " << tp_catcher_task->m_respons_z << std::endl;
  149. std::cout << " huli test :::: " << " m_respons_d1 = " << tp_catcher_task->m_respons_d1 << std::endl;
  150. std::cout << " huli test :::: " << " m_respons_d2 = " << tp_catcher_task->m_respons_d2 << std::endl;
  151. std::cout << " huli test :::: " << " m_respons_wheelbase = " << tp_catcher_task->m_respons_wheelbase << std::endl;
  152. std::cout << " huli test :::: " << " m_respons_clamp_motion = " << tp_catcher_task->m_respons_clamp_motion << std::endl;
  153. std::cout << " huli test :::: " << " t_carrier_base.get_carrier_status() = " << t_catcher.get_dispatch_device_status() << std::endl;
  154. std::cout << " huli test :::: " << " t_carrier_base.get_carrier_status() = " << t_catcher.get_actual_device_status() << std::endl;
  155. std::cout << " ---------------------------------------------------" << std::endl;
  156. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  157. }
  158. char ch123 ;
  159. std::cin >> ch123 ;
  160. Dispatch_communication::get_instance_references().communication_uninit();
  161. return 0;
  162. int t_dispatch_id = 0;
  163. // std::cin >> t_dispatch_id ;
  164. if ( argc == 2 )
  165. {
  166. std::cout << " huli test :::: " << " argv[1] = " << argv[1] << std::endl;
  167. t_dispatch_id = atoi(argv[1]);
  168. }
  169. std::cout << " huli test :::: " << " t_dispatch_id = " << t_dispatch_id << std::endl;
  170. Dispatch_manager::get_instance_references().dispatch_manager_init(t_dispatch_id);
  171. std::cout << "Dispatch_manager = " << Dispatch_manager::get_instance_references().get_dispatch_manager_status() << std::endl;
  172. System_executor::get_instance_references().system_executor_init(8);
  173. std::cout << "System_executor = " << System_executor::get_instance_references().get_system_executor_status() << std::endl;
  174. System_communication::get_instance_references().communication_init();
  175. char ch ;
  176. std::cin >> ch ;
  177. System_communication::get_instance_references().communication_uninit();
  178. System_executor::get_instance_references().system_executor_uninit();
  179. Dispatch_manager::get_instance_references().dispatch_manager_uninit();
  180. return 0;
  181. }