command_manager.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. 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);
  31. /*
  32. * 执行取车请求
  33. */
  34. Error_manager execute_pickup_command(message::Pickup_command_request_msg& request);
  35. /*
  36. * 控制入口 开放或者关闭
  37. */
  38. Error_manager pause_entrance(int terminal_id,bool paused);
  39. bool entrance_paused(int terminal_id);
  40. /*
  41. * 控制出口 开放或者关闭
  42. */
  43. Error_manager pause_export(int terminal_id, bool paused);
  44. bool export_paused(int terminal_id);
  45. /*
  46. * pause,系统急停,急停状态下不允许自动流程的指令执行,允许管理员手动指令执行
  47. */
  48. void pause_system();
  49. /*
  50. * 系统是否急停
  51. */
  52. bool is_paused(){return m_system_paused;}
  53. private:
  54. Command_manager();
  55. protected:
  56. tq::IQueue* m_thread_queue_process; //指令流程线程池
  57. bool m_system_paused;
  58. std::vector<bool> m_input_entrance_paused; //入口状态(关闭/开放)
  59. std::vector<bool> m_output_entrance_paused; //出口状态(关闭/开放)
  60. setting::System_setting m_system_setting;
  61. };
  62. #endif //NNXX_TESTS_COMMAND_MANAGER_H