StoreProcessTask.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. eDispatch_step,
  17. eConfirm_step,
  18. eComplete,
  19. eBackConfirm_step,
  20. eBackDispatch_step,
  21. eBackMeasure_step,
  22. eBackAlloc_step,
  23. eBackComplete
  24. };
  25. public:
  26. StoreProcessTask(unsigned int command_id);
  27. virtual ~StoreProcessTask();
  28. Error_manager init_task(message::Locate_information locate_info,message::Car_info car_info);
  29. /*
  30. * 分配车位
  31. */
  32. Error_manager alloc_space();
  33. /*
  34. * 回退分配车位
  35. */
  36. Error_manager back_alloc_space_step();
  37. protected:
  38. virtual void Main();
  39. /*
  40. * 定位
  41. */
  42. Error_manager locate_step();
  43. /*
  44. * 回退定位
  45. */
  46. Error_manager back_locate_step();
  47. /*
  48. * 调度
  49. */
  50. Error_manager dispatch_step();
  51. /*
  52. * 回退调度
  53. */
  54. Error_manager back_dispatch_step();
  55. /*
  56. * 车位占用确认
  57. */
  58. Error_manager confirm_space_step();
  59. /*
  60. * 初始化 接收到的消息
  61. */
  62. void reset_msg();
  63. /*
  64. * 发布进度
  65. */
  66. static void publish_thread_func(StoreProcessTask* p_commander);
  67. void publish_step_status();
  68. /*
  69. * 根据当前流程状态,生成状态消息
  70. */
  71. Error_manager create_step_statu_msg(message::Storing_process_statu_msg& msg);
  72. protected:
  73. unsigned int m_terminor_id;
  74. message::Car_info m_car_info; //当前流程的车辆标识(车牌号)
  75. message::Locate_information m_locate_info;
  76. //保存请求
  77. message::Parkspace_allocation_request_msg m_alloc_request_msg;
  78. message::Measure_request_msg m_measure_request_msg;
  79. message::Dispatch_request_msg m_dispatch_request_msg;
  80. message::Parkspace_confirm_alloc_request_msg m_confirm_request_msg;
  81. //停车请求发送过来的测量数据,终端位置的测量数据
  82. message::Measure_response_msg m_measure_response_msg; //测量模块的测量数据
  83. message::Parkspace_allocation_response_msg m_parcspace_alloc_response_msg; //分配的车位数据
  84. message::Dispatch_response_msg m_dispatch_response_msg; //调度模块的反馈数据
  85. private:
  86. std::thread* m_publish_statu_thread; //广播状态线程
  87. Thread_condition m_publish_exit_condition; //发送的条件变量
  88. eStoring_step m_step_statu;
  89. };
  90. #endif //NNXX_TESTS_STOREPROCESS_H