command_manager.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // Created by zx on 2020/7/14.
  3. //
  4. /*
  5. * 指令管理, 包括指令的接收,指令的执行控制,指令的状态追踪,出入口状态检查
  6. */
  7. #ifndef NNXX_TESTS_COMMAND_MANAGER_H
  8. #define NNXX_TESTS_COMMAND_MANAGER_H
  9. #include <error_code.h>
  10. #include <terminal_message.pb.h>
  11. #include <communication_message.h>
  12. #include "thread_condition.h"
  13. #include "singleton.h"
  14. #include "TaskQueue/TQFactory.h"
  15. #include "TaskQueue/BaseTask.h"
  16. #include "process_message.pb.h"
  17. #include "thread_safe_map.h"
  18. #include "system_setting.pb.h"
  19. class Command_manager :public Singleton<Command_manager>{
  20. friend Singleton<Command_manager>;
  21. public:
  22. ~Command_manager();
  23. /*
  24. * 初始化函数,创建线程池,创建状态广播线程,根据配置创建停取车流程
  25. */
  26. Error_manager init(setting::System_setting system_setting);
  27. /*
  28. * 执行停车请求
  29. */
  30. Error_manager execute_store_command(message::Store_command_request_msg& request,message::Store_command_response_msg& response);
  31. /*
  32. * 执行取车请求
  33. */
  34. Error_manager execute_pickup_command(message::Pickup_command_request_msg& request,message::Pickup_command_response_msg& response);
  35. private:
  36. Command_manager();
  37. protected:
  38. /*
  39. * 停取车终端 map,key值为终端编号,value为终端指令执行器task,可放入线程池执行流程
  40. */
  41. thread_safe_map<int,tq::BaseTask*> m_store_command_task_map;
  42. thread_safe_map<int,tq::BaseTask*> m_pick_command_task_map;
  43. tq::IQueue* m_thread_queue_process; //指令流程线程池
  44. };
  45. #endif //NNXX_TESTS_COMMAND_MANAGER_H