12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- //
- // Created by zx on 2020/7/9.
- //
- #ifndef NNXX_TESTS_PARKSPACE_COMMUNICATOR_H
- #define NNXX_TESTS_PARKSPACE_COMMUNICATOR_H
- #include <parkspace_allocation_message.pb.h>
- #include "communication_socket_base.h"
- #include "singleton.h"
- #include "thread_safe_map.h"
- class Parkspace_communicator :public Singleton<Parkspace_communicator>, public Communication_socket_base
- {
- friend Singleton<Parkspace_communicator>;
- public:
- virtual ~Parkspace_communicator();
- /*
- * 请求分配车位
- */
- Error_manager alloc_request(message::Parkspace_allocation_request_msg& request,
- message::Parkspace_allocation_response_msg& result,Thread_condition& cancel_condition);
- /*
- * 查询车辆所在位置请求
- */
- Error_manager search_request(message::Parkspace_search_request_msg& request,
- message::Parkspace_search_response_msg& response,Thread_condition& cancel_condition);
- /*
- * 释放车位请求(停车失败或者取车完成时调用)
- */
- Error_manager release_request(message::Parkspace_release_request_msg& request,
- message::Parkspace_release_response_msg& response,Thread_condition& cancel_condition);
- /*
- * 确认占用车位消息
- */
- Error_manager confirm_request(message::Parkspace_confirm_alloc_request_msg& request,
- message::Parkspace_confirm_alloc_response_msg& response,Thread_condition& cancel_condition);
- Error_manager check_statu();
- protected:
- Parkspace_communicator();
- 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);
- protected:
- thread_safe_map<std::string,message::Parkspace_allocation_response_msg> m_alloc_table;
- thread_safe_map<std::string,message::Parkspace_search_response_msg> m_search_table;
- thread_safe_map<std::string,message::Parkspace_release_response_msg> m_release_table;
- thread_safe_map<std::string,message::Parkspace_confirm_alloc_response_msg> m_confirm_table;
- message::Parkspace_allocation_status_msg m_parkspace_status_msg;
- std::chrono::system_clock::time_point m_parkspace_statu_time;
- };
- #endif //NNXX_TESTS_PARKSPACE_COMMUNICATOR_H
|