123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- //
- // Created by zx on 2020/7/13.
- //
- #ifndef NNXX_TESTS_TERMINAL_COMMUNICATION_H
- #define NNXX_TESTS_TERMINAL_COMMUNICATION_H
- #include <process_message.pb.h>
- #include "../tool/singleton.h"
- #include "../communication/communication_socket_base.h"
- #include "terminal_message.pb.h"
- #include "parkspace_allocation_message.pb.h"
- #include "message_compare.h"
- class Terminal_communication :public Singleton<Terminal_communication>, public Communication_socket_base{
- friend class Singleton<Terminal_communication>;
- private:
- // 父类的构造函数必须保护,子类的构造函数必须私有。
- Terminal_communication();
- public:
- //必须关闭拷贝构造和赋值构造,只能通过 get_instance 函数来进行操作唯一的实例。
- Terminal_communication(const Terminal_communication& other) = delete;
- Terminal_communication& operator =(const Terminal_communication& other) = delete;
- ~Terminal_communication();
- /*
- * 设置终端id
- */
- Error_manager set_terminal_id(int id);
- /*
- * 发送停车指令请求
- */
- Error_manager store_request(message::Store_command_request_msg& request,message::Store_command_response_msg& response);
- /*
- * 发送取车指令请求
- */
- Error_manager pickup_request(message::Pickup_command_request_msg& request,message::Pickup_command_response_msg& response);
- /*
- * 检查入口完成状态
- */
- Error_manager check_store_entrance_statu(int terminal_id,message::Entrance_statu& statu);
- /*
- * 检查出口完成状态
- */
- Error_manager check_pickup_entrance_statu(int terminal_id,message::Entrance_statu& statu);
- protected:
- //重载函数
- virtual Error_manager encapsulate_msg(Communication_message* message);
- virtual Error_manager execute_msg(Communication_message* p_msg);
- /*
- * 检测消息是否可被处理
- */
- virtual Error_manager check_msg(Communication_message* p_msg);
- /*
- * 心跳发送函数,重载
- */
- virtual Error_manager encapsulate_send_data();
- //检查消息是否可以被解析, 需要重载
- virtual Error_manager check_executer(Communication_message* p_msg);
- private:
- message::Store_command_response_msg m_store_response_msg;
- message::Pickup_command_response_msg m_pickup_response_msg;
- int m_terminal_id;
- std::mutex m_statu_lock;
- message::Entrance_statu_msg m_entrance_status;
- };
- #endif //NNXX_TESTS_TERMINAL_COMMUNICATION_H
|