system_executor.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 "../system/system_communication.h"
  11. //#include "../locate/locate_manager.h"
  12. //#include "../locate/locate_manager_task.h"
  13. //#include "../laser/laser_manager.h"
  14. //#include "../locate/locate_manager.h"
  15. //#include "../dispatch/dispatch_manager.h"
  16. #include "../message/central_control_message.pb.h"
  17. #include "../message/dispatch_control.pb.h"
  18. #include "../message/dispatch_message.pb.h"
  19. #include "../message/log_process.pb.h"
  20. #include "../message/measure_message.pb.h"
  21. #include "../message/message_base.pb.h"
  22. #include "../message/notify_message.pb.h"
  23. #include "../message/parkspace_allocation_message.pb.h"
  24. #include "../message/process_message.pb.h"
  25. #include "../message/singlechip_msg.pb.h"
  26. #include "../message/UnNormalized_module_message.pb.h"
  27. #include "../message/terminal_message.pb.h"
  28. class System_executor:public Singleton<System_executor>
  29. {
  30. // 子类必须把父类设定为友元函数,这样父类才能使用子类的私有构造函数。
  31. friend class Singleton<System_executor>;
  32. public:
  33. //系统执行者的状态
  34. enum System_executor_status
  35. {//default SYSTEM_EXECUTOR_UNKNOW = 0
  36. SYSTEM_EXECUTOR_UNKNOW = 0, //
  37. SYSTEM_EXECUTOR_READY = 1, //
  38. SYSTEM_EXECUTOR_FAULT = 10, //
  39. };
  40. private:
  41. // 父类的构造函数必须保护,子类的构造函数必须私有。
  42. System_executor();
  43. public:
  44. //必须关闭拷贝构造和赋值构造,只能通过 get_instance 函数来进行操作唯一的实例。
  45. System_executor(const System_executor& other) = delete;
  46. System_executor& operator =(const System_executor& other) = delete;
  47. ~System_executor();
  48. public://API functions
  49. //初始化
  50. Error_manager system_executor_init(int threads_size);
  51. //反初始化
  52. Error_manager system_executor_uninit();
  53. //检查消息是否有效, 主要检查消息类型和接受者, 判断这条消息是不是给我的.
  54. Error_manager check_msg(Communication_message* p_msg);
  55. //检查执行者的状态, 判断能否处理这条消息,
  56. Error_manager check_executer(Communication_message* p_msg);
  57. //处理消息的执行函数
  58. Error_manager execute_msg(Communication_message* p_msg);
  59. //检查状态
  60. Error_manager check_status();
  61. //定时发送状态信息
  62. Error_manager encapsulate_send_status();
  63. //定时发送 调度管理的状态
  64. Error_manager encapsulate_send_dispatch_manager_status();
  65. //判断是否为待机,如果已经准备好,则可以执行任务。
  66. bool is_ready();
  67. public://get or set member variable
  68. System_executor_status get_system_executor_status();
  69. public:
  70. protected://member variable
  71. System_executor_status m_system_executor_status; //系统执行者的状态
  72. Thread_pool m_thread_pool; //执行多任务的线程池
  73. private:
  74. };
  75. #endif //NNXX_TESTS_SYSTEM_EXECUTOR_H