123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- //
- // Created by zx on 2020/7/14.
- //
- /*
- * 指令管理, 包括指令的接收,指令的执行控制,指令的状态追踪,出入口状态检查
- */
- #ifndef NNXX_TESTS_COMMAND_MANAGER_H
- #define NNXX_TESTS_COMMAND_MANAGER_H
- #include <error_code.h>
- #include <terminal_message.pb.h>
- #include <communication_message.h>
- #include "thread_condition.h"
- #include "singleton.h"
- #include "TaskQueue/TQFactory.h"
- #include "TaskQueue/BaseTask.h"
- #include "central_control_message.pb.h"
- #include "thread_safe_map.h"
- #include "system_setting.pb.h"
- class Command_manager :public Singleton<Command_manager>{
- friend Singleton<Command_manager>;
- public:
- ~Command_manager();
- /*
- * 初始化函数,创建线程池,创建状态广播线程,根据配置创建停取车流程
- */
- Error_manager init(setting::System_setting system_setting);
- /*
- * 执行停车请求
- */
- Error_manager execute_store_command(message::Store_command_request_msg& request);
- /*
- * 执行取车请求
- */
- Error_manager execute_pickup_command(message::Pickup_command_request_msg& request);
- /*
- * 控制入口 开放或者关闭
- */
- Error_manager pause_entrance(int terminal_id,bool paused);
- /*
- * 获取出入口状态
- */
- message::Entrance_statu entrance_statu(int terminal_id);
- message::Entrance_statu export_statu(int terminal_id);
- /*
- * 控制出口 开放或者关闭
- */
- Error_manager pause_export(int terminal_id, bool paused);
- /*
- * pause,系统急停,急停状态下不允许自动流程的指令执行,允许管理员手动指令执行
- */
- void pause_system();
- /*
- * 系统是否急停
- */
- bool is_paused(){return m_system_paused;}
- private:
- Command_manager();
- static void publish_statu_function(Command_manager* commander);
- void publish_statu();
- protected:
- tq::IQueue* m_thread_queue_process; //指令流程线程池
- bool m_system_paused;
- std::vector<bool> m_input_entrance_paused; //入口状态(关闭/开放)
- std::vector<bool> m_output_entrance_paused; //出口状态(关闭/开放)
- setting::System_setting m_system_setting;
- std::thread* m_publish_statu_thread; //广播状态线程
- Thread_condition m_publish_exit_condition; //发送的条件变量
- };
- #endif //NNXX_TESTS_COMMAND_MANAGER_H
|