system_executor.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // Created by huli on 2020/7/2.
  3. //
  4. #ifndef NNXX_TESTS_SYSTEM_EXECUTOR_H
  5. #define NNXX_TESTS_SYSTEM_EXECUTOR_H
  6. #include "../tool/thread_pool.h"
  7. #include "../tool/singleton.h"
  8. #include "../error_code/error_code.h"
  9. //#include "../communication/communication_message.h"
  10. #include "../dispatch/dispatch_manager.h"
  11. //#include "../locate/locate_manager.h"
  12. //#include "../locate/locate_manager_task.h"
  13. //#include "../message/measure_message.pb.h"
  14. //#include "../laser/laser_manager.h"
  15. //#include "../locate/locate_manager.h"
  16. #include "../system/system_communication.h"
  17. //#include "../message/dispatch_message.pb.h"
  18. //#include "../message/notify_message.pb.h"
  19. #include "../dispatch/dispatch_manager.h"
  20. #include "../rabbitmq/rabbitmq_message.h"
  21. class System_executor:public Singleton<System_executor>
  22. {
  23. // 子类必须把父类设定为友元函数,这样父类才能使用子类的私有构造函数。
  24. friend class Singleton<System_executor>;
  25. public:
  26. //系统执行者的状态
  27. enum System_executor_status
  28. {//default SYSTEM_EXECUTOR_UNKNOW = 0
  29. SYSTEM_EXECUTOR_UNKNOW = 0, //
  30. SYSTEM_EXECUTOR_READY = 1, //
  31. SYSTEM_EXECUTOR_FAULT = 10, //
  32. };
  33. private:
  34. // 父类的构造函数必须保护,子类的构造函数必须私有。
  35. System_executor();
  36. public:
  37. //必须关闭拷贝构造和赋值构造,只能通过 get_instance 函数来进行操作唯一的实例。
  38. System_executor(const System_executor& other) = delete;
  39. System_executor& operator =(const System_executor& other) = delete;
  40. ~System_executor();
  41. public://API functions
  42. //初始化
  43. Error_manager system_executor_init(int threads_size);
  44. //反初始化
  45. Error_manager system_executor_uninit();
  46. //检查消息是否有效, 主要检查消息类型和接受者, 判断这条消息是不是给我的.
  47. Error_manager check_msg(Rabbitmq_message* p_msg);
  48. //检查执行者的状态, 判断能否处理这条消息,
  49. Error_manager check_executer(Rabbitmq_message* p_msg);
  50. //处理消息的执行函数
  51. Error_manager execute_msg(Rabbitmq_message* p_msg);
  52. //检查状态
  53. Error_manager check_status();
  54. //定时发送状态信息
  55. Error_manager encapsulate_send_status();
  56. //定时发送 调度管理的状态
  57. Error_manager encapsulate_send_dispatch_manager_status();
  58. //判断是否为待机,如果已经准备好,则可以执行任务。
  59. bool is_ready();
  60. public://get or set member variable
  61. System_executor_status get_system_executor_status();
  62. public:
  63. //雷达感测定位 的处理函数
  64. //input::command_id, 消息指令id, 由主控制系统生成的唯一码
  65. //input::command_id, 终端id, 对应具体的某个车位
  66. //return::void, 没有返回, 执行结果直接生成一条答复消息, 然后通过通信返回
  67. // void execute_for_measure(std::string command_key, int unit_id, int terminal_id);
  68. //调度模块的处理函数
  69. // void execute_for_dispatch(std::string command_key, Dispatch_manager::Dispatch_motion_direction dispatch_motion_direction,
  70. // int terminal_id, int parkspace_id, Locate_information * p_locate_information);
  71. //调度模块 //执行搬运请求(主控->调度管理)
  72. // void execute_for_dispatch_request_msg(message::Dispatch_request_msg dispatch_request_msg);
  73. //调度模块 //调度总规划的答复(调度算法->调度管理)
  74. // void execute_for_dispatch_plan_response_msg(message::Dispatch_plan_response_msg dispatch_plan_response_msg);
  75. //调度模块 //调度控制的任务请求(调度算法->调度管理)
  76. // void execute_for_dispatch_control_request_msg(message::Dispatch_control_request_msg dispatch_control_request_msg);
  77. //地面雷达的状态消息(地面雷达->null)
  78. // void execute_for_ground_status_msg(message::Ground_status_msg ground_status_msg);
  79. //调度模块 ///单片机的状态消息
  80. // void execute_for_terminal_status_msg(message::Terminal_status_msg terminal_status_msg);
  81. //调度模块 ///单片机的状态消息
  82. // void execute_for_notify_status_msg(message::Notify_status_msg notify_status_msg);
  83. protected://member variable
  84. System_executor_status m_system_executor_status; //系统执行者的状态
  85. Thread_pool m_thread_pool; //执行多任务的线程池
  86. private:
  87. };
  88. #endif //NNXX_TESTS_SYSTEM_EXECUTOR_H