// // Created by zx on 2020/7/7. // #ifndef NNXX_TESTS_STOREPROCESS_H #define NNXX_TESTS_STOREPROCESS_H #include #include "dispatch_communicator.h" #include "TaskQueue/BaseTask.h" #include "Locate_communicator.h" #include "process_message.pb.h" class StoreProcessTask :public tq::BaseTask{ enum eStoring_step { eAlloc_step=0, eMeasure_step, eCompare_step, eDispatch_step, eConfirm_step, eComplete, eBackConfirm_step, eBackDispatch_step, eBack_compare_step, eBackMeasure_step, eBackAlloc_step, eBackComplete }; public: StoreProcessTask(unsigned int command_id); virtual ~StoreProcessTask(); unsigned int terminal_id(){return m_terminor_id;} Error_manager init_task(message::Locate_information locate_info,message::Car_info car_info); /* * 分配车位 */ Error_manager alloc_space(); /* * 回退分配车位 */ Error_manager back_alloc_space_step(); /* * 取消任务 */ virtual void Cancel(); /* * 获取任务类型 */ virtual tq::TaskCategory GetCategory() const{ return message::eStoring;} protected: virtual void Main(); /* * 定位 */ Error_manager locate_step(); /* * 回退定位 */ Error_manager back_locate_step(); /* * 调度 */ Error_manager dispatch_step(); /* * 回退调度 */ Error_manager back_dispatch_step(); /* * 车位占用确认 */ Error_manager confirm_space_step(); /* * 初始化 接收到的消息 */ void reset_msg(); /* * 发布进度 */ static void publish_thread_func(StoreProcessTask* p_commander); void publish_step_status(); /* * 根据当前流程状态,生成状态消息 */ Error_manager updata_step_statu_msg(); protected: unsigned int m_terminor_id; message::Car_info m_car_info; //当前流程的车辆标识(车牌号) message::Locate_information m_locate_info; //保存请求 message::Parkspace_allocation_request_msg m_alloc_request_msg; message::Measure_request_msg m_measure_request_msg; message::Locate_information m_compare_location_data; message::Dispatch_request_msg m_dispatch_request_msg; message::Parkspace_confirm_alloc_request_msg m_confirm_request_msg; //停车请求发送过来的测量数据,终端位置的测量数据 message::Measure_response_msg m_measure_response_msg; //测量模块的测量数据 message::Parkspace_allocation_response_msg m_parcspace_alloc_response_msg; //分配的车位数据 message::Dispatch_response_msg m_dispatch_response_msg; //调度模块的反馈数据 private: std::thread* m_publish_statu_thread; //广播状态线程 Thread_condition m_publish_exit_condition; //发送的条件变量 eStoring_step m_step_statu; message::Storing_process_statu_msg m_process_msg; Thread_condition m_cancel_condition; //取消任务标志位 }; #endif //NNXX_TESTS_STOREPROCESS_H