system_communicator.h 2.1 KB

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