1
0

module_traffic_light_common.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef module_traffic_light_common_h
  2. #define module_traffic_light_common_h
  3. #include <string>
  4. #include <list>
  5. #include "point.h"
  6. enum device_type{
  7. DT_BIG_READER = 1, // 大分站
  8. DT_SMALL_READER = 2, // 小分站
  9. DT_CARD_READER = 3, // 读卡分站
  10. DT_CTRL_READER = 4, // 通信分站
  11. DT_LIGHT = 5, // 红绿灯
  12. DT_SPEAKER = 6, // 告警器
  13. DT_TURNOUT = 7, // 道岔
  14. DT_LED = 8, // 显示屏
  15. };
  16. // 灯的颜色和形状表
  17. enum light_shape{
  18. init_shape = 0,
  19. red_circle_solid = 1, // 红色实心圆
  20. red_circle = 2, // 红色空心圆
  21. red_cross = 3, // 红色叉型
  22. green_up = 4, // 绿色上箭头
  23. green_down = 5, // 绿色下箭头
  24. green_left = 6, // 绿色左箭头
  25. green_right = 7, // 绿色右箭头
  26. red_spark = 8, // 红色闪烁
  27. green_spark = 9, // 绿色闪烁
  28. green_all_on = 10, // 绿色全亮
  29. green_all_off = 11, // 绿色全灭
  30. red_all_on = 12, // 红色全亮
  31. red_all_off = 13 // 红色全灭
  32. };
  33. //优先级
  34. enum priority{
  35. priority_init = 0, // 初始值
  36. priority_crossing = 1, // 路口控制
  37. priority_avoidance = 2, // 避让控制
  38. priority_manual_ctrl = 3, // 手动控制
  39. };
  40. //web对应的
  41. enum light_color{
  42. init = 1, // 初始值
  43. red, // 红灯
  44. green, // 绿灯
  45. spark // 闪烁
  46. };
  47. enum light_cmd{
  48. cmd_reload = 0, // 重新加载红绿灯信息
  49. cmd_manual_ctrl, // 手动控制红绿灯信息
  50. cmd_card_data, // 卡数据
  51. };
  52. enum move_stream{
  53. unknown = 0,
  54. up_stream,
  55. down_stream,
  56. };
  57. struct pos_data: point{
  58. uint64_t m_card_id; // 卡id
  59. uint8_t m_type; // 1-add,2-del,3-update
  60. bool m_bigger; // 大小车标记
  61. int32_t m_area_id; // 区域id
  62. double m_speed; // 速度
  63. int m_site_id; // 分站id
  64. std::list<int> m_light_group; // 红绿灯组id
  65. pos_data(): m_card_id(0), m_type(0), m_bigger(false), m_area_id(0), m_speed(0.0), m_site_id(0)
  66. {
  67. m_light_group.clear();
  68. }
  69. pos_data operator=(const pos_data& p)
  70. {
  71. this->m_card_id = p.m_card_id;
  72. this->m_type = p.m_type;
  73. this->m_bigger = p.m_bigger;
  74. this->m_area_id = p.m_area_id;
  75. this->m_speed = p.m_speed;
  76. this->m_site_id = p.m_site_id;
  77. this->m_light_group = p.m_light_group;
  78. return *this;
  79. }
  80. };
  81. struct light_message{
  82. uint16_t m_cmd; // 命令
  83. int m_group_id; // 信号灯组id
  84. int m_light_id; // 信号灯id
  85. int m_light_state; // 信号灯形状
  86. std::string m_ctrl_name; // 控制用户
  87. pos_data m_pos; // 卡数据
  88. light_message(): m_cmd(0), m_group_id(0), m_light_id(0), m_light_state(0), m_ctrl_name("")
  89. {}
  90. light_message(const uint16_t cmd, const int gid, const int lid, const int ls, const std::string name, const pos_data& p): m_cmd(cmd), m_group_id(gid), m_light_id(lid), m_light_state(ls), m_ctrl_name(name), m_pos(p)
  91. {}
  92. };
  93. const double g_max_scope = 100.0;
  94. const double g_mid_vehicle_length_group = 30.0;
  95. #endif