StoreProcessTask.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. public:
  13. StoreProcessTask(unsigned int command_id);
  14. virtual ~StoreProcessTask();
  15. Error_manager init_task(message::Command_info command_info,
  16. message::Locate_information locate_info,message::Car_info car_info);
  17. /*
  18. * 检查当前任务是否处于空闲准备状态
  19. */
  20. bool is_ready();
  21. /*
  22. * 分配车位
  23. */
  24. Error_manager alloc_space();
  25. protected:
  26. virtual void Main();
  27. /*
  28. * 定位
  29. */
  30. Error_manager locate_step();
  31. /*
  32. * 调度
  33. */
  34. Error_manager dispatch_step();
  35. /*
  36. * 车位占用确认
  37. */
  38. Error_manager confirm_space_step();
  39. /*
  40. * 车位解锁,当停车失败时需要车位解锁
  41. */
  42. Error_manager release_space_step();
  43. /*
  44. * reset 进度信息
  45. */
  46. void reset_process_statu();
  47. /*
  48. * 初始化 接收到的消息
  49. */
  50. void reset_recv_msg();
  51. /*
  52. * 发布进度
  53. */
  54. static void publish_thread_func(StoreProcessTask* p_commander);
  55. void publish_step_status();
  56. protected:
  57. message::Command_info m_command_info;
  58. unsigned int m_terminor_id;
  59. message::Car_info m_car_info; //当前流程的车辆标识(车牌号)
  60. //停车请求发送过来的测量数据,终端位置的测量数据
  61. message::Locate_information m_locate_info;
  62. //以下的流程中产生的数据
  63. message::Measure_response_msg m_measure_response_msg; //测量模块的测量数据
  64. message::Parkspace_allocation_response_msg m_parcspace_alloc_response_msg; //分配的车位数据
  65. message::Dispatch_response_msg m_dispatch_response_msg; //调度模块的反馈数据
  66. std::mutex m_storing_statu_lock;
  67. message::Storing_process_statu_msg m_storing_process_statu_msg; //停车流程进度信息
  68. private:
  69. std::thread* m_publish_statu_thread; //广播状态线程
  70. Thread_condition m_publish_exit_condition; //发送的条件变量
  71. };
  72. #endif //NNXX_TESTS_STOREPROCESS_H