StoreProcessTask.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. //
  2. // Created by zx on 2020/7/7.
  3. //
  4. #ifndef NNXX_TESTS_STOREPROCESS_H
  5. #define NNXX_TESTS_STOREPROCESS_H
  6. #include <parkspace_allocation_message.pb.h>
  7. #include "dispatch_communicator.h"
  8. #include "TaskQueue/BaseTask.h"
  9. #include "Locate_communicator.h"
  10. #include "process_message.pb.h"
  11. class StoreProcessTask :public tq::BaseTask{
  12. enum eStoring_step
  13. {
  14. eAlloc_step=0,
  15. eMeasure_step,
  16. eCompare_step,
  17. eDispatch_step,
  18. eConfirm_step,
  19. eComplete,
  20. eBackConfirm_step,
  21. eBackDispatch_step,
  22. eBack_compare_step,
  23. eBackMeasure_step,
  24. eBackAlloc_step,
  25. eBackComplete
  26. };
  27. public:
  28. StoreProcessTask(unsigned int command_id);
  29. virtual ~StoreProcessTask();
  30. unsigned int terminal_id(){return m_terminor_id;}
  31. Error_manager init_task(message::Locate_information locate_info,message::Car_info car_info);
  32. /*
  33. * 分配车位
  34. */
  35. Error_manager alloc_space();
  36. /*
  37. * 回退分配车位
  38. */
  39. Error_manager back_alloc_space_step();
  40. /*
  41. * 取消任务
  42. */
  43. virtual void Cancel();
  44. /*
  45. * 获取任务类型
  46. */
  47. virtual tq::TaskCategory GetCategory() const{ return message::eStoring;}
  48. protected:
  49. virtual void Main();
  50. /*
  51. * 定位
  52. */
  53. Error_manager locate_step();
  54. /*
  55. * 回退定位
  56. */
  57. Error_manager back_locate_step();
  58. /*
  59. * 调度
  60. */
  61. Error_manager dispatch_step();
  62. /*
  63. * 回退调度
  64. */
  65. Error_manager back_dispatch_step();
  66. /*
  67. * 车位占用确认
  68. */
  69. Error_manager confirm_space_step();
  70. /*
  71. * 初始化 接收到的消息
  72. */
  73. void reset_msg();
  74. /*
  75. * 发布进度
  76. */
  77. static void publish_thread_func(StoreProcessTask* p_commander);
  78. void publish_step_status();
  79. /*
  80. * 根据当前流程状态,生成状态消息
  81. */
  82. Error_manager updata_step_statu_msg();
  83. protected:
  84. unsigned int m_terminor_id;
  85. message::Car_info m_car_info; //当前流程的车辆标识(车牌号)
  86. message::Locate_information m_locate_info;
  87. //保存请求
  88. message::Parkspace_allocation_request_msg m_alloc_request_msg;
  89. message::Measure_request_msg m_measure_request_msg;
  90. message::Locate_information m_compare_location_data;
  91. message::Dispatch_request_msg m_dispatch_request_msg;
  92. message::Parkspace_confirm_alloc_request_msg m_confirm_request_msg;
  93. //停车请求发送过来的测量数据,终端位置的测量数据
  94. message::Measure_response_msg m_measure_response_msg; //测量模块的测量数据
  95. message::Parkspace_allocation_response_msg m_parcspace_alloc_response_msg; //分配的车位数据
  96. message::Dispatch_response_msg m_dispatch_response_msg; //调度模块的反馈数据
  97. private:
  98. std::thread* m_publish_statu_thread; //广播状态线程
  99. Thread_condition m_publish_exit_condition; //发送的条件变量
  100. eStoring_step m_step_statu;
  101. message::Storing_process_statu_msg m_process_msg;
  102. Thread_condition m_cancel_condition; //取消任务标志位
  103. };
  104. #endif //NNXX_TESTS_STOREPROCESS_H