parkspace_excutor.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // Created by zx on 2020/7/9.
  3. //
  4. #ifndef NNXX_TESTS_PARKSPACE_COMMUNICATOR_H
  5. #define NNXX_TESTS_PARKSPACE_COMMUNICATOR_H
  6. #include "message_communicator.h"
  7. #include <parkspace_allocation_message.pb.h>
  8. #include "thread_safe_map.h"
  9. #include "communication_message.h"
  10. class Parkspace_excutor :public Singleton<Parkspace_excutor>
  11. {
  12. friend Singleton<Parkspace_excutor>;
  13. public:
  14. virtual ~Parkspace_excutor();
  15. /*
  16. * 请求分配车位
  17. */
  18. Error_manager alloc_request(message::Parkspace_allocation_request_msg& request,
  19. message::Parkspace_allocation_response_msg& result,Thread_condition& cancel_condition);
  20. /*
  21. * 查询车辆所在位置请求
  22. */
  23. Error_manager search_request(message::Parkspace_search_request_msg& request,
  24. message::Parkspace_search_response_msg& response,Thread_condition& cancel_condition);
  25. /*
  26. * 释放车位请求(停车失败或者取车完成时调用)
  27. */
  28. Error_manager release_request(message::Parkspace_release_request_msg& request,
  29. message::Parkspace_release_response_msg& response,Thread_condition& cancel_condition);
  30. /*
  31. * 确认占用车位消息
  32. */
  33. Error_manager confirm_request(message::Parkspace_confirm_alloc_request_msg& request,
  34. message::Parkspace_confirm_alloc_response_msg& response,Thread_condition& cancel_condition);
  35. Error_manager consume_msg(Communication_message* p_msg);
  36. Error_manager check_statu();
  37. protected:
  38. Parkspace_excutor();
  39. protected:
  40. thread_safe_map<std::string,message::Parkspace_allocation_response_msg> m_alloc_table;
  41. thread_safe_map<std::string,message::Parkspace_search_response_msg> m_search_table;
  42. thread_safe_map<std::string,message::Parkspace_release_response_msg> m_release_table;
  43. thread_safe_map<std::string,message::Parkspace_confirm_alloc_response_msg> m_confirm_table;
  44. message::Parkspace_allocation_status_msg m_parkspace_status_msg;
  45. std::chrono::system_clock::time_point m_parkspace_statu_time;
  46. };
  47. #endif //NNXX_TESTS_PARKSPACE_COMMUNICATOR_H