communication_message.h.orig 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. //
  2. // Created by huli on 2020/6/29.
  3. //
  4. #ifndef NNXX_TESTS_COMMUNICATION_MESSAGE_H
  5. #define NNXX_TESTS_COMMUNICATION_MESSAGE_H
  6. #include "../error_code/error_code.h"
  7. #include <time.h>
  8. #include <sys/time.h>
  9. #include <chrono>
  10. //#include <iosfwd>
  11. #include <string>
  12. #include "../message/message_base.pb.h"
  13. class Communication_message
  14. {
  15. public:
  16. //消息类型定义,每个在网络上传输的消息必须含有这个属性
  17. enum Message_type
  18. {
  19. eBase_msg=0x00,
  20. eCommand_msg=0x01, //指令消息
  21. eLocate_status_msg=0x11, //定位模块状态消息
  22. eLocate_request_msg=0x12, //定位请求消息
  23. eLocate_response_msg=0x13, //定位反馈消息
  24. eLocate_sift_request_msg = 0x14, //预测算法请求消息
  25. eLocate_sift_response_msg = 0x15, //预测算法反馈消息
  26. eDispatch_status_msg=0x21, //调度模块硬件状态消息
  27. eDispatch_request_msg=0x22, //请求调度消息
  28. eDispatch_response_msg=0x23, //调度结果反馈消息
  29. eParkspace_allocation_status_msg=0x31, //车位分配模块状态消息,包括车位信息
  30. eParkspace_allocation_request_msg=0x32, //请求分配车位消息
  31. eParkspace_allocation_response_msg=0x33,//分配车位结果反馈消息
  32. eParkspace_search_request_msg = 0x34, //查询车位请求消息
  33. eParkspace_search_response_msg = 0x35, //查询车位反馈消息
  34. eParkspace_release_request_msg = 0x36, //释放车位请求消息
  35. eParkspace_release_response_msg = 0x37, //释放车位反馈消息
  36. eParkspace_force_update_request_msg = 0x38, //手动修改车位消息
  37. eParkspace_force_update_response_msg = 0x39,//手动修改车位反馈消息
  38. eParkspace_confirm_alloc_request_msg = 0x3A,//确认分配车位请求消息
  39. eParkspace_confirm_alloc_response_msg = 0x3B,//确认分配车位反馈消息
  40. eStore_command_request_msg=0x41, //终端停车请求消息
  41. eStore_command_response_msg=0x42, //停车请求反馈消息
  42. ePickup_command_request_msg=0x43, //取车请求消息
  43. ePickup_command_response_msg=0x44, //取车请求反馈消息
  44. eStoring_process_statu_msg=0x90, //停车指令进度条消息
  45. ePicking_process_statu_msg=0x91, //取车指令进度消息
  46. eCentral_controller_statu_msg=0xa0, //中控系统状态消息
  47. eEntrance_manual_operation_msg=0xb0, //针对出入口状态操作的手动消息
  48. eProcess_manual_operation_msg=0xb1, //针对流程的手动消息
  49. eGround_detect_request_msg=0xf0, //地面雷达测量请求消息
  50. eGround_detect_response_msg=0xf1, //地面雷达测量反馈消息
  51. };
  52. //通讯单元
  53. enum Communicator
  54. {
  55. eEmpty=0x0000,
  56. eMain=0x0001, //主流程
  57. eTerminor=0x0100,
  58. //车位表
  59. eParkspace=0x0200,
  60. //测量单元
  61. eMeasurer=0x0300,
  62. //测量单元
  63. eMeasurer_sift_server=0x0301,
  64. //调度机构
  65. eDispatch=0x0400,
  66. //...
  67. //地面测量单元
  68. eGround_measurer=0x0f00,
  69. };
  70. public:
  71. Communication_message();
  72. Communication_message(std::string message_buf);
  73. Communication_message(char* p_buf, int size);
  74. Communication_message(const Communication_message& other)= default;
  75. Communication_message& operator =(const Communication_message& other)= default;
  76. ~Communication_message();
  77. public://API functions
  78. bool is_over_time();
  79. public://get or set member variable
  80. void reset(const message::Base_info& base_info, std::string receive_string);
  81. Message_type get_message_type();
  82. Communicator get_sender();
  83. Communicator get_receiver();
  84. std::string& get_message_buf();
  85. std::chrono::system_clock::time_point get_receive_time();
  86. protected://member variable
  87. Message_type m_message_type; //消息类型
  88. std::chrono::system_clock::time_point m_receive_time; //接收消息的时间点
  89. std::chrono::milliseconds m_timeout_ms; //超时时间, 整个软件都统一为毫秒
  90. Communicator m_sender; //发送者
  91. Communicator m_receiver; //接受者
  92. std::string m_message_buf; //消息数据
  93. private:
  94. };
  95. #endif //NNXX_TESTS_COMMUNICATION_MESSAGE_H