// // Created by zx on 2020/7/7. // #ifndef NNXX_TESTS_TAKEPROCESS_H #define NNXX_TESTS_TAKEPROCESS_H #include #include "process_message.pb.h" #include "error_code.h" #include "TaskQueue/BaseTask.h" #include "dispatch_communicator.h" class PickupProcessTask :public tq::BaseTask{ enum ePicking_step { eSearch_step=0, //查询数据库 eDispatch_step, //调度 eWait_step, //等待车辆离开 eRelease_step, //释放车位 eComplete, //完成 eBackWait_step, eBackDispatch_step, eBackSearch_step, eBackComplete }; public: PickupProcessTask(unsigned int terminal_id); virtual ~PickupProcessTask(); unsigned int terminal_id(){return m_terminor_id;} Error_manager init_task(message::Car_info car_info); virtual tq::TaskCategory GetCategory() const{ return message::ePicking;} /* * 取消任务 */ virtual void Cancel(); /* * 查询车位 */ Error_manager search_space(); /* * 回退查询车位 */ Error_manager back_search_space_step(); protected: virtual void Main(); /* * 执行取车动作请求,并等待执行完成 */ Error_manager dispatch_step(); /* * 回退执行取车动作请求,并等待执行完成 */ Error_manager back_dispatch_step(); /* * 等待车辆离开 */ Error_manager wait_for_leave_step(); /* * 回退等待车辆离开 */ Error_manager back_wait_for_leave_step(); /* * 清除车位表中对应的车位 */ Error_manager release_space_step(); /* * 回退清除车位表中对应的车位 */ Error_manager back_release_space_step(); /* * 发布进度 */ static void publish_thread_func(PickupProcessTask* p_commander); void publish_step_status(); /* * 根据当前流程状态,生成状态消息 */ Error_manager updata_step_statu_msg(); void reset_recv_msg(); protected: unsigned int m_terminor_id; message::Car_info m_car_info; //当前流程的车辆信息 std::thread* m_publish_statu_thread; //广播状态线程 Thread_condition m_publish_exit_condition; //发送的条件变量 private: //查询到的车位信息 message::Parkspace_search_request_msg m_search_request_msg; message::Parkspace_search_response_msg m_search_response_msg; //取车调度反馈信息 message::Dispatch_request_msg m_dispatch_request_msg; message::Dispatch_response_msg m_dispatch_response_msg; ePicking_step m_step_statu; Thread_condition m_cancel_condition; message::Picking_process_statu_msg m_process_msg; }; #endif //NNXX_TESTS_TAKEPROCESS_H