system_communicator.h 2.2 KB

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