main.cpp 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  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. std::string sendMsg(int terminal_id,int parkingspace_index_id, float x, std::string key, message::Dispatch_motion_direction direction)
  40. {
  41. message::Locate_information locateInformation;
  42. message::Dispatch_request_msg dispatchRequestMsg;
  43. message::Base_info t_base_info;
  44. message::Car_info car_info;
  45. message::Parkspace_info parkspace_info;
  46. t_base_info.set_msg_type(message::eDispatch_request_msg);
  47. t_base_info.set_sender(message::eMain);
  48. t_base_info.set_receiver(message::eDispatch_manager);
  49. t_base_info.set_timeout_ms(100000000);
  50. car_info.set_car_height(1.6);
  51. car_info.set_car_width(1.8);
  52. car_info.set_license("鄂Awk123");
  53. car_info.set_car_wheel_width(1.8);
  54. car_info.set_car_wheel_base(2.8);
  55. locateInformation.set_locate_x(x);
  56. locateInformation.set_locate_y(3);
  57. locateInformation.set_locate_angle(90);
  58. locateInformation.set_locate_length(3.2);
  59. locateInformation.set_locate_height(1.6);
  60. locateInformation.set_locate_width(1.8);
  61. locateInformation.set_locate_correct(true);
  62. locateInformation.set_locate_wheel_width(1.8);
  63. locateInformation.set_locate_wheel_base(2.8);
  64. parkspace_info.set_parkingspace_index_id(parkingspace_index_id);
  65. parkspace_info.set_parkingspace_room_id(1);
  66. parkspace_info.set_parkingspace_direction(message::Direction::eForward);
  67. parkspace_info.set_parkingspace_floor_id(3);
  68. parkspace_info.set_parkingspace_height(1.5);
  69. parkspace_info.set_parkingspace_width(1.5);
  70. parkspace_info.set_parkingspace_status(message::Parkspace_status::eParkspace_empty);
  71. parkspace_info.mutable_car_info()->CopyFrom(car_info);
  72. dispatchRequestMsg.mutable_base_info()->CopyFrom(t_base_info);
  73. dispatchRequestMsg.mutable_locate_information()->CopyFrom(locateInformation);
  74. dispatchRequestMsg.set_command_key(key);
  75. dispatchRequestMsg.set_dispatch_motion_direction(direction);
  76. dispatchRequestMsg.set_terminal_id(terminal_id);
  77. dispatchRequestMsg.mutable_parkspace_info()->CopyFrom(parkspace_info);
  78. LOG(INFO) << dispatchRequestMsg.DebugString();
  79. return dispatchRequestMsg.SerializeAsString();
  80. }
  81. int main(int argc,char* argv[])
  82. {
  83. Error_manager t_error;
  84. const char* logPath = "./";
  85. google::InitGoogleLogging("LidarMeasurement");
  86. google::SetStderrLogging(google::INFO);
  87. google::SetLogDestination(0, logPath);
  88. google::SetLogFilenameExtension("zxlog");
  89. google::InstallFailureSignalHandler();
  90. google::InstallFailureWriter(&shut_down_logging);
  91. FLAGS_colorlogtostderr = true; // Set log color
  92. FLAGS_logbufsecs = 0; // Set log output speed(s)
  93. FLAGS_max_log_size = 1024; // Set max log file size(GB)
  94. FLAGS_stop_logging_if_full_disk = true;
  95. // Dispatch_communication_test dispatchCommunicationTest;
  96. // dispatchCommunicationTest.communication_init();
  97. // std::this_thread::sleep_for(std::chrono::seconds(1));
  98. nnxx::socket socket{nnxx::SP, nnxx::BUS};
  99. //
  100. socket.bind("tcp://192.168.2.168:30000");
  101. std::this_thread::sleep_for(std::chrono::seconds(1));
  102. //
  103. // socket.send(sendMsg(1, 79, 7.755, "12345678901234567890123456_s1_wU", message::Dispatch_motion_direction::E_STORE_CAR));
  104. // socket.send(sendMsg(2, 78, 11.055, "12345678901234567890123456_s2_wU", message::Dispatch_motion_direction::E_STORE_CAR));
  105. // socket.send(sendMsg(3, 79, 14.655, "12345678901234567890123456_s3_wU", message::Dispatch_motion_direction::E_STORE_CAR));
  106. // socket.send(sendMsg(4, 39, 17.955, "12345678901234567890123456_s4_wU", message::Dispatch_motion_direction::E_STORE_CAR));
  107. // socket.send(sendMsg(5, 40, 21.555, "12345678901234567890123456_s5_wU", message::Dispatch_motion_direction::E_STORE_CAR));
  108. // socket.send(sendMsg(6, 27, 24.855, "12345678901234567890123456_s6_wU", message::Dispatch_motion_direction::E_STORE_CAR));
  109. // socket.send(sendMsg(1, 79, 7.755, "12345678901234567890123456_p1_wU", message::Dispatch_motion_direction::E_PICKUP_CAR));
  110. socket.send(sendMsg(2, 37, 11.055, "12345678901234567890123456_p2_wU", message::Dispatch_motion_direction::E_PICKUP_CAR));
  111. socket.send(sendMsg(3, 36, 14.655, "12345678901234567890123456_p3_wU", message::Dispatch_motion_direction::E_PICKUP_CAR));
  112. socket.send(sendMsg(4, 19, 17.955, "12345678901234567890123456_p4_wU", message::Dispatch_motion_direction::E_PICKUP_CAR));
  113. socket.send(sendMsg(5, 39, 21.555, "12345678901234567890123456_p5_wU", message::Dispatch_motion_direction::E_PICKUP_CAR));
  114. socket.send(sendMsg(6, 40, 24.855, "12345678901234567890123456_p6_wU", message::Dispatch_motion_direction::E_PICKUP_CAR));
  115. // socket.send(sendMsg(7, 39, 24.855, "12345678901234567890123456_p7_wU", message::Dispatch_motion_direction::E_PICKUP_CAR));
  116. // std::this_thread::sleep_for(std::chrono::seconds(5));
  117. ////
  118. //
  119. // message::Dispatch_control_request_msg control_reqeust;
  120. // control_reqeust.mutable_base_info()->set_msg_type(message::eDispatch_control_request_msg);
  121. // control_reqeust.mutable_base_info()->set_sender(message::eDispatch_control);
  122. // control_reqeust.mutable_base_info()->set_receiver(message::eDispatch_manager);
  123. // control_reqeust.mutable_base_info()->set_timeout_ms(100000000);
  124. // control_reqeust.set_command_key("12345678901234567890123456_p5_wU+120");
  125. // control_reqeust.set_dispatch_task_type(message::ROBOT_MOVE);
  126. // control_reqeust.set_dispatch_device_type(message::ROBOT_2);
  127. // control_reqeust.set_dispatch_source(0);
  128. // control_reqeust.set_dispatch_destination(1403);
  129. // LOG(INFO) << control_reqeust.DebugString();
  130. // socket.send(control_reqeust.SerializeAsString());
  131. while (1)
  132. {
  133. std::this_thread::sleep_for(std::chrono::milliseconds(1));
  134. std::string str;
  135. message::Base_msg base_info;
  136. str=socket.recv<std::string>(1);
  137. if ( str.size() > 0 )
  138. {
  139. base_info.ParseFromString(str);
  140. if ( base_info.base_info().msg_type() == message::eDispatch_manager_status_msg )
  141. {
  142. // std::cout << " Time_tool::get_instance_references().get_current_time_millisecond() = " << Time_tool::get_instance_references().get_current_time_millisecond() << std::endl;
  143. // std::cout <<base_info.DebugString()<< std::endl;
  144. }
  145. else if ( base_info.base_info().msg_type() == message::eDispatch_control_response_msg )
  146. {
  147. message::Dispatch_control_response_msg t_dispatch_control_response_msg;
  148. t_dispatch_control_response_msg.ParseFromString(str);
  149. if ( t_dispatch_control_response_msg.dispatch_device_task_status() == message::Dispatch_device_task_status::E_TASK_OVER)
  150. {
  151. std::cout << " Time_tool::get_instance_references().get_current_time_millisecond() = " << Time_tool::get_instance_references().get_current_time_millisecond() << std::endl;
  152. std::cout <<t_dispatch_control_response_msg.DebugString()<< std::endl;
  153. }
  154. else
  155. {
  156. std::cout << " Time_tool::get_instance_references().get_current_time_millisecond() = " << Time_tool::get_instance_references().get_current_time_millisecond() << std::endl;
  157. std::cout <<t_dispatch_control_response_msg.DebugString()<< std::endl;
  158. }
  159. }
  160. else if ( base_info.base_info().msg_type() == message::eDispatch_control_request_msg )
  161. {
  162. message::Dispatch_control_request_msg t_dispatch_control_request_msg;
  163. t_dispatch_control_request_msg.ParseFromString(str);
  164. std::cout << " Time_tool::get_instance_references().get_current_time_millisecond() = " << Time_tool::get_instance_references().get_current_time_millisecond() << std::endl;
  165. std::cout <<t_dispatch_control_request_msg.DebugString()<< std::endl;
  166. }
  167. else
  168. { std::cout << " Time_tool::get_instance_references().get_current_time_millisecond() = " << Time_tool::get_instance_references().get_current_time_millisecond() << std::endl;
  169. std::cout <<base_info.DebugString()<< std::endl;
  170. }
  171. }
  172. }
  173. #define MAIN_TEST 1
  174. #ifdef MAIN_TEST
  175. t_error = Dispatch_coordinates::get_instance_references().dispatch_coordinates_init();
  176. std::cout << " huli test :::: " << " Dispatch_coordinates::get_instance_references().dispatch_coordinates_init() = " << t_error.to_string() << std::endl;
  177. t_error = Dispatch_communication::get_instance_references().communication_init();
  178. std::cout << " huli test :::: " << " Dispatch_communication::get_instance_references().communication_init() = " << t_error.to_string() << std::endl;
  179. std::cout << "Dispatch_communication = " << Dispatch_communication::get_instance_references().get_status() << std::endl;
  180. t_error = Dispatch_manager::get_instance_references().dispatch_manager_init(0);
  181. std::cout << " huli test :::: " << " Dispatch_manager::get_instance_references().dispatch_manager_init(0) = " << t_error.to_string() << std::endl;
  182. std::cout << "Dispatch_manager = " << Dispatch_manager::get_instance_references().get_dispatch_manager_status() << std::endl;
  183. System_executor::get_instance_references().system_executor_init(10);
  184. std::cout << "System_executor = " << System_executor::get_instance_references().get_system_executor_status() << std::endl;
  185. System_communication::get_instance_references().communication_init();
  186. System_communication::get_instance_references().set_encapsulate_cycle_time(1000);
  187. while (1)
  188. {
  189. }
  190. return 0;
  191. #endif
  192. // Error_manager t_error;
  193. t_error = Dispatch_communication::get_instance_references().communication_init();
  194. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  195. std::cout << "Dispatch_communication = " << Dispatch_communication::get_instance_references().get_status() << std::endl;
  196. std::this_thread::sleep_for(std::chrono::seconds(2));
  197. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  198. std::cout << "Dispatch_communication = " << Dispatch_communication::get_instance_references().get_status() << std::endl;
  199. std::cout << " ---------------------------------------------------" << std::endl;
  200. std::cout << " ---------------------------------------------------" << std::endl;
  201. Catcher t_catcher;
  202. t_error = t_catcher.dispatch_device_base_init(1);
  203. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  204. std::this_thread::sleep_for(std::chrono::seconds(2));
  205. std::shared_ptr<Task_Base> tp_task_Base1(new Catcher_task);
  206. Catcher_task * tp_catcher_task1 = (Catcher_task *)tp_task_Base1.get();
  207. tp_catcher_task1->task_init(NULL,std::chrono::milliseconds(15000));
  208. tp_catcher_task1->m_request_key = "x23456789012345678901234567890r1";
  209. tp_catcher_task1->m_request_x = 11055;
  210. tp_catcher_task1->m_request_y = 3000;
  211. tp_catcher_task1->m_request_b = 90;
  212. tp_catcher_task1->m_request_z = 5410;
  213. tp_catcher_task1->m_request_d1 = 355;
  214. tp_catcher_task1->m_request_d2 = 455;
  215. tp_catcher_task1->m_request_wheelbase = 2800;
  216. tp_catcher_task1->m_request_clamp_motion = Catcher_task::E_CLAMP_LOOSE;
  217. t_error = t_catcher.execute_task(tp_task_Base1, Dispatch_device_base::DISPATCH_TASK_ONE_LEVEL);
  218. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  219. std::cout << " ---------------------------------------------------" << std::endl;
  220. /*
  221. char zxczxcxzc1 ;
  222. std::cin >> zxczxcxzc1 ;
  223. while ( 1 )
  224. {
  225. std::cout << " huli test :::: " << " ===================================== " << std::endl;
  226. std::cout << " huli test :::: " << " tp_catcher_task->get_task_statu = " << tp_catcher_task->get_task_statu() << std::endl;
  227. std::cout << " huli test :::: " << " tp_catcher_task->m_respons_status = " << tp_catcher_task->m_respons_status << std::endl;
  228. std::cout << " huli test :::: " << " m_respons_key = " << tp_catcher_task->m_respons_key << std::endl;
  229. std::cout << " huli test :::: " << " m_respons_status = " << tp_catcher_task->m_respons_status << std::endl;
  230. std::cout << " huli test :::: " << " m_respons_x = " << tp_catcher_task->m_respons_x << std::endl;
  231. std::cout << " huli test :::: " << " m_respons_y = " << tp_catcher_task->m_respons_y << std::endl;
  232. std::cout << " huli test :::: " << " m_respons_b = " << tp_catcher_task->m_respons_b << std::endl;
  233. std::cout << " huli test :::: " << " m_respons_z = " << tp_catcher_task->m_respons_z << std::endl;
  234. std::cout << " huli test :::: " << " m_respons_d1 = " << tp_catcher_task->m_respons_d1 << std::endl;
  235. std::cout << " huli test :::: " << " m_respons_d2 = " << tp_catcher_task->m_respons_d2 << std::endl;
  236. std::cout << " huli test :::: " << " m_respons_wheelbase = " << tp_catcher_task->m_respons_wheelbase << std::endl;
  237. std::cout << " huli test :::: " << " m_respons_clamp_motion = " << tp_catcher_task->m_respons_clamp_motion << std::endl;
  238. std::cout << " ---------------------------------------------------" << std::endl;
  239. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  240. std::cout << " huli test :::: " << " t_carrier_base.get_carrier_status() = " << t_catcher.get_dispatch_device_status() << std::endl;
  241. int heat = t_catcher.m_last_heartbeat;
  242. std::cout << " huli test :::: " << " m_last_heartbeat = " << heat << std::endl;
  243. std::cout << " huli test :::: " << " m_actual_device_status = " << t_catcher.m_actual_device_status << std::endl;
  244. std::cout << " huli test :::: " << " m_actual_load_status = " << t_catcher.m_actual_load_status << std::endl;
  245. std::cout << " huli test :::: " << " m_actual_x = " << t_catcher.m_actual_x << std::endl;
  246. std::cout << " huli test :::: " << " m_actual_y = " << t_catcher.m_actual_y << std::endl;
  247. std::cout << " huli test :::: " << " m_actual_b = " << t_catcher.m_actual_b << std::endl;
  248. std::cout << " huli test :::: " << " m_actual_z = " << t_catcher.m_actual_z << std::endl;
  249. std::cout << " huli test :::: " << " m_actual_d1 = " << t_catcher.m_actual_d1 << std::endl;
  250. std::cout << " huli test :::: " << " m_actual_d2 = " << t_catcher.m_actual_d2 << std::endl;
  251. std::cout << " huli test :::: " << " m_actual_clamp_motion1 = " << t_catcher.m_actual_clamp_motion1 << std::endl;
  252. std::cout << " huli test :::: " << " m_actual_clamp_motion2 = " << t_catcher.m_actual_clamp_motion2 << std::endl;
  253. std::cout << " huli test :::: " << " m_actual_clamp_motion3 = " << t_catcher.m_actual_clamp_motion3 << std::endl;
  254. std::cout << " huli test :::: " << " m_actual_clamp_motion4 = " << t_catcher.m_actual_clamp_motion4 << std::endl;
  255. std::cout << " huli test :::: " << " m_actual_error_code = " << std::endl;
  256. for (int i = 0; i < 50; ++i)
  257. {
  258. printf("0x%x ", t_catcher.m_actual_error_code[i]);
  259. }
  260. std::cout << std::endl;
  261. std::cout << " huli test :::: " << " m_actual_warning_code = " << std::endl;
  262. for (int i = 0; i < 50; ++i)
  263. {
  264. printf("0x%x ", t_catcher.m_actual_warning_code[i]);
  265. }
  266. std::cout << std::endl;
  267. std::cout << " huli test :::: " << " m_actual_error_description = " << t_catcher.m_actual_error_description << std::endl;
  268. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  269. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  270. }
  271. */
  272. Carrier t_carrier20;
  273. t_error = t_carrier20.dispatch_device_base_init(0);
  274. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  275. std::this_thread::sleep_for(std::chrono::seconds(2));
  276. std::shared_ptr<Task_Base> tp_task_Base20(new Carrier_task);
  277. Carrier_task * tp_carrier_task20 = (Carrier_task *)tp_task_Base20.get();
  278. tp_carrier_task20->task_init(NULL,std::chrono::milliseconds(15000));
  279. tp_carrier_task20->m_request_key = "x23456789012345678901234567890c0";
  280. tp_carrier_task20->m_request_x = 1;
  281. // tp_carrier_task20->m_request_x = 32600;
  282. tp_carrier_task20->m_request_y = 3000;
  283. tp_carrier_task20->m_request_z = 2525;
  284. tp_carrier_task20->m_request_y1 = 4500;
  285. tp_carrier_task20->m_request_y2 = 1700;
  286. tp_carrier_task20->m_request_clamp_motion = Carrier_task::E_CLAMP_LOOSE;
  287. tp_carrier_task20->m_request_joint_motion_x = Carrier_task::E_JOINT_HOLD_OUT;
  288. tp_carrier_task20->m_request_joint_motion_y = Carrier_task::E_JOINT_HOLD_OUT;
  289. tp_carrier_task20->m_request_space_id = 555;
  290. tp_carrier_task20->m_request_floor_id = 555;
  291. tp_carrier_task20->m_request_wheelbase = 555;
  292. t_error = t_carrier20.execute_task(tp_task_Base20, Dispatch_device_base::DISPATCH_TASK_ONE_LEVEL);
  293. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  294. std::cout << " ---------------------------------------------------" << std::endl;
  295. /*
  296. char zxczxcxzc20 ;
  297. std::cin >> zxczxcxzc20 ;
  298. while ( 1 )
  299. {
  300. std::cout << " huli test :::: " << " ===================================== " << std::endl;
  301. std::cout << " huli test :::: " << " tp_carrier_task->get_task_statu = " << tp_carrier_task->get_task_statu() << std::endl;
  302. std::cout << " huli test :::: " << " tp_carrier_task->m_respons_status = " << tp_carrier_task->m_respons_status << std::endl;
  303. std::cout << " huli test :::: " << " m_respons_key = " << tp_carrier_task->m_respons_key << std::endl;
  304. std::cout << " huli test :::: " << " m_respons_status = " << tp_carrier_task->m_respons_status << std::endl;
  305. std::cout << " huli test :::: " << " m_respons_x = " << tp_carrier_task->m_respons_x << std::endl;
  306. std::cout << " huli test :::: " << " m_respons_y = " << tp_carrier_task->m_respons_y << std::endl;
  307. std::cout << " huli test :::: " << " m_respons_z = " << tp_carrier_task->m_respons_z << std::endl;
  308. std::cout << " huli test :::: " << " m_respons_y1 = " << tp_carrier_task->m_respons_y1 << std::endl;
  309. std::cout << " huli test :::: " << " m_respons_y2 = " << tp_carrier_task->m_respons_y2 << std::endl;
  310. std::cout << " huli test :::: " << " m_respons_clamp_motion = " << tp_carrier_task->m_respons_clamp_motion << std::endl;
  311. std::cout << " huli test :::: " << " m_respons_joint_motion_x = " << tp_carrier_task->m_respons_joint_motion_x << std::endl;
  312. std::cout << " huli test :::: " << " m_respons_joint_motion_y = " << tp_carrier_task->m_respons_joint_motion_y << std::endl;
  313. std::cout << " huli test :::: " << " m_respons_space_id = " << tp_carrier_task->m_respons_space_id << std::endl;
  314. std::cout << " huli test :::: " << " m_respons_floor_id = " << tp_carrier_task->m_respons_floor_id << std::endl;
  315. std::cout << " huli test :::: " << " m_respons_wheelbase = " << tp_carrier_task->m_respons_wheelbase << std::endl;
  316. std::cout << " ---------------------------------------------------" << std::endl;
  317. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  318. std::cout << " huli test :::: " << " t_carrier_base.get_carrier_status() = " << t_carrier.get_dispatch_device_status() << std::endl;
  319. int heat = t_carrier.m_last_heartbeat;
  320. std::cout << " huli test :::: " << " m_last_heartbeat = " << heat << std::endl;
  321. std::cout << " huli test :::: " << " m_actual_device_status = " << t_carrier.m_actual_device_status << std::endl;
  322. std::cout << " huli test :::: " << " m_actual_load_status = " << t_carrier.m_actual_load_status << std::endl;
  323. std::cout << " huli test :::: " << " m_actual_x = " << t_carrier.m_actual_x << std::endl;
  324. std::cout << " huli test :::: " << " m_actual_y = " << t_carrier.m_actual_y << std::endl;
  325. std::cout << " huli test :::: " << " m_actual_z = " << t_carrier.m_actual_z << std::endl;
  326. std::cout << " huli test :::: " << " m_actual_y1 = " << t_carrier.m_actual_y1 << std::endl;
  327. std::cout << " huli test :::: " << " m_actual_y2 = " << t_carrier.m_actual_y2 << std::endl;
  328. std::cout << " huli test :::: " << " m_actual_clamp_motion1 = " << t_carrier.m_actual_clamp_motion1 << std::endl;
  329. std::cout << " huli test :::: " << " m_actual_clamp_motion2 = " << t_carrier.m_actual_clamp_motion2 << std::endl;
  330. std::cout << " huli test :::: " << " m_actual_small_sports_car_motion = " << t_carrier.m_actual_small_sports_car_motion << std::endl;
  331. std::cout << " huli test :::: " << " m_actual_joint_motion_x1 = " << t_carrier.m_actual_joint_motion_x1 << std::endl;
  332. std::cout << " huli test :::: " << " m_actual_joint_motion_x2 = " << t_carrier.m_actual_joint_motion_x2 << std::endl;
  333. std::cout << " huli test :::: " << " m_actual_error_code = " << std::endl;
  334. for (int i = 0; i < 50; ++i)
  335. {
  336. printf("0x%x ", t_carrier.m_actual_error_code[i]);
  337. }
  338. std::cout << std::endl;
  339. std::cout << " huli test :::: " << " m_actual_warning_code = " << std::endl;
  340. for (int i = 0; i < 50; ++i)
  341. {
  342. printf("0x%x ", t_carrier.m_actual_warning_code[i]);
  343. }
  344. std::cout << std::endl;
  345. std::cout << " huli test :::: " << " m_actual_error_description = " << t_carrier.m_actual_error_description << std::endl;
  346. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  347. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  348. }
  349. */
  350. Carrier t_carrier21;
  351. t_error = t_carrier21.dispatch_device_base_init(1);
  352. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  353. std::this_thread::sleep_for(std::chrono::seconds(2));
  354. std::shared_ptr<Task_Base> tp_task_Base21(new Carrier_task);
  355. Carrier_task * tp_carrier_task21 = (Carrier_task *)tp_task_Base21.get();
  356. tp_carrier_task21->task_init(NULL,std::chrono::milliseconds(15000));
  357. tp_carrier_task21->m_request_key = "x23456789012345678901234567890c1";
  358. // tp_carrier_task21->m_request_x = 1;
  359. tp_carrier_task21->m_request_x = 32600;
  360. tp_carrier_task21->m_request_y = 3000;
  361. tp_carrier_task21->m_request_z = 2525;
  362. tp_carrier_task21->m_request_y1 = 4500;
  363. tp_carrier_task21->m_request_y2 = 1700;
  364. tp_carrier_task21->m_request_clamp_motion = Carrier_task::E_CLAMP_LOOSE;
  365. tp_carrier_task21->m_request_joint_motion_x = Carrier_task::E_JOINT_HOLD_OUT;
  366. tp_carrier_task21->m_request_joint_motion_y = Carrier_task::E_JOINT_HOLD_OUT;
  367. tp_carrier_task21->m_request_space_id = 555;
  368. tp_carrier_task21->m_request_floor_id = 555;
  369. tp_carrier_task21->m_request_wheelbase = 555;
  370. t_error = t_carrier21.execute_task(tp_task_Base21, Dispatch_device_base::DISPATCH_TASK_ONE_LEVEL);
  371. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  372. std::cout << " ---------------------------------------------------" << std::endl;
  373. /*
  374. char zxczxcxzc21 ;
  375. std::cin >> zxczxcxzc21 ;
  376. while ( 1 )
  377. {
  378. std::cout << " huli test :::: " << " ===================================== " << std::endl;
  379. std::cout << " huli test :::: " << " tp_carrier_task->get_task_statu = " << tp_carrier_task->get_task_statu() << std::endl;
  380. std::cout << " huli test :::: " << " tp_carrier_task->m_respons_status = " << tp_carrier_task->m_respons_status << std::endl;
  381. std::cout << " huli test :::: " << " m_respons_key = " << tp_carrier_task->m_respons_key << std::endl;
  382. std::cout << " huli test :::: " << " m_respons_status = " << tp_carrier_task->m_respons_status << std::endl;
  383. std::cout << " huli test :::: " << " m_respons_x = " << tp_carrier_task->m_respons_x << std::endl;
  384. std::cout << " huli test :::: " << " m_respons_y = " << tp_carrier_task->m_respons_y << std::endl;
  385. std::cout << " huli test :::: " << " m_respons_z = " << tp_carrier_task->m_respons_z << std::endl;
  386. std::cout << " huli test :::: " << " m_respons_y1 = " << tp_carrier_task->m_respons_y1 << std::endl;
  387. std::cout << " huli test :::: " << " m_respons_y2 = " << tp_carrier_task->m_respons_y2 << std::endl;
  388. std::cout << " huli test :::: " << " m_respons_clamp_motion = " << tp_carrier_task->m_respons_clamp_motion << std::endl;
  389. std::cout << " huli test :::: " << " m_respons_joint_motion_x = " << tp_carrier_task->m_respons_joint_motion_x << std::endl;
  390. std::cout << " huli test :::: " << " m_respons_joint_motion_y = " << tp_carrier_task->m_respons_joint_motion_y << std::endl;
  391. std::cout << " huli test :::: " << " m_respons_space_id = " << tp_carrier_task->m_respons_space_id << std::endl;
  392. std::cout << " huli test :::: " << " m_respons_floor_id = " << tp_carrier_task->m_respons_floor_id << std::endl;
  393. std::cout << " huli test :::: " << " m_respons_wheelbase = " << tp_carrier_task->m_respons_wheelbase << std::endl;
  394. std::cout << " ---------------------------------------------------" << std::endl;
  395. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  396. std::cout << " huli test :::: " << " t_carrier_base.get_carrier_status() = " << t_carrier.get_dispatch_device_status() << std::endl;
  397. int heat = t_carrier.m_last_heartbeat;
  398. std::cout << " huli test :::: " << " m_last_heartbeat = " << heat << std::endl;
  399. std::cout << " huli test :::: " << " m_actual_device_status = " << t_carrier.m_actual_device_status << std::endl;
  400. std::cout << " huli test :::: " << " m_actual_load_status = " << t_carrier.m_actual_load_status << std::endl;
  401. std::cout << " huli test :::: " << " m_actual_x = " << t_carrier.m_actual_x << std::endl;
  402. std::cout << " huli test :::: " << " m_actual_y = " << t_carrier.m_actual_y << std::endl;
  403. std::cout << " huli test :::: " << " m_actual_z = " << t_carrier.m_actual_z << std::endl;
  404. std::cout << " huli test :::: " << " m_actual_y1 = " << t_carrier.m_actual_y1 << std::endl;
  405. std::cout << " huli test :::: " << " m_actual_y2 = " << t_carrier.m_actual_y2 << std::endl;
  406. std::cout << " huli test :::: " << " m_actual_clamp_motion1 = " << t_carrier.m_actual_clamp_motion1 << std::endl;
  407. std::cout << " huli test :::: " << " m_actual_clamp_motion2 = " << t_carrier.m_actual_clamp_motion2 << std::endl;
  408. std::cout << " huli test :::: " << " m_actual_small_sports_car_motion = " << t_carrier.m_actual_small_sports_car_motion << std::endl;
  409. std::cout << " huli test :::: " << " m_actual_joint_motion_x1 = " << t_carrier.m_actual_joint_motion_x1 << std::endl;
  410. std::cout << " huli test :::: " << " m_actual_joint_motion_x2 = " << t_carrier.m_actual_joint_motion_x2 << std::endl;
  411. std::cout << " huli test :::: " << " m_actual_error_code = " << std::endl;
  412. for (int i = 0; i < 50; ++i)
  413. {
  414. printf("0x%x ", t_carrier.m_actual_error_code[i]);
  415. }
  416. std::cout << std::endl;
  417. std::cout << " huli test :::: " << " m_actual_warning_code = " << std::endl;
  418. for (int i = 0; i < 50; ++i)
  419. {
  420. printf("0x%x ", t_carrier.m_actual_warning_code[i]);
  421. }
  422. std::cout << std::endl;
  423. std::cout << " huli test :::: " << " m_actual_error_description = " << t_carrier.m_actual_error_description << std::endl;
  424. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  425. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  426. }
  427. */
  428. Carrier t_carrier22;
  429. t_error = t_carrier22.dispatch_device_base_init(2);
  430. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  431. std::this_thread::sleep_for(std::chrono::seconds(2));
  432. std::shared_ptr<Task_Base> tp_task_Base22(new Carrier_task);
  433. Carrier_task * tp_carrier_task22 = (Carrier_task *)tp_task_Base22.get();
  434. tp_carrier_task22->task_init(NULL,std::chrono::milliseconds(15000));
  435. tp_carrier_task22->m_request_key = "x23456789012345678901234567890c2";
  436. tp_carrier_task22->m_request_x = 24855;
  437. // tp_carrier_task22->m_request_x = 4700;
  438. tp_carrier_task22->m_request_y = 3000;
  439. tp_carrier_task22->m_request_z = 5125;
  440. tp_carrier_task22->m_request_y1 = 4500;
  441. tp_carrier_task22->m_request_y2 = 1700;
  442. tp_carrier_task22->m_request_clamp_motion = Carrier_task::E_CLAMP_LOOSE;
  443. tp_carrier_task22->m_request_joint_motion_x = Carrier_task::E_JOINT_HOLD_OUT;
  444. tp_carrier_task22->m_request_joint_motion_y = Carrier_task::E_JOINT_HOLD_OUT;
  445. tp_carrier_task22->m_request_space_id = 555;
  446. tp_carrier_task22->m_request_floor_id = 555;
  447. tp_carrier_task22->m_request_wheelbase = 555;
  448. t_error = t_carrier22.execute_task(tp_task_Base22, Dispatch_device_base::DISPATCH_TASK_ONE_LEVEL);
  449. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  450. std::cout << " ---------------------------------------------------" << std::endl;
  451. /*
  452. char zxczxcxzc22 ;
  453. std::cin >> zxczxcxzc22 ;
  454. while ( 1 )
  455. {
  456. std::cout << " huli test :::: " << " ===================================== " << std::endl;
  457. std::cout << " huli test :::: " << " tp_carrier_task->get_task_statu = " << tp_carrier_task->get_task_statu() << std::endl;
  458. std::cout << " huli test :::: " << " tp_carrier_task->m_respons_status = " << tp_carrier_task->m_respons_status << std::endl;
  459. std::cout << " huli test :::: " << " m_respons_key = " << tp_carrier_task->m_respons_key << std::endl;
  460. std::cout << " huli test :::: " << " m_respons_status = " << tp_carrier_task->m_respons_status << std::endl;
  461. std::cout << " huli test :::: " << " m_respons_x = " << tp_carrier_task->m_respons_x << std::endl;
  462. std::cout << " huli test :::: " << " m_respons_y = " << tp_carrier_task->m_respons_y << std::endl;
  463. std::cout << " huli test :::: " << " m_respons_z = " << tp_carrier_task->m_respons_z << std::endl;
  464. std::cout << " huli test :::: " << " m_respons_y1 = " << tp_carrier_task->m_respons_y1 << std::endl;
  465. std::cout << " huli test :::: " << " m_respons_y2 = " << tp_carrier_task->m_respons_y2 << std::endl;
  466. std::cout << " huli test :::: " << " m_respons_clamp_motion = " << tp_carrier_task->m_respons_clamp_motion << std::endl;
  467. std::cout << " huli test :::: " << " m_respons_joint_motion_x = " << tp_carrier_task->m_respons_joint_motion_x << std::endl;
  468. std::cout << " huli test :::: " << " m_respons_joint_motion_y = " << tp_carrier_task->m_respons_joint_motion_y << std::endl;
  469. std::cout << " huli test :::: " << " m_respons_space_id = " << tp_carrier_task->m_respons_space_id << std::endl;
  470. std::cout << " huli test :::: " << " m_respons_floor_id = " << tp_carrier_task->m_respons_floor_id << std::endl;
  471. std::cout << " huli test :::: " << " m_respons_wheelbase = " << tp_carrier_task->m_respons_wheelbase << std::endl;
  472. std::cout << " ---------------------------------------------------" << std::endl;
  473. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  474. std::cout << " huli test :::: " << " t_carrier_base.get_carrier_status() = " << t_carrier.get_dispatch_device_status() << std::endl;
  475. int heat = t_carrier.m_last_heartbeat;
  476. std::cout << " huli test :::: " << " m_last_heartbeat = " << heat << std::endl;
  477. std::cout << " huli test :::: " << " m_actual_device_status = " << t_carrier.m_actual_device_status << std::endl;
  478. std::cout << " huli test :::: " << " m_actual_load_status = " << t_carrier.m_actual_load_status << std::endl;
  479. std::cout << " huli test :::: " << " m_actual_x = " << t_carrier.m_actual_x << std::endl;
  480. std::cout << " huli test :::: " << " m_actual_y = " << t_carrier.m_actual_y << std::endl;
  481. std::cout << " huli test :::: " << " m_actual_z = " << t_carrier.m_actual_z << std::endl;
  482. std::cout << " huli test :::: " << " m_actual_y1 = " << t_carrier.m_actual_y1 << std::endl;
  483. std::cout << " huli test :::: " << " m_actual_y2 = " << t_carrier.m_actual_y2 << std::endl;
  484. std::cout << " huli test :::: " << " m_actual_clamp_motion1 = " << t_carrier.m_actual_clamp_motion1 << std::endl;
  485. std::cout << " huli test :::: " << " m_actual_clamp_motion2 = " << t_carrier.m_actual_clamp_motion2 << std::endl;
  486. std::cout << " huli test :::: " << " m_actual_small_sports_car_motion = " << t_carrier.m_actual_small_sports_car_motion << std::endl;
  487. std::cout << " huli test :::: " << " m_actual_joint_motion_x1 = " << t_carrier.m_actual_joint_motion_x1 << std::endl;
  488. std::cout << " huli test :::: " << " m_actual_joint_motion_x2 = " << t_carrier.m_actual_joint_motion_x2 << std::endl;
  489. std::cout << " huli test :::: " << " m_actual_error_code = " << std::endl;
  490. for (int i = 0; i < 50; ++i)
  491. {
  492. printf("0x%x ", t_carrier.m_actual_error_code[i]);
  493. }
  494. std::cout << std::endl;
  495. std::cout << " huli test :::: " << " m_actual_warning_code = " << std::endl;
  496. for (int i = 0; i < 50; ++i)
  497. {
  498. printf("0x%x ", t_carrier.m_actual_warning_code[i]);
  499. }
  500. std::cout << std::endl;
  501. std::cout << " huli test :::: " << " m_actual_error_description = " << t_carrier.m_actual_error_description << std::endl;
  502. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  503. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  504. }
  505. */
  506. /*
  507. Passageway t_passageway;
  508. t_error = t_passageway.dispatch_device_base_init(1);
  509. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  510. std::this_thread::sleep_for(std::chrono::seconds(2));
  511. std::shared_ptr<Task_Base> tp_task_Base3(new Passageway_task);
  512. Passageway_task * tp_passageway_task = (Passageway_task *)tp_task_Base3.get();
  513. tp_passageway_task->task_init(NULL,std::chrono::milliseconds(15000));
  514. tp_passageway_task->m_request_key = "ABCDEF";
  515. tp_passageway_task->m_request_inside_door_motion = Passageway_task::DOOR_OPEN;
  516. tp_passageway_task->m_request_outside_door_motion = Passageway_task::DOOR_CLOSE;
  517. tp_passageway_task->m_request_turntable_direction = Passageway_task::TURNTABLE_DIRECTION_OUTSIDE;
  518. t_error = t_passageway.execute_task(tp_task_Base3, Dispatch_device_base::E_ONE_LEVEL);
  519. std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
  520. std::cout << " ---------------------------------------------------" << std::endl;
  521. char zxczxcxzc3 ;
  522. std::cin >> zxczxcxzc3 ;
  523. while ( 1 )
  524. {
  525. std::cout << " huli test :::: " << " ===================================== " << std::endl;
  526. std::cout << " huli test :::: " << " tp_passageway_task->get_task_statu = " << tp_passageway_task->get_task_statu() << std::endl;
  527. std::cout << " huli test :::: " << " tp_passageway_task->m_respons_status = " << tp_passageway_task->m_respons_status << std::endl;
  528. std::cout << " huli test :::: " << " m_respons_key = " << tp_passageway_task->m_respons_key << std::endl;
  529. std::cout << " huli test :::: " << " m_respons_status = " << tp_passageway_task->m_respons_status << std::endl;
  530. std::cout << " huli test :::: " << " m_respons_inside_door_motion = " << tp_passageway_task->m_respons_inside_door_motion << std::endl;
  531. std::cout << " huli test :::: " << " m_respons_outside_door_motion = " << tp_passageway_task->m_respons_outside_door_motion << std::endl;
  532. std::cout << " huli test :::: " << " m_respons_turntable_direction = " << tp_passageway_task->m_respons_turntable_direction << std::endl;
  533. std::cout << " ---------------------------------------------------" << std::endl;
  534. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  535. std::cout << " huli test :::: " << " t_passageway_base.get_passageway_status() = " << t_passageway.get_dispatch_device_status() << std::endl;
  536. int heat = t_passageway.m_last_heartbeat;
  537. std::cout << " huli test :::: " << " m_last_heartbeat = " << heat << std::endl;
  538. std::cout << " huli test :::: " << " m_actual_device_status = " << t_passageway.m_actual_device_status << std::endl;
  539. std::cout << " huli test :::: " << " m_actual_inside_load_status = " << t_passageway.m_actual_inside_load_status << std::endl;
  540. std::cout << " huli test :::: " << " m_actual_outside_load_status = " << t_passageway.m_actual_outside_load_status << std::endl;
  541. std::cout << " huli test :::: " << " m_actual_front_overstep_the_boundary = " << t_passageway.m_actual_front_overstep_the_boundary << std::endl;
  542. std::cout << " huli test :::: " << " m_actual_back_overstep_the_boundary = " << t_passageway.m_actual_back_overstep_the_boundary << std::endl;
  543. std::cout << " huli test :::: " << " m_actual_height_overstep_the_boundary = " << t_passageway.m_actual_height_overstep_the_boundary << std::endl;
  544. std::cout << " huli test :::: " << " m_actual_outside_door_sensor = " << t_passageway.m_actual_outside_door_sensor << std::endl;
  545. std::cout << " huli test :::: " << " m_actual_inside_door_motion = " << t_passageway.m_actual_inside_door_motion << std::endl;
  546. std::cout << " huli test :::: " << " m_actual_outside_door_motion = " << t_passageway.m_actual_outside_door_motion << std::endl;
  547. std::cout << " huli test :::: " << " m_actual_turntable_load_status = " << t_passageway.m_actual_turntable_load_status << std::endl;
  548. std::cout << " huli test :::: " << " m_actual_turntable_direction = " << t_passageway.m_actual_turntable_direction << std::endl;
  549. std::cout << " huli test :::: " << " m_actual_error_code = " << std::endl;
  550. for (int i = 0; i < 50; ++i)
  551. {
  552. printf("0x%x ", t_passageway.m_actual_error_code[i]);
  553. }
  554. std::cout << std::endl;
  555. std::cout << " huli test :::: " << " m_actual_warning_code = " << std::endl;
  556. for (int i = 0; i < 50; ++i)
  557. {
  558. printf("0x%x ", t_passageway.m_actual_warning_code[i]);
  559. }
  560. std::cout << std::endl;
  561. std::cout << " huli test :::: " << " m_actual_error_description = " << t_passageway.m_actual_error_description << std::endl;
  562. std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
  563. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  564. }
  565. */
  566. while (1)
  567. {
  568. }
  569. char ch123 ;
  570. std::cin >> ch123 ;
  571. Dispatch_communication::get_instance_references().communication_uninit();
  572. return 0;
  573. int t_dispatch_id = 0;
  574. // std::cin >> t_dispatch_id ;
  575. if ( argc == 2 )
  576. {
  577. std::cout << " huli test :::: " << " argv[1] = " << argv[1] << std::endl;
  578. t_dispatch_id = atoi(argv[1]);
  579. }
  580. std::cout << " huli test :::: " << " t_dispatch_id = " << t_dispatch_id << std::endl;
  581. Dispatch_manager::get_instance_references().dispatch_manager_init(t_dispatch_id);
  582. std::cout << "Dispatch_manager = " << Dispatch_manager::get_instance_references().get_dispatch_manager_status() << std::endl;
  583. System_executor::get_instance_references().system_executor_init(8);
  584. std::cout << "System_executor = " << System_executor::get_instance_references().get_system_executor_status() << std::endl;
  585. System_communication::get_instance_references().communication_init();
  586. char ch ;
  587. std::cin >> ch ;
  588. System_communication::get_instance_references().communication_uninit();
  589. System_executor::get_instance_references().system_executor_uninit();
  590. Dispatch_manager::get_instance_references().dispatch_manager_uninit();
  591. return 0;
  592. }