system_executor.cpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. //
  2. // Created by huli on 2020/7/2.
  3. //
  4. #include "system_executor.h"
  5. System_executor::System_executor()
  6. {
  7. }
  8. System_executor::~System_executor()
  9. {
  10. system_executor_uninit();
  11. }
  12. //初始化
  13. Error_manager System_executor::system_executor_init(int threads_size)
  14. {
  15. m_thread_pool.thread_pool_init(threads_size);
  16. m_system_executor_status = SYSTEM_EXECUTOR_READY;
  17. return Error_code::SUCCESS;
  18. }
  19. //反初始化
  20. Error_manager System_executor::system_executor_uninit()
  21. {
  22. m_thread_pool.thread_pool_uninit();
  23. m_system_executor_status = SYSTEM_EXECUTOR_UNKNOW;
  24. return Error_code::SUCCESS;
  25. }
  26. //检查消息是否有效, 主要检查消息类型和接受者, 判断这条消息是不是给我的.
  27. Error_manager System_executor::check_msg(Rabbitmq_message* p_msg)
  28. {
  29. return Error_code::SUCCESS;
  30. /*
  31. if ( p_msg == NULL )
  32. {
  33. return Error_manager(Error_code::POINTER_IS_NULL, Error_level::MINOR_ERROR,
  34. " POINTER IS NULL ");
  35. }
  36. //检查接受人
  37. if ( p_msg->get_receiver() == Communication_message::Communicator::eDispatch_mamager )
  38. {
  39. //检查消息类型
  40. switch ( p_msg->get_message_type() )
  41. {
  42. case Communication_message::Message_type::eDispatch_request_msg:
  43. {
  44. message::Dispatch_request_msg t_dispatch_request_msg;
  45. //针对消息类型, 对消息进行二次解析
  46. if (t_dispatch_request_msg.ParseFromString(p_msg->get_message_buf()))
  47. {
  48. if ( t_dispatch_request_msg.dispatch_motion_direction() == message::Dispatch_motion_direction::E_STORE_CAR )
  49. {
  50. if ( t_dispatch_request_msg.id_struct().has_terminal_id() &&
  51. t_dispatch_request_msg.mutable_id_struct()->terminal_id() == Dispatch_manager::get_instance_references().get_dispatch_manager_id()*2 ||
  52. t_dispatch_request_msg.mutable_id_struct()->terminal_id() == Dispatch_manager::get_instance_references().get_dispatch_manager_id()*2+1)
  53. {
  54. return Error_code::SUCCESS;
  55. }
  56. }
  57. else if ( t_dispatch_request_msg.dispatch_motion_direction() == message::Dispatch_motion_direction::E_PICKUP_CAR )
  58. {
  59. if ( t_dispatch_request_msg.id_struct().has_unit_id() &&
  60. t_dispatch_request_msg.mutable_id_struct()->unit_id() == Dispatch_manager::get_instance_references().get_dispatch_manager_id() )
  61. {
  62. return Error_code::SUCCESS;
  63. }
  64. }
  65. }
  66. else
  67. {
  68. return Error_manager(Error_code::SYSTEM_EXECUTOR_PARSE_ERROR, Error_level::MINOR_ERROR,
  69. " message::Dispatch_request_msg ParseFromString error ");
  70. }
  71. break;
  72. }
  73. case Communication_message::Message_type::eDispatch_plan_response_msg:
  74. {
  75. return Error_code::SUCCESS;
  76. break;
  77. }
  78. case Communication_message::Message_type::eDispatch_control_request_msg:
  79. {
  80. return Error_code::SUCCESS;
  81. break;
  82. }
  83. default :
  84. ;
  85. break;
  86. }
  87. }
  88. //检查接受人
  89. if ( p_msg->get_receiver() == Communication_message::Communicator::eEmpty )
  90. {
  91. //检查消息类型
  92. switch ( p_msg->get_message_type() )
  93. {
  94. case Communication_message::Message_type::eGround_status_msg:
  95. {
  96. message::Ground_status_msg t_ground_status_msg;
  97. //针对消息类型, 对消息进行二次解析
  98. if (t_ground_status_msg.ParseFromString(p_msg->get_message_buf()))
  99. {
  100. if ( t_ground_status_msg.mutable_id_struct()->terminal_id() == Dispatch_manager::get_instance_references().get_dispatch_manager_id()*2 ||
  101. t_ground_status_msg.mutable_id_struct()->terminal_id() == Dispatch_manager::get_instance_references().get_dispatch_manager_id()*2+1)
  102. {
  103. return Error_code::SUCCESS;
  104. }
  105. }
  106. else
  107. {
  108. return Error_manager(Error_code::SYSTEM_EXECUTOR_PARSE_ERROR, Error_level::MINOR_ERROR,
  109. " message::Dispatch_request_msg ParseFromString error ");
  110. }
  111. break;
  112. }
  113. case Communication_message::Message_type::eTerminal_status_msg:
  114. {
  115. message::Terminal_status_msg t_terminal_status_msg;
  116. //针对消息类型, 对消息进行二次解析
  117. if (t_terminal_status_msg.ParseFromString(p_msg->get_message_buf()))
  118. {
  119. if ( t_terminal_status_msg.id_struct().terminal_id() == Dispatch_manager::get_instance_references().get_dispatch_manager_id()*2 ||
  120. t_terminal_status_msg.id_struct().terminal_id() == Dispatch_manager::get_instance_references().get_dispatch_manager_id()*2+1)
  121. {
  122. return Error_code::SUCCESS;
  123. }
  124. }
  125. else
  126. {
  127. return Error_manager(Error_code::SYSTEM_EXECUTOR_PARSE_ERROR, Error_level::MINOR_ERROR,
  128. " message::Dispatch_request_msg ParseFromString error ");
  129. }
  130. break;
  131. }
  132. case Communication_message::Message_type::eNotify_status_msg:
  133. {
  134. message::Notify_status_msg t_notify_status_msg;
  135. //针对消息类型, 对消息进行二次解析
  136. if (t_notify_status_msg.ParseFromString(p_msg->get_message_buf()))
  137. {
  138. if ( t_notify_status_msg.mutable_id_struct()->terminal_id() == Dispatch_manager::get_instance_references().get_dispatch_manager_id()*2 ||
  139. t_notify_status_msg.mutable_id_struct()->terminal_id() == Dispatch_manager::get_instance_references().get_dispatch_manager_id()*2+1)
  140. {
  141. return Error_code::SUCCESS;
  142. }
  143. }
  144. else
  145. {
  146. return Error_manager(Error_code::SYSTEM_EXECUTOR_PARSE_ERROR, Error_level::MINOR_ERROR,
  147. " message::Dispatch_request_msg ParseFromString error ");
  148. }
  149. break;
  150. }
  151. default :
  152. ;
  153. break;
  154. }
  155. }
  156. //无效的消息,
  157. return Error_manager(Error_code::INVALID_MESSAGE, Error_level::NEGLIGIBLE_ERROR,
  158. " INVALID_MESSAGE error ");
  159. */
  160. }
  161. //检查执行者的状态, 判断能否处理这条消息,
  162. Error_manager System_executor::check_executer(Rabbitmq_message* p_msg)
  163. {
  164. return Error_code::SUCCESS;
  165. /*
  166. if ( p_msg == NULL )
  167. {
  168. return Error_manager(Error_code::POINTER_IS_NULL, Error_level::MINOR_ERROR,
  169. " POINTER IS NULL ");
  170. }
  171. //检查执行线程池
  172. Error_manager t_executor_result = System_executor::get_instance_references().check_status();
  173. if (t_executor_result.get_error_level() == NEGLIGIBLE_ERROR)//一级故障,轻微故障,
  174. {
  175. std::cout << "executer_is_busy , " << std::endl;
  176. //返回繁忙之后, 通信模块1秒后再次调用check
  177. return Error_code::COMMUNICATION_EXCUTER_IS_BUSY;
  178. }
  179. else if (t_executor_result.get_error_level() > NEGLIGIBLE_ERROR)
  180. {
  181. return Error_manager(Error_code::SYSTEM_EXECUTOR_STATUS_ERROR, Error_level::MINOR_ERROR,
  182. "System_executor::get_instance_references().check_status(); fun error ");
  183. }
  184. //检查接受人
  185. if ( p_msg->get_receiver() == Communication_message::Communicator::eDispatch_mamager )
  186. {
  187. return Dispatch_manager::get_instance_references().check_execute_msg(p_msg);
  188. }
  189. */
  190. return Error_code::SUCCESS;
  191. }
  192. //处理消息的执行函数
  193. Error_manager System_executor::execute_msg(Rabbitmq_message* p_msg)
  194. {
  195. if ( p_msg == NULL )
  196. {
  197. return Error_manager(Error_code::POINTER_IS_NULL, Error_level::MINOR_ERROR,
  198. " POINTER IS NULL ");
  199. }
  200. return Dispatch_manager::get_instance_references().execute_rabbitmq_message_new(p_msg);
  201. // //通过key来判断消息类型
  202. // if ( p_msg->m_routing_key.find("count_command_signal") != p_msg->m_routing_key.npos ||
  203. // p_msg->m_routing_key.find("count_command_signal") != p_msg->m_routing_key.npos)
  204. // {
  205. //
  206. // }
  207. // else
  208. // {
  209. // std::cout << " huli test :::: xxxxxxxxxxxxxxxxxxxxxxx" << " p_msg = " << p_msg->m_message_buf << std::endl;
  210. // }
  211. //不用解析, 直接给调度模块
  212. /*
  213. //检查接受人
  214. if ( p_msg->get_receiver() == Communication_message::Communicator::eDispatch_mamager )
  215. {
  216. switch ( p_msg->get_message_type() )
  217. {
  218. case Communication_message::Message_type::eDispatch_request_msg:
  219. {
  220. message::Dispatch_request_msg t_dispatch_request_msg;
  221. //针对消息类型, 对消息进行二次解析
  222. if (t_dispatch_request_msg.ParseFromString(p_msg->get_message_buf()))
  223. {
  224. //往线程池添加执行任务, 之后会唤醒一个线程去执行他.
  225. m_thread_pool.enqueue(&System_executor::execute_for_dispatch_request_msg, this,
  226. t_dispatch_request_msg );
  227. }
  228. else
  229. {
  230. return Error_manager(Error_code::SYSTEM_EXECUTOR_PARSE_ERROR, Error_level::MINOR_ERROR,
  231. " message::Dispatch_request_msg ParseFromString error ");
  232. }
  233. break;
  234. }
  235. case Communication_message::Message_type::eDispatch_plan_response_msg:
  236. {
  237. message::Dispatch_plan_response_msg t_dispatch_plan_response_msg;
  238. //针对消息类型, 对消息进行二次解析
  239. if (t_dispatch_plan_response_msg.ParseFromString(p_msg->get_message_buf()))
  240. {
  241. //往线程池添加执行任务, 之后会唤醒一个线程去执行他.
  242. m_thread_pool.enqueue(&System_executor::execute_for_dispatch_plan_response_msg, this,
  243. t_dispatch_plan_response_msg );
  244. }
  245. else
  246. {
  247. return Error_manager(Error_code::SYSTEM_EXECUTOR_PARSE_ERROR, Error_level::MINOR_ERROR,
  248. " message::Dispatch_request_msg ParseFromString error ");
  249. }
  250. break;
  251. }
  252. case Communication_message::Message_type::eDispatch_control_request_msg:
  253. {
  254. message::Dispatch_control_request_msg t_dispatch_control_request_msg;
  255. //针对消息类型, 对消息进行二次解析
  256. if (t_dispatch_control_request_msg.ParseFromString(p_msg->get_message_buf()))
  257. {
  258. //往线程池添加执行任务, 之后会唤醒一个线程去执行他.
  259. m_thread_pool.enqueue(&System_executor::execute_for_dispatch_control_request_msg, this,
  260. t_dispatch_control_request_msg );
  261. }
  262. else
  263. {
  264. return Error_manager(Error_code::SYSTEM_EXECUTOR_PARSE_ERROR, Error_level::MINOR_ERROR,
  265. " message::Dispatch_request_msg ParseFromString error ");
  266. }
  267. break;
  268. }
  269. default:
  270. break;
  271. }
  272. }
  273. //检查接受人
  274. if ( p_msg->get_receiver() == Communication_message::Communicator::eEmpty )
  275. {
  276. switch ( p_msg->get_message_type() )
  277. {
  278. case Communication_message::Message_type::eGround_status_msg:
  279. {
  280. message::Ground_status_msg t_ground_status_msg;
  281. //针对消息类型, 对消息进行二次解析
  282. if (t_ground_status_msg.ParseFromString(p_msg->get_message_buf()))
  283. {
  284. //往线程池添加执行任务, 之后会唤醒一个线程去执行他.
  285. m_thread_pool.enqueue(&System_executor::execute_for_ground_status_msg, this,
  286. t_ground_status_msg );
  287. }
  288. else
  289. {
  290. return Error_manager(Error_code::SYSTEM_EXECUTOR_PARSE_ERROR, Error_level::MINOR_ERROR,
  291. " message::Dispatch_request_msg ParseFromString error ");
  292. }
  293. break;
  294. }
  295. case Communication_message::Message_type::eTerminal_status_msg:
  296. {
  297. message::Terminal_status_msg t_terminal_status_msg;
  298. //针对消息类型, 对消息进行二次解析
  299. if (t_terminal_status_msg.ParseFromString(p_msg->get_message_buf()))
  300. {
  301. //往线程池添加执行任务, 之后会唤醒一个线程去执行他.
  302. m_thread_pool.enqueue(&System_executor::execute_for_terminal_status_msg, this,
  303. t_terminal_status_msg );
  304. }
  305. else
  306. {
  307. return Error_manager(Error_code::SYSTEM_EXECUTOR_PARSE_ERROR, Error_level::MINOR_ERROR,
  308. " message::Dispatch_request_msg ParseFromString error ");
  309. }
  310. break;
  311. }
  312. case Communication_message::Message_type::eNotify_status_msg:
  313. {
  314. message::Notify_status_msg t_notify_status_msg;
  315. //针对消息类型, 对消息进行二次解析
  316. if (t_notify_status_msg.ParseFromString(p_msg->get_message_buf()))
  317. {
  318. //往线程池添加执行任务, 之后会唤醒一个线程去执行他.
  319. m_thread_pool.enqueue(&System_executor::execute_for_notify_status_msg, this,
  320. t_notify_status_msg );
  321. }
  322. else
  323. {
  324. return Error_manager(Error_code::SYSTEM_EXECUTOR_PARSE_ERROR, Error_level::MINOR_ERROR,
  325. " message::Dispatch_request_msg ParseFromString error ");
  326. }
  327. break;
  328. }
  329. default:
  330. break;
  331. }
  332. }
  333. */
  334. return Error_code::SUCCESS;
  335. }
  336. //检查状态
  337. Error_manager System_executor::check_status()
  338. {
  339. if ( m_system_executor_status == SYSTEM_EXECUTOR_READY )
  340. {
  341. if ( m_thread_pool.thread_is_full_load() == false )
  342. {
  343. return Error_code::SUCCESS;
  344. }
  345. else
  346. {
  347. return Error_manager(Error_code::SYSTEM_EXECUTOR_STATUS_BUSY, Error_level::NEGLIGIBLE_ERROR,
  348. " System_executor::check_status error ");
  349. }
  350. }
  351. else
  352. {
  353. return Error_manager(Error_code::SYSTEM_EXECUTOR_STATUS_ERROR, Error_level::MINOR_ERROR,
  354. " System_executor::check_status error ");
  355. }
  356. }
  357. //定时发送状态信息
  358. Error_manager System_executor::encapsulate_send_status()
  359. {
  360. Error_manager t_error;
  361. return Error_code::SUCCESS;
  362. int t_dispatch_manager_id = Dispatch_manager::get_instance_references().get_dispatch_manager_id();
  363. std::string t_msg;
  364. /*
  365. //创建一条 调度管理总管理的状态
  366. message::Dispatch_manager_status_msg t_dispatch_manager_status_msg;
  367. t_dispatch_manager_status_msg.mutable_base_info()->set_msg_type(message::Message_type::eDispatch_manager_status_msg);
  368. t_dispatch_manager_status_msg.mutable_base_info()->set_timeout_ms(5000);
  369. t_dispatch_manager_status_msg.mutable_base_info()->set_sender(message::Communicator::eDispatch);
  370. t_dispatch_manager_status_msg.mutable_base_info()->set_receiver(message::Communicator::eMain);
  371. t_dispatch_manager_status_msg.set_dispatch_id(t_dispatch_id);
  372. Dispatch_manager::Dispatch_manager_status t_dispatch_manager_status = Dispatch_manager::get_instance_references().get_dispatch_manager_status();
  373. t_dispatch_manager_status_msg.set_dispatch_manager_status((message::Dispatch_manager_status)t_dispatch_manager_status);
  374. t_msg = t_dispatch_manager_status_msg.SerializeAsString();
  375. System_communication::get_instance_references().encapsulate_msg(t_msg);
  376. */
  377. /*
  378. //创建4条 调度模块终端出入口的状态
  379. message::Dispatch_terminal_status_msg t_dispatch_terminal_status_msg;
  380. t_dispatch_terminal_status_msg.mutable_base_info()->set_msg_type(message::Message_type::eDispatch_status_msg);
  381. t_dispatch_terminal_status_msg.mutable_base_info()->set_timeout_ms(5000);
  382. t_dispatch_terminal_status_msg.mutable_base_info()->set_sender(message::Communicator::eDispatch_manager);
  383. t_dispatch_terminal_status_msg.mutable_base_info()->set_receiver(message::Communicator::eMain);
  384. t_dispatch_terminal_status_msg.set_terminal_id(t_dispatch_manager_id*2+0);
  385. t_dispatch_terminal_status_msg.set_terminal_status(message::Terminal_status::E_TERMINAL_READY);
  386. t_dispatch_terminal_status_msg.set_passageway_direction(message::Passageway_direction::E_INLET);
  387. t_msg = t_dispatch_terminal_status_msg.SerializeAsString();
  388. System_communication::get_instance_references().encapsulate_msg(t_msg);
  389. t_dispatch_terminal_status_msg.mutable_base_info()->set_msg_type(message::Message_type::eDispatch_status_msg);
  390. t_dispatch_terminal_status_msg.mutable_base_info()->set_timeout_ms(5000);
  391. t_dispatch_terminal_status_msg.mutable_base_info()->set_sender(message::Communicator::eDispatch_manager);
  392. t_dispatch_terminal_status_msg.mutable_base_info()->set_receiver(message::Communicator::eMain);
  393. t_dispatch_terminal_status_msg.set_terminal_id(t_dispatch_manager_id*2+0);
  394. t_dispatch_terminal_status_msg.set_terminal_status(message::Terminal_status::E_TERMINAL_READY);
  395. t_dispatch_terminal_status_msg.set_passageway_direction(message::Passageway_direction::E_OUTLET);
  396. t_msg = t_dispatch_terminal_status_msg.SerializeAsString();
  397. System_communication::get_instance_references().encapsulate_msg(t_msg);
  398. t_dispatch_terminal_status_msg.mutable_base_info()->set_msg_type(message::Message_type::eDispatch_status_msg);
  399. t_dispatch_terminal_status_msg.mutable_base_info()->set_timeout_ms(5000);
  400. t_dispatch_terminal_status_msg.mutable_base_info()->set_sender(message::Communicator::eDispatch_manager);
  401. t_dispatch_terminal_status_msg.mutable_base_info()->set_receiver(message::Communicator::eMain);
  402. t_dispatch_terminal_status_msg.set_terminal_id(t_dispatch_manager_id*2+1);
  403. t_dispatch_terminal_status_msg.set_terminal_status(message::Terminal_status::E_TERMINAL_READY);
  404. t_dispatch_terminal_status_msg.set_passageway_direction(message::Passageway_direction::E_INLET);
  405. t_msg = t_dispatch_terminal_status_msg.SerializeAsString();
  406. System_communication::get_instance_references().encapsulate_msg(t_msg);
  407. t_dispatch_terminal_status_msg.mutable_base_info()->set_msg_type(message::Message_type::eDispatch_status_msg);
  408. t_dispatch_terminal_status_msg.mutable_base_info()->set_timeout_ms(5000);
  409. t_dispatch_terminal_status_msg.mutable_base_info()->set_sender(message::Communicator::eDispatch_manager);
  410. t_dispatch_terminal_status_msg.mutable_base_info()->set_receiver(message::Communicator::eMain);
  411. t_dispatch_terminal_status_msg.set_terminal_id(t_dispatch_manager_id*2+1);
  412. t_dispatch_terminal_status_msg.set_terminal_status(message::Terminal_status::E_TERMINAL_READY);
  413. t_dispatch_terminal_status_msg.set_passageway_direction(message::Passageway_direction::E_OUTLET);
  414. t_msg = t_dispatch_terminal_status_msg.SerializeAsString();
  415. System_communication::get_instance_references().encapsulate_msg(t_msg);
  416. */
  417. return Error_code::SUCCESS;
  418. }
  419. //定时发送 调度管理的状态
  420. Error_manager System_executor::encapsulate_send_dispatch_manager_status()
  421. {
  422. // return Dispatch_manager::get_instance_references().encapsulate_send_dispatch_manager_status();
  423. return Dispatch_manager::get_instance_references().encapsulate_send_dispatch_manager_status_new();
  424. }
  425. //判断是否为待机,如果已经准备好,则可以执行任务。
  426. bool System_executor::is_ready()
  427. {
  428. if ( m_system_executor_status == SYSTEM_EXECUTOR_READY && m_thread_pool.thread_is_full_load() == false )
  429. {
  430. return true;
  431. }
  432. else
  433. {
  434. return false;
  435. }
  436. }
  437. System_executor::System_executor_status System_executor::get_system_executor_status()
  438. {
  439. return m_system_executor_status;
  440. }
  441. //雷达感测定位 的处理函数
  442. //input::command_id, 消息指令id, 由主控制系统生成的唯一码
  443. //input::command_id, 终端id, 对应具体的某个车位
  444. //return::void, 没有返回, 执行结果直接生成一条答复消息, 然后通过通信返回
  445. //void System_executor::execute_for_measure(std::string command_key, int unit_id, int terminal_id)
  446. //{
  447. // Error_manager t_error;
  448. //
  449. // LOG(INFO) << " System_executor::execute_for_measure run "<< this;
  450. // //这里要处理.......以后再写
  451. //
  452. // //创建一条答复消息
  453. // message::Measure_response_msg t_measure_response_msg;
  454. // t_measure_response_msg.mutable_base_info()->set_msg_type(message::Message_type::eLocate_response_msg);
  455. // t_measure_response_msg.mutable_base_info()->set_timeout_ms(5000);
  456. // t_measure_response_msg.mutable_base_info()->set_sender(message::Communicator::eMeasurer);
  457. // t_measure_response_msg.mutable_base_info()->set_receiver(message::Communicator::eMain);
  458. //
  459. // t_measure_response_msg.set_command_key(command_key);
  460. // t_measure_response_msg.mutable_id_struct()->set_unit_id(unit_id);
  461. // t_measure_response_msg.mutable_id_struct()->set_terminal_id(terminal_id);
  462. // t_measure_response_msg.mutable_error_manager()->set_error_code(t_error.get_error_code());
  463. // t_measure_response_msg.mutable_error_manager()->set_error_level((message::Error_level)t_error.get_error_level());
  464. // t_measure_response_msg.mutable_error_manager()->set_error_description(t_error.get_error_description());
  465. //
  466. // t_measure_response_msg.mutable_locate_information()->set_locate_x(0);
  467. // t_measure_response_msg.mutable_locate_information()->set_locate_y(0);
  468. // t_measure_response_msg.mutable_locate_information()->set_locate_angle(0);
  469. // t_measure_response_msg.mutable_locate_information()->set_locate_length(0);
  470. // t_measure_response_msg.mutable_locate_information()->set_locate_width(0);
  471. // t_measure_response_msg.mutable_locate_information()->set_locate_height(0);
  472. // t_measure_response_msg.mutable_locate_information()->set_locate_wheel_base(0);
  473. // t_measure_response_msg.mutable_locate_information()->set_locate_wheel_width(0);
  474. // t_measure_response_msg.mutable_locate_information()->set_locate_correct(0);
  475. //
  476. // std::string t_msg = t_measure_response_msg.SerializeAsString();
  477. // System_communication::get_instance_references().encapsulate_task_msg(t_msg);
  478. // LOG(INFO) << " System_executor::execute_for_measure end "<< this;
  479. //
  480. // return ;
  481. //}
  482. //
  483. //
  484. ////调度模块的处理函数
  485. //void System_executor::execute_for_dispatch(std::string command_key, Dispatch_manager::Dispatch_motion_direction dispatch_motion_direction,
  486. // int terminal_id, int parkspace_id, Locate_information * p_locate_information)
  487. //{
  488. // Error_manager t_error;
  489. //
  490. // LOG(INFO) << " System_executor::execute_for_dispatch run "<< this;
  491. // //这里要处理.......以后再写
  492. //
  493. // t_error = Dispatch_manager::get_instance_references().execute_task(dispatch_motion_direction);
  494. //
  495. // //创建一条答复消息
  496. // message::Dispatch_response_msg t_dispatch_response_msg;
  497. // t_dispatch_response_msg.mutable_base_info()->set_msg_type(message::Message_type::eDispatch_response_msg);
  498. // t_dispatch_response_msg.mutable_base_info()->set_timeout_ms(5000);
  499. // t_dispatch_response_msg.mutable_base_info()->set_sender(message::Communicator::eDispatch_manager);
  500. // t_dispatch_response_msg.mutable_base_info()->set_receiver(message::Communicator::eMain);
  501. //
  502. // t_dispatch_response_msg.set_command_key(command_key);
  503. // t_dispatch_response_msg.mutable_error_manager()->set_error_code(t_error.get_error_code());
  504. // t_dispatch_response_msg.mutable_error_manager()->set_error_level((message::Error_level)t_error.get_error_level());
  505. // t_dispatch_response_msg.mutable_error_manager()->set_error_description(t_error.get_error_description());
  506. //
  507. // std::string t_msg = t_dispatch_response_msg.SerializeAsString();
  508. // System_communication::get_instance_references().encapsulate_task_msg(t_msg);
  509. //
  510. // std::cout << "huli test dispatch_motion_direction = " << dispatch_motion_direction << std::endl;
  511. // std::cout << "huli test error = " << t_error << std::endl;
  512. //
  513. //
  514. // LOG(INFO) << " System_executor::execute_for_dispatch end "<< this;
  515. // return ;
  516. //
  517. //}
  518. //
  519. ////调度模块的处理函数
  520. //void System_executor::execute_for_dispatch_request_msg(message::Dispatch_request_msg dispatch_request_msg)
  521. //{
  522. // Error_manager t_error;
  523. // t_error = Dispatch_manager::get_instance_references().execute_for_dispatch_request_msg(dispatch_request_msg);
  524. // if ( t_error != Error_code::SUCCESS )
  525. // {
  526. // LOG(INFO) << " System_executor::execute_for_dispatch_request_msg fun error "<< this;
  527. // LOG(INFO) << t_error.to_string() << " "<< this;
  528. // }
  529. // return;
  530. //}
  531. ////调度模块 //调度总规划的答复(调度算法->调度管理)
  532. //void System_executor::execute_for_dispatch_plan_response_msg(message::Dispatch_plan_response_msg dispatch_plan_response_msg)
  533. //{
  534. // Error_manager t_error;
  535. // t_error = Dispatch_manager::get_instance_references().execute_for_dispatch_plan_response_msg(dispatch_plan_response_msg);
  536. // if ( t_error != Error_code::SUCCESS )
  537. // {
  538. // LOG(INFO) << " System_executor::execute_for_dispatch_request_msg fun error "<< this;
  539. // LOG(INFO) << t_error.to_string() << " "<< this;
  540. // }
  541. // return;
  542. //}
  543. ////调度模块 //调度控制的任务请求(调度算法->调度管理)
  544. //void System_executor::execute_for_dispatch_control_request_msg(message::Dispatch_control_request_msg dispatch_control_request_msg)
  545. //{
  546. // Error_manager t_error;
  547. // t_error = Dispatch_manager::get_instance_references().execute_for_dispatch_control_request_msg(dispatch_control_request_msg);
  548. // if ( t_error != Error_code::SUCCESS )
  549. // {
  550. // LOG(INFO) << " System_executor::execute_for_dispatch_request_msg fun error "<< this;
  551. // LOG(INFO) << t_error.to_string() << " "<< this;
  552. // }
  553. // return;
  554. //}
  555. //
  556. ////地面雷达的状态消息(地面雷达->null)
  557. //void System_executor::execute_for_ground_status_msg(message::Ground_status_msg ground_status_msg)
  558. //{
  559. // Error_manager t_error;
  560. // t_error = Dispatch_manager::get_instance_references().execute_for_ground_status_msg(ground_status_msg);
  561. // if ( t_error != Error_code::SUCCESS )
  562. // {
  563. // LOG(INFO) << " System_executor::execute_for_dispatch_request_msg fun error "<< this;
  564. // LOG(INFO) << t_error.to_string() << " "<< this;
  565. // }
  566. // return ;
  567. //}
  568. //
  569. ////地面雷达的状态消息(地面雷达->null)
  570. //void System_executor::execute_for_terminal_status_msg(message::Terminal_status_msg terminal_status_msg)
  571. //{
  572. // Error_manager t_error;
  573. // t_error = Dispatch_manager::get_instance_references().execute_for_singlechip_data_msg(terminal_status_msg.singlechipdata(), terminal_status_msg.singlechip_validity());
  574. // if ( t_error != Error_code::SUCCESS )
  575. // {
  576. // LOG(INFO) << " System_executor::execute_for_singlechip_data_msg fun error "<< this;
  577. // LOG(INFO) << t_error.to_string() << " "<< this;
  578. // }
  579. // return ;
  580. //}
  581. //
  582. ////调度模块 ///单片机的状态消息
  583. //void System_executor::execute_for_notify_status_msg(message::Notify_status_msg notify_status_msg)
  584. //{
  585. // // LOG(INFO) << "notify_status_msg = " << notify_status_msg.DebugString()<< this;
  586. //
  587. //
  588. // Error_manager t_error;
  589. // t_error = Dispatch_manager::get_instance_references().execute_for_singlechip_data_msg(notify_status_msg.singlechipdata(), notify_status_msg.singlechip_validity());
  590. // if ( t_error != Error_code::SUCCESS )
  591. // {
  592. // LOG(INFO) << " System_executor::execute_for_singlechip_data_msg fun error "<< this;
  593. // LOG(INFO) << t_error.to_string() << " "<< this;
  594. // }
  595. // return ;
  596. //}