command_manager.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 <thread>
  12. #include <communication_message.h>
  13. #include "thread_condition.h"
  14. #include "singleton.h"
  15. #include "TaskQueue/TQFactory.h"
  16. #include "process_message.pb.h"
  17. class Command_manager :public Singleton<Command_manager>{
  18. friend Singleton<Command_manager>;
  19. public:
  20. ~Command_manager();
  21. /*
  22. * 初始化函数,创建线程池,创建状态广播线程,
  23. */
  24. Error_manager init();
  25. /*
  26. * 执行停车请求
  27. */
  28. Error_manager execute_store_command(message::Store_command_request_msg& request,message::Store_command_response_msg& response);
  29. /*
  30. * 执行取车请求
  31. */
  32. Error_manager execute_pickup_command(message::Pickup_command_request_msg& request,message::Pickup_command_response_msg& response);
  33. /*
  34. * 更新状态
  35. */
  36. void updata_store_entrance_statu(int command_id,message::Entrance_statu statu);
  37. void updata_pickup_entrance_statu(int command_id,message::Entrance_statu statu);
  38. private:
  39. Command_manager();
  40. static void publish_thread_func(Command_manager* p_commander);
  41. void publish_status();
  42. protected:
  43. std::thread* m_publish_statu_thread; //广播状态线程
  44. Thread_condition m_publish_exit_condition; //发送的条件变量
  45. std::mutex m_entrance_msg_lock;
  46. message::Entrance_statu_msg m_entrance_status; //出入口状态
  47. tq::IQueue* m_thread_queue_process; //指令流程线程池
  48. };
  49. #endif //NNXX_TESTS_COMMAND_MANAGER_H