PickupProcessTask.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. unsigned int terminal_id(){return m_terminor_id;}
  28. Error_manager init_task(message::Car_info car_info);
  29. virtual tq::TaskCategory GetCategory() const{ return message::ePicking;}
  30. /*
  31. * 取消任务
  32. */
  33. virtual void Cancel();
  34. /*
  35. * 查询车位
  36. */
  37. Error_manager search_space();
  38. /*
  39. * 回退查询车位
  40. */
  41. Error_manager back_search_space_step();
  42. protected:
  43. virtual void Main();
  44. /*
  45. * 执行取车动作请求,并等待执行完成
  46. */
  47. Error_manager dispatch_step();
  48. /*
  49. * 回退执行取车动作请求,并等待执行完成
  50. */
  51. Error_manager back_dispatch_step();
  52. /*
  53. * 等待车辆离开
  54. */
  55. Error_manager wait_for_leave_step();
  56. /*
  57. * 回退等待车辆离开
  58. */
  59. Error_manager back_wait_for_leave_step();
  60. /*
  61. * 清除车位表中对应的车位
  62. */
  63. Error_manager release_space_step();
  64. /*
  65. * 回退清除车位表中对应的车位
  66. */
  67. Error_manager back_release_space_step();
  68. /*
  69. * 发布进度
  70. */
  71. static void publish_thread_func(PickupProcessTask* p_commander);
  72. void publish_step_status();
  73. /*
  74. * 根据当前流程状态,生成状态消息
  75. */
  76. Error_manager updata_step_statu_msg();
  77. void reset_recv_msg();
  78. protected:
  79. unsigned int m_terminor_id;
  80. message::Car_info m_car_info; //当前流程的车辆信息
  81. std::thread* m_publish_statu_thread; //广播状态线程
  82. Thread_condition m_publish_exit_condition; //发送的条件变量
  83. private:
  84. //查询到的车位信息
  85. message::Parkspace_search_request_msg m_search_request_msg;
  86. message::Parkspace_search_response_msg m_search_response_msg;
  87. //取车调度反馈信息
  88. message::Dispatch_request_msg m_dispatch_request_msg;
  89. message::Dispatch_response_msg m_dispatch_response_msg;
  90. ePicking_step m_step_statu;
  91. Thread_condition m_cancel_condition;
  92. message::Picking_process_statu_msg m_process_msg;
  93. };
  94. #endif //NNXX_TESTS_TAKEPROCESS_H