1
0

sync_time_message.h 3.2 KB

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