main.cpp 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  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 "./dispatch/dispatch_manager.h"
  14. #include "./dispatch/dispatch_communication.h"
  15. #include "./dispatch/dispatch_coordinates.h"
  16. #include "./tool/common_data.h"
  17. #include <algorithm> // std::for_each
  18. #define LIVOX_NUMBER 2
  19. GOOGLE_GLOG_DLL_DECL void shut_down_logging(const char* data, int size)
  20. {
  21. time_t tt;
  22. time( &tt );
  23. tt = tt + 8*3600; // transform the time zone
  24. tm* t= gmtime( &tt );
  25. char buf[255]={0};
  26. sprintf(buf,"./%d%02d%02d-%02d%02d%02d-dump.txt",
  27. t->tm_year + 1900,
  28. t->tm_mon + 1,
  29. t->tm_mday,
  30. t->tm_hour,
  31. t->tm_min,
  32. t->tm_sec);
  33. FILE* tp_file=fopen(buf,"w");
  34. fprintf(tp_file,data,strlen(data));
  35. fclose(tp_file);
  36. }
  37. #include <chrono>
  38. using namespace std;
  39. class AAA
  40. {
  41. public:
  42. int a;
  43. };
  44. class BBB:public AAA
  45. {
  46. public:
  47. int b;
  48. };
  49. int main(int argc,char* argv[])
  50. {
  51. // std::shared_ptr<AAA> aaa(new BBB);
  52. // aaa->a = 10;
  53. // std::cout << " huli test :::: " << " aaa.size() = " << aaa.use_count()<< std::endl;
  54. // std::cout << " huli test :::: " << " aaa->a = " << aaa->a<< std::endl;
  55. //
  56. // BBB* bbb = (BBB*)aaa.get();
  57. //
  58. //
  59. // return 0;
  60. Error_manager t_error;
  61. const char* logPath = "./";
  62. google::InitGoogleLogging("LidarMeasurement");
  63. google::SetStderrLogging(google::INFO);
  64. google::SetLogDestination(0, logPath);
  65. google::SetLogFilenameExtension("zxlog");
  66. google::InstallFailureSignalHandler();
  67. google::InstallFailureWriter(&shut_down_logging);
  68. FLAGS_colorlogtostderr = true; // Set log color
  69. FLAGS_logbufsecs = 0; // Set log output speed(s)
  70. FLAGS_max_log_size = 1024; // Set max log file size(GB)
  71. FLAGS_stop_logging_if_full_disk = true;
  72. //#define MAIN_TEST 1
  73. #ifdef MAIN_TEST
  74. t_error = Dispatch_coordinates::get_instance_references().dispatch_coordinates_init();
  75. std::cout << " huli test :::: " << " Dispatch_coordinates::get_instance_references().dispatch_coordinates_init() = " << t_error.to_string() << std::endl;
  76. t_error = Dispatch_communication::get_instance_references().communication_init();
  77. std::cout << " huli test :::: " << " Dispatch_communication::get_instance_references().communication_init() = " << t_error.to_string() << std::endl;
  78. std::cout << "Dispatch_communication = " << Dispatch_communication::get_instance_references().get_status() << std::endl;
  79. t_error = Dispatch_manager::get_instance_references().dispatch_manager_init(0);
  80. std::cout << " huli test :::: " << " Dispatch_manager::get_instance_references().dispatch_manager_init(0) = " << t_error.to_string() << std::endl;
  81. std::cout << "Dispatch_manager = " << Dispatch_manager::get_instance_references().get_dispatch_manager_status() << std::endl;
  82. System_executor::get_instance_references().system_executor_init(10);
  83. std::cout << "System_executor = " << System_executor::get_instance_references().get_system_executor_status() << std::endl;
  84. System_communication::get_instance_references().communication_init();
  85. System_communication::get_instance_references().set_encapsulate_cycle_time(1000);
  86. while (1)
  87. {
  88. // Dispatch_manager::space_device** tpp = Dispatch_manager::get_instance_references().mpp_space_lock;
  89. // for (int i = 0; i < 11; ++i)
  90. // {
  91. // for (int j = 0; j < 15; ++j)
  92. // {
  93. // if ( tpp[i][j].m_catcher_id != -1 )
  94. // {
  95. // std::cout << " huli test :::: " << " tpp[i][j].m_catcher_id = " << tpp[i][j].m_catcher_id << std::endl;
  96. // std::cout << " huli test :::: " << " i = " << i << std::endl;
  97. // std::cout << " huli test :::: " << " j = " << j << std::endl;
  98. // }
  99. // if ( tpp[i][j].m_carrier_id != -1 )
  100. // {
  101. // std::cout << " huli test :::: " << " tpp[i][j].m_carrier_id = " << tpp[i][j].m_carrier_id << std::endl;
  102. // std::cout << " huli test :::: " << " i = " << i << std::endl;
  103. // std::cout << " huli test :::: " << " j = " << j << std::endl;
  104. // }
  105. // }
  106. // }
  107. std::this_thread::sleep_for(std::chrono::seconds(1));
  108. }
  109. return 0;
  110. #endif
  111. // Error_manager t_error;
  112. t_error = Dispatch_communication::get_instance_references().communication_init();
  113. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  114. std::cout << "Dispatch_communication = " << Dispatch_communication::get_instance_references().get_status() << std::endl;
  115. std::this_thread::sleep_for(std::chrono::seconds(2));
  116. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  117. std::cout << "Dispatch_communication = " << Dispatch_communication::get_instance_references().get_status() << std::endl;
  118. std::cout << " ---------------------------------------------------" << std::endl;
  119. std::cout << " ---------------------------------------------------" << std::endl;
  120. Catcher t_catcher;
  121. t_error = t_catcher.dispatch_device_base_init(1, 102);
  122. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  123. std::this_thread::sleep_for(std::chrono::seconds(2));
  124. std::shared_ptr<Task_Base> tp_task_Base1(new Catcher_task);
  125. Catcher_task * tp_catcher_task1 = (Catcher_task *)tp_task_Base1.get();
  126. tp_catcher_task1->task_init(NULL,std::chrono::milliseconds(15000));
  127. tp_catcher_task1->m_request_key = "x23456789012345678901234567890r1";
  128. tp_catcher_task1->m_request_x = 24855;
  129. tp_catcher_task1->m_request_y = 3000;
  130. tp_catcher_task1->m_request_b = 90;
  131. tp_catcher_task1->m_request_z = 5410;
  132. tp_catcher_task1->m_request_d1 = 355;
  133. tp_catcher_task1->m_request_d2 = 455;
  134. tp_catcher_task1->m_request_wheelbase = 2800;
  135. tp_catcher_task1->m_request_clamp_motion = Catcher_task::E_CLAMP_LOOSE;
  136. t_error = t_catcher.execute_task(tp_task_Base1, Dispatch_device_base::DISPATCH_TASK_ONE_LEVEL);
  137. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  138. std::cout << " ---------------------------------------------------" << std::endl;
  139. /*
  140. char zxczxcxzc1 ;
  141. std::cin >> zxczxcxzc1 ;
  142. while ( 1 )
  143. {
  144. std::cout << " huli test :::: " << " ===================================== " << std::endl;
  145. std::cout << " huli test :::: " << " tp_catcher_task->get_task_statu = " << tp_catcher_task->get_task_statu() << std::endl;
  146. std::cout << " huli test :::: " << " tp_catcher_task->m_respons_status = " << tp_catcher_task->m_respons_status << std::endl;
  147. std::cout << " huli test :::: " << " m_respons_key = " << tp_catcher_task->m_respons_key << std::endl;
  148. std::cout << " huli test :::: " << " m_respons_status = " << tp_catcher_task->m_respons_status << std::endl;
  149. std::cout << " huli test :::: " << " m_respons_x = " << tp_catcher_task->m_respons_x << std::endl;
  150. std::cout << " huli test :::: " << " m_respons_y = " << tp_catcher_task->m_respons_y << std::endl;
  151. std::cout << " huli test :::: " << " m_respons_b = " << tp_catcher_task->m_respons_b << std::endl;
  152. std::cout << " huli test :::: " << " m_respons_z = " << tp_catcher_task->m_respons_z << std::endl;
  153. std::cout << " huli test :::: " << " m_respons_d1 = " << tp_catcher_task->m_respons_d1 << std::endl;
  154. std::cout << " huli test :::: " << " m_respons_d2 = " << tp_catcher_task->m_respons_d2 << std::endl;
  155. std::cout << " huli test :::: " << " m_respons_wheelbase = " << tp_catcher_task->m_respons_wheelbase << std::endl;
  156. std::cout << " huli test :::: " << " m_respons_clamp_motion = " << tp_catcher_task->m_respons_clamp_motion << std::endl;
  157. std::cout << " ---------------------------------------------------" << std::endl;
  158. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  159. std::cout << " huli test :::: " << " t_carrier_base.get_carrier_status() = " << t_catcher.get_dispatch_device_status() << std::endl;
  160. int heat = t_catcher.m_last_heartbeat;
  161. std::cout << " huli test :::: " << " m_last_heartbeat = " << heat << std::endl;
  162. std::cout << " huli test :::: " << " m_actual_device_status = " << t_catcher.m_actual_device_status << std::endl;
  163. std::cout << " huli test :::: " << " m_actual_load_status = " << t_catcher.m_actual_load_status << std::endl;
  164. std::cout << " huli test :::: " << " m_actual_x = " << t_catcher.m_actual_x << std::endl;
  165. std::cout << " huli test :::: " << " m_actual_y = " << t_catcher.m_actual_y << std::endl;
  166. std::cout << " huli test :::: " << " m_actual_b = " << t_catcher.m_actual_b << std::endl;
  167. std::cout << " huli test :::: " << " m_actual_z = " << t_catcher.m_actual_z << std::endl;
  168. std::cout << " huli test :::: " << " m_actual_d1 = " << t_catcher.m_actual_d1 << std::endl;
  169. std::cout << " huli test :::: " << " m_actual_d2 = " << t_catcher.m_actual_d2 << std::endl;
  170. std::cout << " huli test :::: " << " m_actual_clamp_motion1 = " << t_catcher.m_actual_clamp_motion1 << std::endl;
  171. std::cout << " huli test :::: " << " m_actual_clamp_motion2 = " << t_catcher.m_actual_clamp_motion2 << std::endl;
  172. std::cout << " huli test :::: " << " m_actual_clamp_motion3 = " << t_catcher.m_actual_clamp_motion3 << std::endl;
  173. std::cout << " huli test :::: " << " m_actual_clamp_motion4 = " << t_catcher.m_actual_clamp_motion4 << std::endl;
  174. std::cout << " huli test :::: " << " m_actual_error_code = " << std::endl;
  175. for (int i = 0; i < 50; ++i)
  176. {
  177. printf("0x%x ", t_catcher.m_actual_error_code[i]);
  178. }
  179. std::cout << std::endl;
  180. std::cout << " huli test :::: " << " m_actual_warning_code = " << std::endl;
  181. for (int i = 0; i < 50; ++i)
  182. {
  183. printf("0x%x ", t_catcher.m_actual_warning_code[i]);
  184. }
  185. std::cout << std::endl;
  186. std::cout << " huli test :::: " << " m_actual_error_description = " << t_catcher.m_actual_error_description << std::endl;
  187. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  188. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  189. }
  190. */
  191. Carrier t_carrier20;
  192. t_error = t_carrier20.dispatch_device_base_init(0, 200);
  193. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  194. std::this_thread::sleep_for(std::chrono::seconds(2));
  195. std::shared_ptr<Task_Base> tp_task_Base20(new Carrier_task);
  196. Carrier_task * tp_carrier_task20 = (Carrier_task *)tp_task_Base20.get();
  197. tp_carrier_task20->task_init(NULL,std::chrono::milliseconds(15000));
  198. tp_carrier_task20->m_request_key = "x23456789012345678901234567890c0";
  199. tp_carrier_task20->m_request_x = 1;
  200. // tp_carrier_task20->m_request_x = 32600;
  201. tp_carrier_task20->m_request_y = 3000;
  202. tp_carrier_task20->m_request_z = 2525;
  203. tp_carrier_task20->m_request_y1 = 4500;
  204. tp_carrier_task20->m_request_y2 = 1700;
  205. tp_carrier_task20->m_request_clamp_motion = Carrier_task::E_CLAMP_LOOSE;
  206. tp_carrier_task20->m_request_joint_motion_x = Carrier_task::E_JOINT_HOLD_OUT;
  207. tp_carrier_task20->m_request_joint_motion_y = Carrier_task::E_JOINT_HOLD_OUT;
  208. tp_carrier_task20->m_request_space_id = 555;
  209. tp_carrier_task20->m_request_floor_id = 555;
  210. tp_carrier_task20->m_request_wheelbase = 555;
  211. t_error = t_carrier20.execute_task(tp_task_Base20, Dispatch_device_base::DISPATCH_TASK_ONE_LEVEL);
  212. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  213. std::cout << " ---------------------------------------------------" << std::endl;
  214. /*
  215. char zxczxcxzc20 ;
  216. std::cin >> zxczxcxzc20 ;
  217. while ( 1 )
  218. {
  219. std::cout << " huli test :::: " << " ===================================== " << std::endl;
  220. std::cout << " huli test :::: " << " tp_carrier_task->get_task_statu = " << tp_carrier_task->get_task_statu() << std::endl;
  221. std::cout << " huli test :::: " << " tp_carrier_task->m_respons_status = " << tp_carrier_task->m_respons_status << std::endl;
  222. std::cout << " huli test :::: " << " m_respons_key = " << tp_carrier_task->m_respons_key << std::endl;
  223. std::cout << " huli test :::: " << " m_respons_status = " << tp_carrier_task->m_respons_status << std::endl;
  224. std::cout << " huli test :::: " << " m_respons_x = " << tp_carrier_task->m_respons_x << std::endl;
  225. std::cout << " huli test :::: " << " m_respons_y = " << tp_carrier_task->m_respons_y << std::endl;
  226. std::cout << " huli test :::: " << " m_respons_z = " << tp_carrier_task->m_respons_z << std::endl;
  227. std::cout << " huli test :::: " << " m_respons_y1 = " << tp_carrier_task->m_respons_y1 << std::endl;
  228. std::cout << " huli test :::: " << " m_respons_y2 = " << tp_carrier_task->m_respons_y2 << std::endl;
  229. std::cout << " huli test :::: " << " m_respons_clamp_motion = " << tp_carrier_task->m_respons_clamp_motion << std::endl;
  230. std::cout << " huli test :::: " << " m_respons_joint_motion_x = " << tp_carrier_task->m_respons_joint_motion_x << std::endl;
  231. std::cout << " huli test :::: " << " m_respons_joint_motion_y = " << tp_carrier_task->m_respons_joint_motion_y << std::endl;
  232. std::cout << " huli test :::: " << " m_respons_space_id = " << tp_carrier_task->m_respons_space_id << std::endl;
  233. std::cout << " huli test :::: " << " m_respons_floor_id = " << tp_carrier_task->m_respons_floor_id << std::endl;
  234. std::cout << " huli test :::: " << " m_respons_wheelbase = " << tp_carrier_task->m_respons_wheelbase << std::endl;
  235. std::cout << " ---------------------------------------------------" << std::endl;
  236. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  237. std::cout << " huli test :::: " << " t_carrier_base.get_carrier_status() = " << t_carrier.get_dispatch_device_status() << std::endl;
  238. int heat = t_carrier.m_last_heartbeat;
  239. std::cout << " huli test :::: " << " m_last_heartbeat = " << heat << std::endl;
  240. std::cout << " huli test :::: " << " m_actual_device_status = " << t_carrier.m_actual_device_status << std::endl;
  241. std::cout << " huli test :::: " << " m_actual_load_status = " << t_carrier.m_actual_load_status << std::endl;
  242. std::cout << " huli test :::: " << " m_actual_x = " << t_carrier.m_actual_x << std::endl;
  243. std::cout << " huli test :::: " << " m_actual_y = " << t_carrier.m_actual_y << std::endl;
  244. std::cout << " huli test :::: " << " m_actual_z = " << t_carrier.m_actual_z << std::endl;
  245. std::cout << " huli test :::: " << " m_actual_y1 = " << t_carrier.m_actual_y1 << std::endl;
  246. std::cout << " huli test :::: " << " m_actual_y2 = " << t_carrier.m_actual_y2 << std::endl;
  247. std::cout << " huli test :::: " << " m_actual_clamp_motion1 = " << t_carrier.m_actual_clamp_motion1 << std::endl;
  248. std::cout << " huli test :::: " << " m_actual_clamp_motion2 = " << t_carrier.m_actual_clamp_motion2 << std::endl;
  249. std::cout << " huli test :::: " << " m_actual_small_sports_car_motion = " << t_carrier.m_actual_small_sports_car_motion << std::endl;
  250. std::cout << " huli test :::: " << " m_actual_joint_motion_x1 = " << t_carrier.m_actual_joint_motion_x1 << std::endl;
  251. std::cout << " huli test :::: " << " m_actual_joint_motion_x2 = " << t_carrier.m_actual_joint_motion_x2 << std::endl;
  252. std::cout << " huli test :::: " << " m_actual_error_code = " << std::endl;
  253. for (int i = 0; i < 50; ++i)
  254. {
  255. printf("0x%x ", t_carrier.m_actual_error_code[i]);
  256. }
  257. std::cout << std::endl;
  258. std::cout << " huli test :::: " << " m_actual_warning_code = " << std::endl;
  259. for (int i = 0; i < 50; ++i)
  260. {
  261. printf("0x%x ", t_carrier.m_actual_warning_code[i]);
  262. }
  263. std::cout << std::endl;
  264. std::cout << " huli test :::: " << " m_actual_error_description = " << t_carrier.m_actual_error_description << std::endl;
  265. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  266. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  267. }
  268. */
  269. Carrier t_carrier21;
  270. t_error = t_carrier21.dispatch_device_base_init(1, 207);
  271. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  272. std::this_thread::sleep_for(std::chrono::seconds(2));
  273. std::shared_ptr<Task_Base> tp_task_Base21(new Carrier_task);
  274. Carrier_task * tp_carrier_task21 = (Carrier_task *)tp_task_Base21.get();
  275. tp_carrier_task21->task_init(NULL,std::chrono::milliseconds(15000));
  276. tp_carrier_task21->m_request_key = "x23456789012345678901234567890c1";
  277. // tp_carrier_task21->m_request_x = 1;
  278. tp_carrier_task21->m_request_x = 32600;
  279. tp_carrier_task21->m_request_y = 3000;
  280. tp_carrier_task21->m_request_z = 2525;
  281. tp_carrier_task21->m_request_y1 = 4500;
  282. tp_carrier_task21->m_request_y2 = 1700;
  283. tp_carrier_task21->m_request_clamp_motion = Carrier_task::E_CLAMP_LOOSE;
  284. tp_carrier_task21->m_request_joint_motion_x = Carrier_task::E_JOINT_HOLD_OUT;
  285. tp_carrier_task21->m_request_joint_motion_y = Carrier_task::E_JOINT_HOLD_OUT;
  286. tp_carrier_task21->m_request_space_id = 555;
  287. tp_carrier_task21->m_request_floor_id = 555;
  288. tp_carrier_task21->m_request_wheelbase = 555;
  289. t_error = t_carrier21.execute_task(tp_task_Base21, Dispatch_device_base::DISPATCH_TASK_ONE_LEVEL);
  290. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  291. std::cout << " ---------------------------------------------------" << std::endl;
  292. /*
  293. char zxczxcxzc21 ;
  294. std::cin >> zxczxcxzc21 ;
  295. while ( 1 )
  296. {
  297. std::cout << " huli test :::: " << " ===================================== " << std::endl;
  298. std::cout << " huli test :::: " << " tp_carrier_task->get_task_statu = " << tp_carrier_task->get_task_statu() << std::endl;
  299. std::cout << " huli test :::: " << " tp_carrier_task->m_respons_status = " << tp_carrier_task->m_respons_status << std::endl;
  300. std::cout << " huli test :::: " << " m_respons_key = " << tp_carrier_task->m_respons_key << std::endl;
  301. std::cout << " huli test :::: " << " m_respons_status = " << tp_carrier_task->m_respons_status << std::endl;
  302. std::cout << " huli test :::: " << " m_respons_x = " << tp_carrier_task->m_respons_x << std::endl;
  303. std::cout << " huli test :::: " << " m_respons_y = " << tp_carrier_task->m_respons_y << std::endl;
  304. std::cout << " huli test :::: " << " m_respons_z = " << tp_carrier_task->m_respons_z << std::endl;
  305. std::cout << " huli test :::: " << " m_respons_y1 = " << tp_carrier_task->m_respons_y1 << std::endl;
  306. std::cout << " huli test :::: " << " m_respons_y2 = " << tp_carrier_task->m_respons_y2 << std::endl;
  307. std::cout << " huli test :::: " << " m_respons_clamp_motion = " << tp_carrier_task->m_respons_clamp_motion << std::endl;
  308. std::cout << " huli test :::: " << " m_respons_joint_motion_x = " << tp_carrier_task->m_respons_joint_motion_x << std::endl;
  309. std::cout << " huli test :::: " << " m_respons_joint_motion_y = " << tp_carrier_task->m_respons_joint_motion_y << std::endl;
  310. std::cout << " huli test :::: " << " m_respons_space_id = " << tp_carrier_task->m_respons_space_id << std::endl;
  311. std::cout << " huli test :::: " << " m_respons_floor_id = " << tp_carrier_task->m_respons_floor_id << std::endl;
  312. std::cout << " huli test :::: " << " m_respons_wheelbase = " << tp_carrier_task->m_respons_wheelbase << std::endl;
  313. std::cout << " ---------------------------------------------------" << std::endl;
  314. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  315. std::cout << " huli test :::: " << " t_carrier_base.get_carrier_status() = " << t_carrier.get_dispatch_device_status() << std::endl;
  316. int heat = t_carrier.m_last_heartbeat;
  317. std::cout << " huli test :::: " << " m_last_heartbeat = " << heat << std::endl;
  318. std::cout << " huli test :::: " << " m_actual_device_status = " << t_carrier.m_actual_device_status << std::endl;
  319. std::cout << " huli test :::: " << " m_actual_load_status = " << t_carrier.m_actual_load_status << std::endl;
  320. std::cout << " huli test :::: " << " m_actual_x = " << t_carrier.m_actual_x << std::endl;
  321. std::cout << " huli test :::: " << " m_actual_y = " << t_carrier.m_actual_y << std::endl;
  322. std::cout << " huli test :::: " << " m_actual_z = " << t_carrier.m_actual_z << std::endl;
  323. std::cout << " huli test :::: " << " m_actual_y1 = " << t_carrier.m_actual_y1 << std::endl;
  324. std::cout << " huli test :::: " << " m_actual_y2 = " << t_carrier.m_actual_y2 << std::endl;
  325. std::cout << " huli test :::: " << " m_actual_clamp_motion1 = " << t_carrier.m_actual_clamp_motion1 << std::endl;
  326. std::cout << " huli test :::: " << " m_actual_clamp_motion2 = " << t_carrier.m_actual_clamp_motion2 << std::endl;
  327. std::cout << " huli test :::: " << " m_actual_small_sports_car_motion = " << t_carrier.m_actual_small_sports_car_motion << std::endl;
  328. std::cout << " huli test :::: " << " m_actual_joint_motion_x1 = " << t_carrier.m_actual_joint_motion_x1 << std::endl;
  329. std::cout << " huli test :::: " << " m_actual_joint_motion_x2 = " << t_carrier.m_actual_joint_motion_x2 << std::endl;
  330. std::cout << " huli test :::: " << " m_actual_error_code = " << std::endl;
  331. for (int i = 0; i < 50; ++i)
  332. {
  333. printf("0x%x ", t_carrier.m_actual_error_code[i]);
  334. }
  335. std::cout << std::endl;
  336. std::cout << " huli test :::: " << " m_actual_warning_code = " << std::endl;
  337. for (int i = 0; i < 50; ++i)
  338. {
  339. printf("0x%x ", t_carrier.m_actual_warning_code[i]);
  340. }
  341. std::cout << std::endl;
  342. std::cout << " huli test :::: " << " m_actual_error_description = " << t_carrier.m_actual_error_description << std::endl;
  343. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  344. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  345. }
  346. */
  347. Carrier t_carrier22;
  348. t_error = t_carrier22.dispatch_device_base_init(2, 203);
  349. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  350. std::this_thread::sleep_for(std::chrono::seconds(2));
  351. std::shared_ptr<Task_Base> tp_task_Base22(new Carrier_task);
  352. Carrier_task * tp_carrier_task22 = (Carrier_task *)tp_task_Base22.get();
  353. tp_carrier_task22->task_init(NULL,std::chrono::milliseconds(15000));
  354. tp_carrier_task22->m_request_key = "x23456789012345678901234567890c2";
  355. tp_carrier_task22->m_request_x = 24855;
  356. // tp_carrier_task22->m_request_x = 4700;
  357. tp_carrier_task22->m_request_y = 3000;
  358. tp_carrier_task22->m_request_z = 5125;
  359. tp_carrier_task22->m_request_y1 = 4500;
  360. tp_carrier_task22->m_request_y2 = 1700;
  361. tp_carrier_task22->m_request_clamp_motion = Carrier_task::E_CLAMP_LOOSE;
  362. tp_carrier_task22->m_request_joint_motion_x = Carrier_task::E_JOINT_HOLD_OUT;
  363. tp_carrier_task22->m_request_joint_motion_y = Carrier_task::E_JOINT_HOLD_OUT;
  364. tp_carrier_task22->m_request_space_id = 555;
  365. tp_carrier_task22->m_request_floor_id = 555;
  366. tp_carrier_task22->m_request_wheelbase = 555;
  367. t_error = t_carrier22.execute_task(tp_task_Base22, Dispatch_device_base::DISPATCH_TASK_ONE_LEVEL);
  368. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  369. std::cout << " ---------------------------------------------------" << std::endl;
  370. /*
  371. char zxczxcxzc22 ;
  372. std::cin >> zxczxcxzc22 ;
  373. while ( 1 )
  374. {
  375. std::cout << " huli test :::: " << " ===================================== " << std::endl;
  376. std::cout << " huli test :::: " << " tp_carrier_task->get_task_statu = " << tp_carrier_task->get_task_statu() << std::endl;
  377. std::cout << " huli test :::: " << " tp_carrier_task->m_respons_status = " << tp_carrier_task->m_respons_status << std::endl;
  378. std::cout << " huli test :::: " << " m_respons_key = " << tp_carrier_task->m_respons_key << std::endl;
  379. std::cout << " huli test :::: " << " m_respons_status = " << tp_carrier_task->m_respons_status << std::endl;
  380. std::cout << " huli test :::: " << " m_respons_x = " << tp_carrier_task->m_respons_x << std::endl;
  381. std::cout << " huli test :::: " << " m_respons_y = " << tp_carrier_task->m_respons_y << std::endl;
  382. std::cout << " huli test :::: " << " m_respons_z = " << tp_carrier_task->m_respons_z << std::endl;
  383. std::cout << " huli test :::: " << " m_respons_y1 = " << tp_carrier_task->m_respons_y1 << std::endl;
  384. std::cout << " huli test :::: " << " m_respons_y2 = " << tp_carrier_task->m_respons_y2 << std::endl;
  385. std::cout << " huli test :::: " << " m_respons_clamp_motion = " << tp_carrier_task->m_respons_clamp_motion << std::endl;
  386. std::cout << " huli test :::: " << " m_respons_joint_motion_x = " << tp_carrier_task->m_respons_joint_motion_x << std::endl;
  387. std::cout << " huli test :::: " << " m_respons_joint_motion_y = " << tp_carrier_task->m_respons_joint_motion_y << std::endl;
  388. std::cout << " huli test :::: " << " m_respons_space_id = " << tp_carrier_task->m_respons_space_id << std::endl;
  389. std::cout << " huli test :::: " << " m_respons_floor_id = " << tp_carrier_task->m_respons_floor_id << std::endl;
  390. std::cout << " huli test :::: " << " m_respons_wheelbase = " << tp_carrier_task->m_respons_wheelbase << std::endl;
  391. std::cout << " ---------------------------------------------------" << std::endl;
  392. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  393. std::cout << " huli test :::: " << " t_carrier_base.get_carrier_status() = " << t_carrier.get_dispatch_device_status() << std::endl;
  394. int heat = t_carrier.m_last_heartbeat;
  395. std::cout << " huli test :::: " << " m_last_heartbeat = " << heat << std::endl;
  396. std::cout << " huli test :::: " << " m_actual_device_status = " << t_carrier.m_actual_device_status << std::endl;
  397. std::cout << " huli test :::: " << " m_actual_load_status = " << t_carrier.m_actual_load_status << std::endl;
  398. std::cout << " huli test :::: " << " m_actual_x = " << t_carrier.m_actual_x << std::endl;
  399. std::cout << " huli test :::: " << " m_actual_y = " << t_carrier.m_actual_y << std::endl;
  400. std::cout << " huli test :::: " << " m_actual_z = " << t_carrier.m_actual_z << std::endl;
  401. std::cout << " huli test :::: " << " m_actual_y1 = " << t_carrier.m_actual_y1 << std::endl;
  402. std::cout << " huli test :::: " << " m_actual_y2 = " << t_carrier.m_actual_y2 << std::endl;
  403. std::cout << " huli test :::: " << " m_actual_clamp_motion1 = " << t_carrier.m_actual_clamp_motion1 << std::endl;
  404. std::cout << " huli test :::: " << " m_actual_clamp_motion2 = " << t_carrier.m_actual_clamp_motion2 << std::endl;
  405. std::cout << " huli test :::: " << " m_actual_small_sports_car_motion = " << t_carrier.m_actual_small_sports_car_motion << std::endl;
  406. std::cout << " huli test :::: " << " m_actual_joint_motion_x1 = " << t_carrier.m_actual_joint_motion_x1 << std::endl;
  407. std::cout << " huli test :::: " << " m_actual_joint_motion_x2 = " << t_carrier.m_actual_joint_motion_x2 << std::endl;
  408. std::cout << " huli test :::: " << " m_actual_error_code = " << std::endl;
  409. for (int i = 0; i < 50; ++i)
  410. {
  411. printf("0x%x ", t_carrier.m_actual_error_code[i]);
  412. }
  413. std::cout << std::endl;
  414. std::cout << " huli test :::: " << " m_actual_warning_code = " << std::endl;
  415. for (int i = 0; i < 50; ++i)
  416. {
  417. printf("0x%x ", t_carrier.m_actual_warning_code[i]);
  418. }
  419. std::cout << std::endl;
  420. std::cout << " huli test :::: " << " m_actual_error_description = " << t_carrier.m_actual_error_description << std::endl;
  421. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  422. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  423. }
  424. */
  425. /*
  426. Passageway t_passageway;
  427. t_error = t_passageway.dispatch_device_base_init(1);
  428. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  429. std::this_thread::sleep_for(std::chrono::seconds(2));
  430. std::shared_ptr<Task_Base> tp_task_Base3(new Passageway_task);
  431. Passageway_task * tp_passageway_task = (Passageway_task *)tp_task_Base3.get();
  432. tp_passageway_task->task_init(NULL,std::chrono::milliseconds(15000));
  433. tp_passageway_task->m_request_key = "ABCDEF";
  434. tp_passageway_task->m_request_inside_door_motion = Passageway_task::DOOR_OPEN;
  435. tp_passageway_task->m_request_outside_door_motion = Passageway_task::DOOR_CLOSE;
  436. tp_passageway_task->m_request_turntable_direction = Passageway_task::TURNTABLE_DIRECTION_OUTSIDE;
  437. t_error = t_passageway.execute_task(tp_task_Base3, Dispatch_device_base::E_ONE_LEVEL);
  438. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  439. std::cout << " ---------------------------------------------------" << std::endl;
  440. char zxczxcxzc3 ;
  441. std::cin >> zxczxcxzc3 ;
  442. while ( 1 )
  443. {
  444. std::cout << " huli test :::: " << " ===================================== " << std::endl;
  445. std::cout << " huli test :::: " << " tp_passageway_task->get_task_statu = " << tp_passageway_task->get_task_statu() << std::endl;
  446. std::cout << " huli test :::: " << " tp_passageway_task->m_respons_status = " << tp_passageway_task->m_respons_status << std::endl;
  447. std::cout << " huli test :::: " << " m_respons_key = " << tp_passageway_task->m_respons_key << std::endl;
  448. std::cout << " huli test :::: " << " m_respons_status = " << tp_passageway_task->m_respons_status << std::endl;
  449. std::cout << " huli test :::: " << " m_respons_inside_door_motion = " << tp_passageway_task->m_respons_inside_door_motion << std::endl;
  450. std::cout << " huli test :::: " << " m_respons_outside_door_motion = " << tp_passageway_task->m_respons_outside_door_motion << std::endl;
  451. std::cout << " huli test :::: " << " m_respons_turntable_direction = " << tp_passageway_task->m_respons_turntable_direction << std::endl;
  452. std::cout << " ---------------------------------------------------" << std::endl;
  453. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  454. std::cout << " huli test :::: " << " t_passageway_base.get_passageway_status() = " << t_passageway.get_dispatch_device_status() << std::endl;
  455. int heat = t_passageway.m_last_heartbeat;
  456. std::cout << " huli test :::: " << " m_last_heartbeat = " << heat << std::endl;
  457. std::cout << " huli test :::: " << " m_actual_device_status = " << t_passageway.m_actual_device_status << std::endl;
  458. std::cout << " huli test :::: " << " m_actual_inside_load_status = " << t_passageway.m_actual_inside_load_status << std::endl;
  459. std::cout << " huli test :::: " << " m_actual_outside_load_status = " << t_passageway.m_actual_outside_load_status << std::endl;
  460. std::cout << " huli test :::: " << " m_actual_front_overstep_the_boundary = " << t_passageway.m_actual_front_overstep_the_boundary << std::endl;
  461. std::cout << " huli test :::: " << " m_actual_back_overstep_the_boundary = " << t_passageway.m_actual_back_overstep_the_boundary << std::endl;
  462. std::cout << " huli test :::: " << " m_actual_height_overstep_the_boundary = " << t_passageway.m_actual_height_overstep_the_boundary << std::endl;
  463. std::cout << " huli test :::: " << " m_actual_outside_door_sensor = " << t_passageway.m_actual_outside_door_sensor << std::endl;
  464. std::cout << " huli test :::: " << " m_actual_inside_door_motion = " << t_passageway.m_actual_inside_door_motion << std::endl;
  465. std::cout << " huli test :::: " << " m_actual_outside_door_motion = " << t_passageway.m_actual_outside_door_motion << std::endl;
  466. std::cout << " huli test :::: " << " m_actual_turntable_load_status = " << t_passageway.m_actual_turntable_load_status << std::endl;
  467. std::cout << " huli test :::: " << " m_actual_turntable_direction = " << t_passageway.m_actual_turntable_direction << std::endl;
  468. std::cout << " huli test :::: " << " m_actual_error_code = " << std::endl;
  469. for (int i = 0; i < 50; ++i)
  470. {
  471. printf("0x%x ", t_passageway.m_actual_error_code[i]);
  472. }
  473. std::cout << std::endl;
  474. std::cout << " huli test :::: " << " m_actual_warning_code = " << std::endl;
  475. for (int i = 0; i < 50; ++i)
  476. {
  477. printf("0x%x ", t_passageway.m_actual_warning_code[i]);
  478. }
  479. std::cout << std::endl;
  480. std::cout << " huli test :::: " << " m_actual_error_description = " << t_passageway.m_actual_error_description << std::endl;
  481. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  482. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  483. }
  484. */
  485. while (1)
  486. {
  487. }
  488. char ch123 ;
  489. std::cin >> ch123 ;
  490. Dispatch_communication::get_instance_references().communication_uninit();
  491. return 0;
  492. int t_dispatch_id = 0;
  493. // std::cin >> t_dispatch_id ;
  494. if ( argc == 2 )
  495. {
  496. std::cout << " huli test :::: " << " argv[1] = " << argv[1] << std::endl;
  497. t_dispatch_id = atoi(argv[1]);
  498. }
  499. std::cout << " huli test :::: " << " t_dispatch_id = " << t_dispatch_id << std::endl;
  500. Dispatch_manager::get_instance_references().dispatch_manager_init(t_dispatch_id);
  501. std::cout << "Dispatch_manager = " << Dispatch_manager::get_instance_references().get_dispatch_manager_status() << std::endl;
  502. System_executor::get_instance_references().system_executor_init(8);
  503. std::cout << "System_executor = " << System_executor::get_instance_references().get_system_executor_status() << std::endl;
  504. System_communication::get_instance_references().communication_init();
  505. char ch ;
  506. std::cin >> ch ;
  507. System_communication::get_instance_references().communication_uninit();
  508. System_executor::get_instance_references().system_executor_uninit();
  509. Dispatch_manager::get_instance_references().dispatch_manager_uninit();
  510. return 0;
  511. }