PickupProcessTask.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //
  2. // Created by zx on 2020/7/7.
  3. //
  4. #ifndef NNXX_TESTS_TAKEPROCESS_H
  5. #define NNXX_TESTS_TAKEPROCESS_H
  6. #include <parkspace_allocation_message.pb.h>
  7. #include "process_message.pb.h"
  8. #include "error_code.h"
  9. #include "TaskQueue/BaseTask.h"
  10. #include "dispatch_communicator.h"
  11. class PickupProcessTask :public tq::BaseTask{
  12. enum ePicking_step
  13. {
  14. eSearch_step=0, //查询数据库
  15. eDispatch_step, //调度
  16. eWait_step, //等待车辆离开
  17. eRelease_step, //释放车位
  18. eComplete, //完成
  19. eBackWait_step,
  20. eBackDispatch_step,
  21. eBackSearch_step,
  22. eBackComplete
  23. };
  24. public:
  25. PickupProcessTask(unsigned int terminal_id);
  26. virtual ~PickupProcessTask();
  27. Error_manager init_task(message::Car_info car_info);
  28. /*
  29. * 检查当前任务是否处于空闲准备状态
  30. */
  31. bool is_ready();
  32. /*
  33. * 查询车位
  34. */
  35. Error_manager search_space();
  36. /*
  37. * 回退查询车位
  38. */
  39. Error_manager back_search_space_step();
  40. protected:
  41. virtual void Main();
  42. /*
  43. * 执行取车动作请求,并等待执行完成
  44. */
  45. Error_manager dispatch_step();
  46. /*
  47. * 回退执行取车动作请求,并等待执行完成
  48. */
  49. Error_manager back_dispatch_step();
  50. /*
  51. * 等待车辆离开
  52. */
  53. Error_manager wait_for_leave_step();
  54. /*
  55. * 回退等待车辆离开
  56. */
  57. Error_manager back_wait_for_leave_step();
  58. /*
  59. * 清除车位表中对应的车位
  60. */
  61. Error_manager release_space_step();
  62. /*
  63. * 回退清除车位表中对应的车位
  64. */
  65. Error_manager back_release_space_step();
  66. /*
  67. * 发布进度
  68. */
  69. static void publish_thread_func(PickupProcessTask* p_commander);
  70. void publish_step_status();
  71. /*
  72. * 根据当前流程状态,生成状态消息
  73. */
  74. Error_manager create_step_statu_msg(message::Picking_process_statu_msg& msg);
  75. void reset_recv_msg();
  76. protected:
  77. unsigned int m_terminor_id;
  78. message::Car_info m_car_info; //当前流程的车辆信息
  79. std::thread* m_publish_statu_thread; //广播状态线程
  80. Thread_condition m_publish_exit_condition; //发送的条件变量
  81. private:
  82. //查询到的车位信息
  83. message::Parkspace_search_request_msg m_search_request_msg;
  84. message::Parkspace_search_response_msg m_search_response_msg;
  85. //取车调度反馈信息
  86. message::Dispatch_request_msg m_dispatch_request_msg;
  87. message::Dispatch_response_msg m_dispatch_response_msg;
  88. ePicking_step m_step_statu;
  89. };
  90. #endif //NNXX_TESTS_TAKEPROCESS_H