vehicle_driver_alarm.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #ifndef VEHICLE_DRIVER_ALARM_H
  2. #define VEHICLE_DRIVER_ALARM_H
  3. #include <vector>
  4. #include "tr_tool.h"
  5. #include "struct_def.h"
  6. #include <memory>
  7. const int ET_COALING_DRIVING_DRIVER=37;//工作面(采煤面和掘进面)司机与车卡告警;
  8. //司机的求和坐标
  9. struct DriverPos
  10. {
  11. DriverPos()
  12. :isOn(false)
  13. ,PointNum(0)
  14. ,dept_id(0)
  15. ,Sum_x(0.)
  16. ,Sum_y(0.)
  17. {
  18. }
  19. //开始时间
  20. time_t starttime;
  21. //车或者对应的车是否开机
  22. bool isOn;
  23. //定位点个数
  24. int PointNum;
  25. //部门
  26. uint32_t dept_id;
  27. //x坐标和
  28. double Sum_x;
  29. //y坐标和
  30. double Sum_y;
  31. void reset_vehicle_driver_pos();
  32. void calc_vehicle_driver_pos(double x,double y);
  33. bool calc_vehicle_driver_distance( double mean_vx,double mean_vy,double& distance);
  34. void on_vehicle_state_changed(bool m_bOpen);
  35. };
  36. //采煤机、挖掘机的求和坐标
  37. struct VehiclePos:public DriverPos
  38. {
  39. VehiclePos()
  40. :workface_id(0)
  41. {
  42. }
  43. // 工作面
  44. int workface_id;
  45. std::vector<uint32_t> m_drivelist;//司机列表
  46. };
  47. //工作面相关参数告警参数
  48. struct WorkfaceParam
  49. {
  50. //告警距离
  51. double dist;
  52. //告警时间
  53. int dist_time;
  54. };
  55. struct SDeal_Card_Pos
  56. {
  57. double x; // located x
  58. double y; // located y
  59. double z; // located z
  60. uint64_t type; // card type
  61. int dentifier_type;
  62. int identifier_id; // staff id or 工作面ID
  63. uint32_t dpt_id; //部门ID
  64. int work_type_id;
  65. int id;
  66. void Copy(const card_pos & pos)
  67. {
  68. x = pos.x;
  69. y = pos.y;
  70. z = pos.z;
  71. id = pos.id;
  72. type = pos.type;
  73. dentifier_type = 0;
  74. dpt_id = pos.dpt_id;
  75. work_type_id = pos.work_type_id;
  76. }
  77. };
  78. typedef std::map<uint32_t, std::shared_ptr<WorkfaceParam>> WorkfaceParamMap;
  79. typedef std::map<uint32_t,std::shared_ptr<DriverPos>> DriverPosMap;
  80. typedef std::map<uint32_t,std::shared_ptr<VehiclePos>> VehiclePosMap;
  81. class vehicle_driver_alarm
  82. {
  83. public:
  84. vehicle_driver_alarm();
  85. ~vehicle_driver_alarm(){};
  86. public:
  87. /*
  88. * 初始化参数
  89. */
  90. void init();
  91. void deal_vehicle_driver_alarm(SDeal_Card_Pos & cp);
  92. public:
  93. void init_coalface_driver_warningparam();
  94. void init_driving_driver_warningparam(const std::string & sz_drivingface_id = "-1");
  95. protected:
  96. void add_driver_to_vehicle(SDeal_Card_Pos &cp, std::shared_ptr<DriverPos> driverPos);
  97. void add_driver_to_vehicle(VehiclePosMap& vehiclePosMap, SDeal_Card_Pos &cp,std::shared_ptr<DriverPos> driverPos);
  98. public:
  99. void set_send_callback(const SendCallBack &cb)
  100. {
  101. m_send_callback = move(cb);
  102. }
  103. private:
  104. std::shared_ptr<VehiclePos> get_vehicle_pos(int _id,int _type);
  105. private:
  106. WorkfaceParamMap m_WorkfaceParamMap;//工作面告警的计算参数
  107. VehiclePosMap m_DrivingVehiclePosMap;//掘进机的平均位置
  108. VehiclePosMap m_CoalVehiclePosMap;//采煤机的平均位置
  109. DriverPosMap m_DriverPosMap;//司机的平均位置
  110. SendCallBack m_send_callback;
  111. };
  112. #endif