system_communicator.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // Created by huli on 2020/6/28.
  3. //
  4. #ifndef NNXX_TESTS_SYSTEM_COMMUNICATION_H
  5. #define NNXX_TESTS_SYSTEM_COMMUNICATION_H
  6. #include <process_message.pb.h>
  7. #include <central_control_message.pb.h>
  8. #include "../tool/singleton.h"
  9. #include "../communication/communication_socket_base.h"
  10. #include "terminal_message.pb.h"
  11. /*typedef Error_manager (*StoreCommandCallback)(message::Store_command_request_msg& msg,message::Store_command_response_msg& response);
  12. typedef Error_manager (*PickupCommandCallback)(message::Pickup_command_request_msg& msg,message::Pickup_command_response_msg& response);*/
  13. class System_communicator:public Singleton<System_communicator>, public Communication_socket_base
  14. {
  15. // 子类必须把父类设定为友元函数,这样父类才能使用子类的私有构造函数。
  16. friend class Singleton<System_communicator>;
  17. private:
  18. // 父类的构造函数必须保护,子类的构造函数必须私有。
  19. System_communicator();
  20. public:
  21. //必须关闭拷贝构造和赋值构造,只能通过 get_instance 函数来进行操作唯一的实例。
  22. System_communicator(const System_communicator& other) = delete;
  23. System_communicator& operator =(const System_communicator& other) = delete;
  24. /*
  25. * 发送中控状态消息, 出入口状态消息
  26. */
  27. Error_manager post_process_statu(message::Storing_process_statu_msg& msg);
  28. Error_manager post_process_statu(message::Picking_process_statu_msg& msg);
  29. Error_manager post_central_statu(message::Central_controller_statu_msg& msg);
  30. ~System_communicator();
  31. protected:
  32. //重载函数
  33. virtual Error_manager encapsulate_msg(Communication_message* message);
  34. virtual Error_manager execute_msg(Communication_message* p_msg);
  35. /*
  36. * 检测消息是否可被处理
  37. */
  38. virtual Error_manager check_msg(Communication_message* p_msg);
  39. /*
  40. * 心跳发送函数,重载
  41. */
  42. virtual Error_manager encapsulate_send_data();
  43. //检查消息是否可以被解析, 需要重载
  44. virtual Error_manager check_executer(Communication_message* p_msg);
  45. private:
  46. /*StoreCommandCallback mp_store_command_callback; //收到停车请求回调函数
  47. PickupCommandCallback mp_pickup_command_callback; //收到取车指令后的回调函数*/
  48. };
  49. #endif //NNXX_TESTS_SYSTEM_COMMUNICATION_H