sync_time_message.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #ifndef sync_time_message_h
  2. #define sync_time_message_h
  3. #include <iostream>
  4. #include <fstream>
  5. #include "tag_message.h"
  6. #include "../message.h"
  7. #include <unordered_map>
  8. using namespace std;
  9. namespace host_server{
  10. class sync_time_message
  11. {
  12. private:
  13. unsigned long long m_local_id; // 本节点的id码
  14. unsigned long long m_upper_id; // 上一级同步节点的id码
  15. unsigned long long m_root_id; // 根节点的id码
  16. unsigned short m_sync_num; // 时间同步号
  17. unsigned short m_sync_level; // 同步层级
  18. unsigned long long m_local_send_time; // 本分站的发送时间
  19. unsigned long long m_local_receive_time; // 本分站的接收时间
  20. public:
  21. tag_message tag;
  22. std::unordered_map<int, message_tdoa_locinfo> map_tdoa_msg;
  23. sync_time_message():m_local_id(0),
  24. m_upper_id(0),
  25. m_root_id(0),
  26. m_sync_num(0),
  27. m_sync_level(0),
  28. m_local_send_time(0),
  29. m_local_receive_time(0)
  30. {}
  31. sync_time_message(unsigned long long local_id, unsigned long long upper_id, unsigned long long root_id, unsigned short sync_num, unsigned short sync_level, unsigned long long send_time, unsigned long long rec_time):
  32. m_local_id(local_id),
  33. m_upper_id(upper_id),
  34. m_root_id(root_id),
  35. m_sync_num(sync_num),
  36. m_sync_level(sync_level),
  37. m_local_send_time(send_time),
  38. m_local_receive_time(rec_time)
  39. {}
  40. unsigned long long get_local_id() const
  41. {
  42. return m_local_id;
  43. }
  44. void set_local_id(unsigned long long val)
  45. {
  46. if(val == 14757395258967641292){
  47. val = 0;
  48. }
  49. m_local_id = val;
  50. }
  51. unsigned long long get_upper_id() const
  52. {
  53. return m_upper_id;
  54. }
  55. void set_upper_id(const unsigned long long& val)
  56. {
  57. m_upper_id = val;
  58. }
  59. unsigned long long get_root_id() const
  60. {
  61. return m_root_id;
  62. }
  63. void set_root_id(const unsigned long long& val)
  64. {
  65. m_root_id = val;
  66. }
  67. unsigned short get_sync_num() const
  68. {
  69. return m_sync_num;
  70. }
  71. void set_sync_num(const unsigned short& val)
  72. {
  73. m_sync_num = val;
  74. }
  75. unsigned short get_sync_level() const
  76. {
  77. return m_sync_level;
  78. }
  79. void set_sync_level(const unsigned short& val)
  80. {
  81. m_sync_level = val;
  82. }
  83. unsigned long long get_local_send_time() const
  84. {
  85. return m_local_send_time;
  86. }
  87. void set_local_send_time(const unsigned long long& val)
  88. {
  89. m_local_send_time = val;
  90. }
  91. unsigned long long get_local_receive_time() const
  92. {
  93. return m_local_receive_time;
  94. }
  95. void set_local_receive_time(const unsigned long long& val)
  96. {
  97. m_local_receive_time = val;
  98. }
  99. };
  100. }
  101. #endif