123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- //
- // Created by zx on 2020/8/26.
- //
- #ifndef NNXX_TESTS_PROCESS_TASK_H
- #define NNXX_TESTS_PROCESS_TASK_H
- #include "thread_condition.h"
- #include "TaskQueue/BaseTask.h"
- #include "process_message.pb.h"
- /*
- * 停取车流程基类, 包括任务创建, 状态消息发布线程启动, 任务取消等公共功能
- * 该类继承自tq::BaseTask类, 可让入 tq 线程池, 执行虚函数 Main
- * 派生出 停车任务类(StoreProcessTask)与取车任务类(PickupProcessTask)
- */
- class Process_task : public tq::BaseTask{
- protected:
- enum EStep_type
- {
- eAlloc_step=0,
- eMeasure_step,
- eCompare_step,
- eDispatch_step,
- eConfirm_step,
- eSearch_step, //查询数据库
- eWait_step, //等待车辆离开
- eRelease_step, //释放车位
- eComplete, //完成
- eBackConfirm_step,
- eBack_compare_step,
- eBackMeasure_step,
- eBackAlloc_step,
- eBackWait_step,
- eBackDispatch_step,
- eBackSearch_step,
- eBackComplete
- };
- public:
- Process_task(unsigned int command_id,message::Car_info car_info);
- virtual ~Process_task();
- unsigned int terminal_id(){return m_terminor_id;}
- std::string license(){ return m_car_info.license();}
- EStep_type step_type(){return m_step_type;}
- /*
- * 取消任务
- */
- virtual void Cancel();
- /*
- * 任务是否取消
- */
- virtual bool is_canceled();
- protected:
- /*
- * 发布进度消息
- */
- static void publish_thread_func(Process_task* ptask);
- virtual void publish_step_status()=0;
- protected:
- unsigned int m_terminor_id;
- message::Car_info m_car_info; //当前流程的车辆信息
- EStep_type m_step_type;
- std::thread* m_publish_statu_thread; //广播状态线程
- Thread_condition m_publish_exit_condition; //发送的条件变量
- Thread_condition m_cancel_condition; //取消任务标志位
- std::mutex m_process_msg_lock; //状态消息锁
- };
- #endif //NNXX_TESTS_PROCESS_TASK_H
|