StoreProcessTask.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. //
  2. // Created by zx on 2020/7/7.
  3. //
  4. #include <Parkspace_communicator.h>
  5. #include <dispatch_message.pb.h>
  6. #include "dispatch_communicator.h"
  7. #include "StoreProcessTask.h"
  8. #include "process_message.pb.h"
  9. #include "command_manager.h"
  10. #include "system_communicator.h"
  11. #include "exception_solver.h"
  12. #include "uniq_key.h"
  13. StoreProcessTask::StoreProcessTask(unsigned int terminor_id)
  14. :m_publish_statu_thread(nullptr)
  15. {
  16. m_terminor_id=terminor_id;
  17. }
  18. StoreProcessTask::~StoreProcessTask()
  19. {
  20. Exception_solver::get_instance_pointer()->delete_task_cancel_condition(m_car_info.license());
  21. //退出线程
  22. m_publish_exit_condition.set_pass_ever(true);
  23. if(m_publish_statu_thread!= nullptr)
  24. {
  25. if(m_publish_statu_thread->joinable())
  26. {
  27. m_publish_statu_thread->join();
  28. }
  29. delete m_publish_statu_thread;
  30. m_publish_statu_thread=nullptr;
  31. }
  32. }
  33. Error_manager StoreProcessTask::init_task(message::Locate_information locate_info,message::Car_info car_info)
  34. {
  35. reset_msg();
  36. m_car_info=car_info;
  37. m_locate_info=locate_info;
  38. //添加当前流程的任务取消标志位到异常处理模块
  39. m_cancel_condition.reset(false, false, false);
  40. Error_manager code=Exception_solver::get_instance_pointer()->add_task_cancel_condition(car_info.license(),this);
  41. if(code!=SUCCESS)
  42. return code;
  43. //初始化进度状态消息基本信息
  44. message::Base_info base_info;
  45. base_info.set_msg_type(message::eStoring_process_statu_msg);
  46. base_info.set_sender(message::eMain);
  47. base_info.set_receiver(message::eEmpty);
  48. m_process_msg.mutable_base_info()->CopyFrom(base_info);
  49. m_process_msg.set_terminal_id(m_terminor_id);
  50. m_process_msg.set_license(m_car_info.license());
  51. m_step_statu=eAlloc_step;
  52. ///创建状态发布线程
  53. if(m_publish_statu_thread== nullptr)
  54. {
  55. m_publish_exit_condition.reset(false, false, false);
  56. m_publish_statu_thread=new std::thread(publish_thread_func,this);
  57. }
  58. return SUCCESS;
  59. }
  60. /*
  61. * 取消任务
  62. */
  63. void StoreProcessTask::Cancel()
  64. {
  65. m_cancel_condition.set_pass_ever(true);
  66. tq::BaseTask::Cancel();
  67. }
  68. Error_manager StoreProcessTask::locate_step() {
  69. Error_manager code;
  70. //检查测量模块状态
  71. code=Locate_communicator::get_instance_pointer()->check_statu(m_terminor_id);
  72. if(code!=SUCCESS)
  73. return code;
  74. message::Base_info base_info;
  75. base_info.set_msg_type(message::eLocate_request_msg);
  76. base_info.set_sender(message::eMain);
  77. base_info.set_receiver(message::eMeasurer);
  78. base_info.set_timeout_ms(20000); //测量超时5s
  79. m_measure_request_msg.mutable_base_info()->CopyFrom(base_info);
  80. m_measure_request_msg.set_command_key(create_key());
  81. m_measure_request_msg.set_terminal_id(m_terminor_id);
  82. code=Locate_communicator::get_instance_pointer()->locate_request(m_measure_request_msg,
  83. m_measure_response_msg,m_cancel_condition);
  84. if(code!=SUCCESS)
  85. return code;
  86. if(m_measure_response_msg.error_manager().error_code()==0) {
  87. return SUCCESS;
  88. }
  89. else
  90. return Error_manager(FAILED,MINOR_ERROR,m_measure_response_msg.error_manager().error_description().c_str());
  91. }
  92. /*
  93. * 回退定位
  94. */
  95. Error_manager StoreProcessTask::back_locate_step()
  96. {
  97. m_measure_request_msg=message::Measure_request_msg();
  98. m_measure_response_msg=message::Measure_response_msg();
  99. return SUCCESS;
  100. }
  101. /*
  102. * 检验结果
  103. */
  104. Error_manager StoreProcessTask::compare_step()
  105. {
  106. return SUCCESS;
  107. }
  108. /*
  109. * 回退检验
  110. */
  111. Error_manager StoreProcessTask::back_compare_step()
  112. {
  113. return SUCCESS;
  114. }
  115. /*
  116. * 调度
  117. */
  118. Error_manager StoreProcessTask::dispatch_step()
  119. {
  120. Error_manager code;
  121. /*
  122. * 判断调度所需的数据是否都正常
  123. */
  124. //1,测量信息是否存在
  125. if(m_measure_response_msg.has_base_info()== false
  126. ||m_measure_response_msg.has_locate_information()==false
  127. ||m_parcspace_alloc_response_msg.has_base_info()== false
  128. ||m_parcspace_alloc_response_msg.has_allocated_space_info()==false)
  129. {
  130. return Error_manager(ERROR,MAJOR_ERROR,"调度所需的前置数据(测量,车位)不存在");
  131. }
  132. //2,判断调度节点状态
  133. code=Dispatch_communicator::get_instance_pointer()->check_entrance_statu(m_terminor_id);
  134. if(code!=SUCCESS)
  135. return code;
  136. message::Base_info base_info;
  137. base_info.set_msg_type(message::eDispatch_request_msg);
  138. base_info.set_sender(message::eMain);
  139. base_info.set_receiver(message::eDispatch);
  140. base_info.set_timeout_ms(1000*15); //超时15s
  141. m_dispatch_request_msg.mutable_base_info()->CopyFrom(base_info);
  142. std::string key=create_key();
  143. m_dispatch_request_msg.set_command_key(key);
  144. m_dispatch_request_msg.set_terminal_id(m_terminor_id);
  145. m_dispatch_request_msg.set_dispatch_motion_direction(message::E_STORE_CAR);
  146. m_dispatch_request_msg.set_parkspace_id(m_parcspace_alloc_response_msg.allocated_space_info().parkspace_id());
  147. code=Dispatch_communicator::get_instance_pointer()->dispatch_request(m_dispatch_request_msg,
  148. m_dispatch_response_msg,m_cancel_condition);
  149. if(code!=SUCCESS)
  150. return code;
  151. if(m_dispatch_response_msg.error_manager().error_code()==0) {
  152. return SUCCESS;
  153. }
  154. else
  155. return Error_manager(FAILED,MINOR_ERROR,"dispatch response error_code error");
  156. }
  157. /*
  158. * 回退调度
  159. */
  160. Error_manager StoreProcessTask::back_dispatch_step()
  161. {
  162. //reset 调度请求数据
  163. m_dispatch_request_msg=message::Dispatch_request_msg();
  164. m_dispatch_response_msg=message::Dispatch_response_msg();
  165. return SUCCESS;
  166. }
  167. /*
  168. * 分配车位
  169. */
  170. Error_manager StoreProcessTask::alloc_space()
  171. {
  172. /*
  173. * 检查是否有测量数据
  174. */
  175. m_step_statu=eAlloc_step;
  176. updata_step_statu_msg(message::eWorking);
  177. if(m_locate_info.has_locate_height()==false||m_locate_info.has_locate_width()==false)
  178. {
  179. updata_step_statu_msg(message::eError);
  180. return Error_manager(FAILED,MINOR_ERROR,"停车请求缺少车辆高度和宽度信息");
  181. }
  182. /*
  183. * 检查车位管理模块是否正常
  184. */
  185. Error_manager code=Parkspace_communicator::get_instance_pointer()->check_statu();
  186. if(code!=SUCCESS)
  187. {
  188. updata_step_statu_msg(message::eError);
  189. return code;
  190. }
  191. //发送分配请求
  192. message::Base_info base_info;
  193. base_info.set_msg_type(message::eParkspace_allocation_request_msg);
  194. base_info.set_sender(message::eMain);
  195. base_info.set_receiver(message::eParkspace);
  196. base_info.set_timeout_ms(1000); //超时1s
  197. m_alloc_request_msg.mutable_base_info()->CopyFrom(base_info);
  198. m_alloc_request_msg.mutable_car_info()->CopyFrom(m_car_info);
  199. m_alloc_request_msg.set_command_key(create_key());
  200. m_alloc_request_msg.set_terminal_id(m_terminor_id);
  201. code=Parkspace_communicator::get_instance_pointer()->alloc_request(m_alloc_request_msg,
  202. m_parcspace_alloc_response_msg,m_cancel_condition);
  203. if(code!=SUCCESS)
  204. {
  205. updata_step_statu_msg(message::eError);
  206. return code;
  207. }
  208. if(m_parcspace_alloc_response_msg.error_manager().error_code()==0)
  209. {
  210. message::Car_info alloc_car_info=m_parcspace_alloc_response_msg.allocated_space_info().car_info();
  211. if(alloc_car_info.license()!=m_car_info.license())
  212. {
  213. return Error_manager(ERROR,MINOR_ERROR,"分配车位反馈的车辆信息不匹配");
  214. }
  215. updata_step_statu_msg(message::eComplete);
  216. //置步骤状态为测量状态.
  217. m_step_statu=eMeasure_step;
  218. return SUCCESS;
  219. }
  220. else
  221. {
  222. updata_step_statu_msg(message::eError);
  223. return Error_manager(FAILED,MINOR_ERROR,"分配车位反馈结果错误");
  224. }
  225. }
  226. /*
  227. * 车位占用确认
  228. */
  229. Error_manager StoreProcessTask::confirm_space_step()
  230. {
  231. /*
  232. * 检查车位管理模块是否正常
  233. */
  234. Error_manager code=Parkspace_communicator::get_instance_pointer()->check_statu();
  235. if(code!=SUCCESS)
  236. return code;
  237. message::Parkspace_confirm_alloc_request_msg request;
  238. message::Base_info base_info;
  239. base_info.set_msg_type(message::eParkspace_confirm_alloc_request_msg);
  240. base_info.set_sender(message::eMain);
  241. base_info.set_receiver(message::eParkspace);
  242. base_info.set_timeout_ms(1000); //测量超时1s
  243. request.mutable_base_info()->CopyFrom(base_info);
  244. message::Parkspace_info space_info=m_parcspace_alloc_response_msg.allocated_space_info();
  245. request.mutable_confirm_space_info()->CopyFrom(space_info);
  246. request.set_command_key(create_key());
  247. message::Parkspace_confirm_alloc_response_msg confirm_response;
  248. code=Parkspace_communicator::get_instance_pointer()->confirm_request(request,confirm_response,m_cancel_condition);
  249. if(code!=SUCCESS)
  250. return code;
  251. if(m_parcspace_alloc_response_msg.allocated_space_info().parkspace_id()!=
  252. confirm_response.confirm_alloc_space_info().parkspace_id())
  253. {
  254. return Error_manager(ERROR,MINOR_ERROR,"占用车位与分配车位不一致");
  255. }
  256. if(confirm_response.error_manager().error_code()==0) {
  257. /*LOG(INFO)<<"停车流程正常,确认占用车位成功,停车终端:"<<m_terminor_id
  258. <<", 指令id:"<<m_command_info.place()+m_command_info.time()
  259. <<", 车位楼层:"<<confirm_response.confirm_alloc_space_info().floor()
  260. <<", 车位序号:"<<confirm_response.confirm_alloc_space_info().index()
  261. <<", 车牌号:"<<confirm_response.confirm_alloc_space_info().car_info().license();*/
  262. return SUCCESS;
  263. }
  264. else
  265. return Error_manager(FAILED,MINOR_ERROR,"parkspace confirm response error_code error");
  266. }
  267. /*
  268. * 回退车位分配
  269. */
  270. Error_manager StoreProcessTask::back_alloc_space_step()
  271. {
  272. /*
  273. * 检查是否曾经分配过车位
  274. */
  275. if(m_parcspace_alloc_response_msg.has_allocated_space_info()==false)
  276. {
  277. return Error_manager(FAILED,MINOR_ERROR," parkspace release request without space info");
  278. }
  279. /*
  280. * 检查车位管理模块是否正常
  281. */
  282. Error_manager code=Parkspace_communicator::get_instance_pointer()->check_statu();
  283. if(code!=SUCCESS)
  284. return code;
  285. message::Parkspace_release_request_msg request;
  286. message::Base_info base_info;
  287. base_info.set_msg_type(message::eParkspace_release_request_msg);
  288. base_info.set_sender(message::eMain);
  289. base_info.set_receiver(message::eParkspace);
  290. base_info.set_timeout_ms(1000); //测量超时1s
  291. request.mutable_base_info()->CopyFrom(base_info);
  292. message::Parkspace_info space_info=m_parcspace_alloc_response_msg.allocated_space_info();
  293. request.mutable_release_space_info()->CopyFrom(space_info);
  294. request.set_command_key(create_key());
  295. message::Parkspace_release_response_msg release_response;
  296. code=Parkspace_communicator::get_instance_pointer()->release_request(request,release_response,m_cancel_condition);
  297. if(code!=SUCCESS)
  298. return code;
  299. if(release_response.error_manager().error_code()==0) {
  300. /*LOG(WARNING)<<"停车流程异常,释放车位成功,停车终端:"<<m_terminor_id
  301. <<", 指令id:"<<m_command_info.place()+m_command_info.time()
  302. <<", 车位楼层:"<<m_parcspace_alloc_response_msg.allocated_space_info().floor()
  303. <<", 车位序号:"<<m_parcspace_alloc_response_msg.allocated_space_info().index()
  304. <<", 车牌号:"<<m_parcspace_alloc_response_msg.allocated_space_info().car_info().license();*/
  305. m_alloc_request_msg=message::Parkspace_allocation_request_msg();
  306. m_parcspace_alloc_response_msg=message::Parkspace_allocation_response_msg();
  307. return SUCCESS;
  308. }
  309. else
  310. return Error_manager(FAILED,MINOR_ERROR,"parkspace release response error_code error");
  311. }
  312. void StoreProcessTask::Main()
  313. {
  314. /*
  315. * 外部已经分配好车位,进入到此流程说明车位已经分配好, 存放在 m_parcspace_alloc_response_msg
  316. */
  317. Error_manager code;
  318. //开始执行停车指令
  319. while(m_cancel_condition.wait_for_millisecond(1)==false)
  320. {
  321. //第一步,测量
  322. if (m_step_statu == eStoring_step::eMeasure_step)
  323. {
  324. //开始定位
  325. updata_step_statu_msg(message::eWorking);
  326. code = locate_step();
  327. usleep(1000 * 1000 * (rand() % 5 + 1));
  328. code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eComplete);
  329. LOG_IF(ERROR, code != SUCCESS) << "测量失败:" << code.get_error_description();
  330. m_step_statu = (code != SUCCESS) ? eStoring_step::eBackAlloc_step : eStoring_step::eCompare_step;
  331. }
  332. if(m_step_statu==eStoring_step::eCompare_step)
  333. {
  334. updata_step_statu_msg(message::eWorking);
  335. code=compare_step();
  336. usleep(500*1000);
  337. code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eComplete);
  338. LOG_IF(ERROR, code != SUCCESS) << "检验失败:" << code.get_error_description();
  339. m_step_statu = (code != SUCCESS) ? eStoring_step::eBackMeasure_step : eStoring_step::eDispatch_step;
  340. }
  341. //第二步,调度
  342. if (m_step_statu == eStoring_step::eDispatch_step)
  343. {
  344. //开始调度
  345. updata_step_statu_msg(message::eWorking);
  346. code = dispatch_step();
  347. usleep(1000 * 1000 * (rand() % 5));
  348. code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eComplete);
  349. LOG_IF(ERROR, code != SUCCESS) << "调度失败:" << code.get_error_description();
  350. m_step_statu = (code != SUCCESS) ? eStoring_step::eBack_compare_step : eStoring_step::eConfirm_step;
  351. }
  352. //第三步,占据车位
  353. if (m_step_statu == eStoring_step::eConfirm_step)
  354. {
  355. updata_step_statu_msg(message::eWorking);
  356. code = confirm_space_step();
  357. usleep(1000 * 1000);
  358. code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eComplete);
  359. LOG_IF(ERROR, code != SUCCESS) << "终端号:" << m_terminor_id << "停车流程:" << code.get_error_description() <<
  360. " 车位id :"
  361. << m_parcspace_alloc_response_msg.allocated_space_info().parkspace_id()
  362. << ",车牌:" << m_car_info.license()<<code.to_string();
  363. //最后一步故障,提升故障等级,急停
  364. m_step_statu = (code != SUCCESS) ? eStoring_step::eBackDispatch_step : eStoring_step::eComplete;
  365. }
  366. //第四步,完成,退出循环
  367. if (m_step_statu == eStoring_step::eComplete)
  368. {
  369. //流程结束前,保证至少发送一次流程完成状态
  370. updata_step_statu_msg(message::eComplete);
  371. break;
  372. }
  373. //回退confirm ------------------------------------华丽的分割线------------------------------------------
  374. if (m_step_statu == eStoring_step::eBackConfirm_step)
  375. {
  376. updata_step_statu_msg(message::eWorking);
  377. usleep(1000*1000);
  378. updata_step_statu_msg(message::eComplete);
  379. m_step_statu=eStoring_step::eBackDispatch_step;
  380. }
  381. if(m_step_statu==eStoring_step::eBackDispatch_step)
  382. {
  383. updata_step_statu_msg(message::eWorking);
  384. code=back_dispatch_step();
  385. usleep(1000*1000);
  386. code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eComplete);
  387. if(code!=SUCCESS)
  388. {
  389. //提升错误等级为四级
  390. break;
  391. }
  392. else
  393. {
  394. m_step_statu=eStoring_step::eBack_compare_step;
  395. }
  396. }
  397. if(m_step_statu==eStoring_step::eBack_compare_step)
  398. {
  399. updata_step_statu_msg(message::eWorking);
  400. code=back_compare_step();
  401. usleep(1000*1000);
  402. code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eComplete);
  403. if(code!=SUCCESS)
  404. {
  405. //提升错误等级为四级
  406. break;
  407. }
  408. else
  409. {
  410. m_step_statu=eStoring_step::eBackMeasure_step;
  411. }
  412. }
  413. if(m_step_statu==eStoring_step::eBackMeasure_step)
  414. {
  415. updata_step_statu_msg(message::eWorking);
  416. code=back_locate_step();
  417. usleep(1000*1000);
  418. code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eComplete);
  419. if(code!=SUCCESS)
  420. {
  421. //提升错误等级为四级
  422. break;
  423. }
  424. else
  425. {
  426. m_step_statu=eStoring_step::eBackAlloc_step;
  427. }
  428. }
  429. if(m_step_statu==eStoring_step::eBackAlloc_step)
  430. {
  431. updata_step_statu_msg(message::eWorking);
  432. code=back_alloc_space_step();
  433. usleep(1000*1000);
  434. code!=SUCCESS?updata_step_statu_msg(message::eError):updata_step_statu_msg(message::eComplete);
  435. if(code!=SUCCESS)
  436. {
  437. //提升错误等级为四级
  438. break;
  439. }
  440. else
  441. {
  442. m_step_statu=eStoring_step::eBackComplete;
  443. }
  444. }
  445. if(m_step_statu==eStoring_step::eBackComplete)
  446. {
  447. updata_step_statu_msg(message::eComplete);
  448. break;
  449. }
  450. }
  451. /*
  452. * 跳出循环后,判断状态,是否正常结束, 循环跳出状态只有可能是 eBackComplete(异常结束),eComplete(正常结束),任务取消状态
  453. */
  454. if(m_cancel_condition.wait_for_millisecond(1)==true) {
  455. LOG(ERROR) << "停车任务被强制取消,车牌号:" << m_car_info.license()
  456. << ", 终端号:" << m_terminor_id;
  457. return ;
  458. }
  459. if(m_step_statu==eStoring_step::eBackComplete)
  460. {
  461. //异常结束
  462. usleep(1000*1000);
  463. LOG(ERROR)<<"异常停车,回退结束"<<"车牌号:"<<m_car_info.license()
  464. <<",xxxxxxxxxxxxxx 终端:"<<m_terminor_id<<" xxxxxxxxxxxxxx";
  465. }
  466. if(m_step_statu==eStoring_step::eComplete)
  467. {
  468. //正常结束
  469. usleep(1000*500);
  470. LOG(INFO)<<"停车结束,"<<"车牌号:"<<m_car_info.license()
  471. <<",-------------- 终端:"<<m_terminor_id<<" --------------";
  472. }
  473. }
  474. /*
  475. * 发布状态线程
  476. */
  477. void StoreProcessTask::publish_thread_func(StoreProcessTask* ptask)
  478. {
  479. if(ptask)
  480. {
  481. ptask->publish_step_status();
  482. }
  483. }
  484. void StoreProcessTask::publish_step_status()
  485. {
  486. //未收到退出信号
  487. while(false==m_publish_exit_condition.wait_for_ex(std::chrono::milliseconds(50)))
  488. {
  489. /*
  490. * 通过communicator 发布状态
  491. */
  492. if(System_communicator::get_instance_pointer())
  493. {
  494. std::lock_guard<std::mutex> lock(m_process_msg_lock);
  495. System_communicator::get_instance_pointer()->post_process_statu(m_process_msg);
  496. }
  497. }
  498. }
  499. /*
  500. * 根据当前流程状态,生成状态消息
  501. */
  502. void StoreProcessTask::updata_step_statu_msg(message::Step_statu statu)
  503. {
  504. std::lock_guard<std::mutex> lock(m_process_msg_lock);
  505. switch (m_step_statu) {
  506. case eStoring_step::eAlloc_step: {
  507. message::Alloc_space_step_statu alloc_step_statu;
  508. alloc_step_statu.set_step_statu(statu);
  509. m_process_msg.mutable_alloc_space_step()->CopyFrom(alloc_step_statu);
  510. break;
  511. }
  512. case eStoring_step::eMeasure_step: {
  513. message::Measure_step_statu measure_step_statu;
  514. measure_step_statu.set_step_statu(statu);
  515. measure_step_statu.mutable_locate_info()->CopyFrom(m_locate_info);
  516. m_process_msg.mutable_measure_step()->CopyFrom(measure_step_statu);
  517. break;
  518. }
  519. case eStoring_step::eCompare_step:{
  520. message::Compare_step_statu compare_step;
  521. compare_step.mutable_locate_info_wj()->CopyFrom(m_locate_info);
  522. compare_step.mutable_locate_info_dj()->CopyFrom(m_measure_response_msg.locate_information());
  523. compare_step.mutable_locate_info_result()->CopyFrom(m_compare_location_data);
  524. compare_step.set_step_statu(statu);
  525. m_process_msg.mutable_compare_step()->CopyFrom(compare_step);
  526. break;
  527. }
  528. case eStoring_step::eDispatch_step: {
  529. message::Dispatch_store_step_statu dispatch_step_statu;
  530. dispatch_step_statu.set_step_statu(statu);
  531. dispatch_step_statu.mutable_locate_info()->CopyFrom(m_locate_info);
  532. dispatch_step_statu.mutable_space_info()->CopyFrom(m_parcspace_alloc_response_msg.allocated_space_info());
  533. m_process_msg.mutable_dispatch_step()->CopyFrom(dispatch_step_statu);
  534. break;
  535. }
  536. case eStoring_step::eConfirm_step: {
  537. message::Confirm_space_step_statu confirm_step_statu;
  538. confirm_step_statu.set_step_statu(statu);
  539. confirm_step_statu.mutable_space_info()->CopyFrom(m_parcspace_alloc_response_msg.allocated_space_info());
  540. m_process_msg.mutable_confirm_space_step()->CopyFrom(confirm_step_statu);
  541. break;
  542. }
  543. case eStoring_step::eComplete: {
  544. m_process_msg.set_completed(true);
  545. break;
  546. }
  547. case eStoring_step::eBackConfirm_step: {
  548. message::Back_confirm_space_step_statu back_confirm_step_statu;
  549. back_confirm_step_statu.set_step_statu(statu);
  550. m_process_msg.mutable_back_confirm_step()->CopyFrom(back_confirm_step_statu);
  551. break;
  552. }
  553. case eStoring_step::eBackDispatch_step: {
  554. message::Back_dispatch_store_step_statu back_dispatch_step_statu;
  555. back_dispatch_step_statu.set_step_statu(statu);
  556. back_dispatch_step_statu.mutable_space_info()->CopyFrom(m_parcspace_alloc_response_msg.allocated_space_info());
  557. back_dispatch_step_statu.mutable_locate_info()->CopyFrom(m_compare_location_data);
  558. m_process_msg.mutable_back_dispatch_step()->CopyFrom(back_dispatch_step_statu);
  559. break;
  560. }
  561. case eStoring_step::eBack_compare_step:{
  562. message::Back_compare_step_statu back_compare_step_statu;
  563. back_compare_step_statu.set_step_statu(statu);
  564. back_compare_step_statu.mutable_locate_info_wj()->CopyFrom(m_locate_info);
  565. back_compare_step_statu.mutable_locate_info_dj()->CopyFrom(m_measure_response_msg.locate_information());
  566. back_compare_step_statu.mutable_locate_info_result()->CopyFrom(m_compare_location_data);
  567. m_process_msg.mutable_back_compare_step()->CopyFrom(back_compare_step_statu);
  568. break;
  569. }
  570. case eStoring_step::eBackMeasure_step: {
  571. message::Back_measure_step_statu back_measure_step_statu;
  572. back_measure_step_statu.set_step_statu(statu);
  573. m_process_msg.mutable_back_measure_step()->CopyFrom(back_measure_step_statu);
  574. break;
  575. }
  576. case eStoring_step::eBackAlloc_step: {
  577. message::Back_alloc_space_step_statu back_alloc_step_statu;
  578. back_alloc_step_statu.set_step_statu(statu);
  579. back_alloc_step_statu.mutable_space_info()->CopyFrom(m_parcspace_alloc_response_msg.allocated_space_info());
  580. m_process_msg.mutable_back_alloc_space_step()->CopyFrom(back_alloc_step_statu);
  581. break;
  582. }
  583. case eStoring_step::eBackComplete: {
  584. m_process_msg.set_back_completed(true);
  585. break;
  586. }
  587. default:
  588. break;
  589. }
  590. }
  591. /*
  592. * 初始化 接收到的消息
  593. */
  594. void StoreProcessTask::reset_msg() {
  595. m_alloc_request_msg = message::Parkspace_allocation_request_msg();
  596. m_measure_request_msg = message::Measure_request_msg();
  597. m_dispatch_request_msg = message::Dispatch_request_msg();
  598. m_confirm_request_msg = message::Parkspace_confirm_alloc_request_msg();
  599. m_locate_info = message::Locate_information();
  600. m_measure_response_msg = message::Measure_response_msg(); //测量模块的测量数据
  601. m_parcspace_alloc_response_msg = message::Parkspace_allocation_response_msg(); //分配的车位数据
  602. m_dispatch_response_msg = message::Dispatch_response_msg(); //调度模块的反馈数据
  603. }