1
0

ant.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #ifndef _ANT_LIST_HPP_
  2. #define _ANT_LIST_HPP_
  3. #include <math.h>
  4. #include <array>
  5. #include <deque>
  6. #include <tuple>
  7. #include <memory>
  8. #include <algorithm>
  9. #include "line.h"
  10. #include "point.h"
  11. struct path
  12. {
  13. line_v m_line;
  14. double m_slope=0;
  15. };
  16. struct algo_config
  17. {
  18. const char*desc;
  19. int min_msg_cnt;
  20. int best_msg_cnt;
  21. int min_wait_time;
  22. int max_wait_time;
  23. };
  24. struct ant
  25. {
  26. static algo_config g_config[];
  27. int m_site_id;
  28. int m_algo; //TOF:0,TDOA:1
  29. int m_num_dims; //1维:0,2维:1,3维:2
  30. point m_position;
  31. std::vector<path> m_path;
  32. int index()const;
  33. const algo_config&config()const;
  34. };
  35. struct ant_list
  36. {
  37. std::vector<ant*> m_ant_list;
  38. ant*get(uint32_t site_id,uint32_t ant_id)
  39. {
  40. return 0;
  41. }
  42. void load_from_db()
  43. {
  44. }
  45. static ant_list*instance();
  46. };
  47. struct site
  48. {
  49. std::vector<ant*> m_ant_list;
  50. };
  51. struct site_list
  52. {
  53. std::vector<site*> m_site_list;
  54. site*get(uint32_t site_id)
  55. {
  56. return 0;
  57. }
  58. void load_from_db()
  59. {
  60. }
  61. static site_list*instance();
  62. };
  63. struct loc_message
  64. {
  65. ant* m_ant;
  66. uint64_t m_num_ticks; //tof时间片或tdoa相对root时间
  67. loc_message();
  68. loc_message(ant*a,uint64_t num_ticks)
  69. :m_ant(a)
  70. ,m_num_ticks(num_ticks)
  71. {}
  72. int tool_index()const;
  73. };
  74. struct loc_tool
  75. {
  76. virtual std::vector<point> calc_location(const std::vector<loc_message>&locm)=0;
  77. virtual int index()
  78. {
  79. return -1;
  80. }
  81. virtual ~loc_tool(){}
  82. };
  83. struct loc_tool_tdoa_3_base:loc_tool
  84. {
  85. virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
  86. virtual int index();
  87. };
  88. struct loc_tool_tdoa_2_base:loc_tool
  89. {
  90. virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
  91. virtual int index();
  92. };
  93. struct loc_tool_tdoa_1_base:loc_tool
  94. {
  95. virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
  96. virtual int index();
  97. };
  98. struct loc_tool_tof_3_base:loc_tool
  99. {
  100. virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
  101. virtual int index();
  102. };
  103. struct loc_tool_tof_2_base:loc_tool
  104. {
  105. virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
  106. virtual int index();
  107. };
  108. struct loc_tool_tof_1_base:loc_tool
  109. {
  110. virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
  111. virtual int index();
  112. };
  113. struct loc_tool_main:loc_tool
  114. {
  115. static loc_tool* g_tool[6];
  116. loc_tool_main();
  117. ~loc_tool_main();
  118. static void set_tool(loc_tool*tool);
  119. std::vector<point> calc_location(const std::vector<loc_message>&locm);
  120. };
  121. #endif