12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- //
- // Created by zx on 2020/8/26.
- //
- #ifndef NNXX_TESTS_PROCESS_TASK_H
- #define NNXX_TESTS_PROCESS_TASK_H
- #include <error_code.h>
- #include "thread_condition.h"
- #include "TaskQueue/BaseTask.h"
- #include "process_message.pb.h"
- #include <glog/logging.h>
- /*
- * 停取车流程基类, 包括任务创建, 状态消息发布线程启动, 任务取消等公共功能
- * 该类继承自tq::BaseTask类, 可放入 tq 线程池, 执行虚函数 Main
- * 派生出 停车任务类(StoreProcessTask)与取车任务类(PickupProcessTask)
- */
- class Process_task : public tq::BaseTask{
- 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();}
- message::Step_type current_step_type(){return m_current_step_type;}
- message::Step_statu current_step_statu(){return m_current_step_statu;}
- // 获取任务类型
- virtual message::Process_type get_process_type() const=0;
- /*
- * 取消任务
- */
- virtual void Cancel();
- /*
- * 任务是否取消
- */
- virtual bool is_canceled();
- /*
- * 控制流程到下一步
- */
- virtual Error_manager next_step(){
- LOG(ERROR)<<"process base virtual called";
- return ERROR;};
- virtual void updata_step_statu(message::Step_statu statu)=0;
- 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; //当前流程的车辆信息
- message::Step_type m_current_step_type; //当前流程正在哪一步
- message::Step_statu m_current_step_statu; //当前步骤所处的状态
- 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
|