command_manager.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 "central_control_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. enum Entrance_statu
  22. {
  23. Enable=0,
  24. Disable
  25. };
  26. public:
  27. ~Command_manager();
  28. /*
  29. * 初始化函数,创建线程池,创建状态广播线程,根据配置创建停取车流程
  30. */
  31. Error_manager init(setting::System_setting system_setting);
  32. /*
  33. * 执行停车请求
  34. */
  35. Error_manager execute_store_command(message::Store_command_request_msg& request,message::Store_command_response_msg& response);
  36. /*
  37. * 执行取车请求
  38. */
  39. Error_manager execute_pickup_command(message::Pickup_command_request_msg& request,message::Pickup_command_response_msg& response);
  40. /*
  41. * 控制入口 开放或者关闭
  42. */
  43. Error_manager enable_entrance(int terminal_id,bool enable);
  44. /*
  45. * 控制出口 开放或者关闭
  46. */
  47. Error_manager enable_export(int terminal_id,bool enable);
  48. /*
  49. * pause,系统急停,急停状态下不允许自动流程的指令执行,允许管理员手动指令执行
  50. */
  51. void pause_system();
  52. private:
  53. Command_manager();
  54. static void publish_statu_function(Command_manager* commander);
  55. void publish_statu();
  56. protected:
  57. tq::IQueue* m_thread_queue_process; //指令流程线程池
  58. bool m_system_paused;
  59. std::vector<Entrance_statu> m_input_entrance_statu; //入口状态(关闭/开放)
  60. std::vector<Entrance_statu> m_output_entrance_statu; //出口状态(关闭/开放)
  61. setting::System_setting m_system_setting;
  62. std::thread* m_publish_statu_thread; //广播状态线程
  63. Thread_condition m_publish_exit_condition; //发送的条件变量
  64. };
  65. #endif //NNXX_TESTS_COMMAND_MANAGER_H