system_communicator.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 post_entrance_statu(message::Storing_process_statu_msg& msg);
  24. Error_manager post_entrance_statu(message::Picking_process_statu_msg& msg);
  25. ~System_communicator();
  26. protected:
  27. //重载函数
  28. virtual Error_manager encapsulate_msg(Communication_message* message);
  29. virtual Error_manager execute_msg(Communication_message* p_msg);
  30. /*
  31. * 检测消息是否可被处理
  32. */
  33. virtual Error_manager check_msg(Communication_message* p_msg);
  34. /*
  35. * 心跳发送函数,重载
  36. */
  37. virtual Error_manager encapsulate_send_data();
  38. //检查消息是否可以被解析, 需要重载
  39. virtual Error_manager check_executer(Communication_message* p_msg);
  40. private:
  41. /*StoreCommandCallback mp_store_command_callback; //收到停车请求回调函数
  42. PickupCommandCallback mp_pickup_command_callback; //收到取车指令后的回调函数*/
  43. };
  44. #endif //NNXX_TESTS_SYSTEM_COMMUNICATION_H