LivoxMid100Laser.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #include "LivoxMid100Laser.h"
  2. #include "../common.h"
  3. RegisterLaser(LivoxMid100)
  4. CLivoxMid100Laser::CLivoxMid100Laser(int id, Automatic::stLaserCalibParam laser_param)
  5. :CLivoxLaser(id, laser_param)
  6. {
  7. m_frame_maxnum = laser_param.frame_num();
  8. if (laser_param.type() == "LivoxMid100")
  9. {
  10. std::string sn = laser_param.sn();
  11. std::string sn1 = sn, sn2 = sn, sn3 = sn;
  12. sn1 += "1";
  13. sn2 += "2";
  14. sn3 += "3";
  15. g_sn_laser.insert(std::make_pair(sn1, this));
  16. g_sn_laser.insert(std::make_pair(sn2, this));
  17. g_sn_laser.insert(std::make_pair(sn3, this));
  18. }
  19. }
  20. void CLivoxMid100Laser::UpdataHandle()
  21. {
  22. std::string sn = m_laser_param.sn();
  23. std::string sn1 = sn, sn2 = sn, sn3 = sn;
  24. sn1 += "1";
  25. sn2 += "2";
  26. sn3 += "3";
  27. if (g_sn_handle.find(sn1) != g_sn_handle.end())
  28. {
  29. m_handle1 = g_sn_handle[sn1];
  30. }
  31. if (g_sn_handle.find(sn2) != g_sn_handle.end())
  32. {
  33. m_handle2 = g_sn_handle[sn2];
  34. }
  35. if (g_sn_handle.find(sn3) != g_sn_handle.end())
  36. {
  37. m_handle3 = g_sn_handle[sn3];
  38. }
  39. }
  40. bool CLivoxMid100Laser::IsScanComplete()
  41. {
  42. return g_count[m_handle1] >= m_frame_maxnum && g_count[m_handle2] >= m_frame_maxnum
  43. && g_count[m_handle2] >= m_frame_maxnum;
  44. }
  45. eLaserStatu CLivoxMid100Laser::GetStatu()
  46. {
  47. bool cond1=g_devices[m_handle1].device_state == kDeviceStateConnect ||
  48. g_devices[m_handle1].device_state == kDeviceStateSampling;
  49. bool cond2=g_devices[m_handle2].device_state == kDeviceStateConnect ||
  50. g_devices[m_handle2].device_state == kDeviceStateSampling;
  51. bool cond3=g_devices[m_handle3].device_state == kDeviceStateConnect ||
  52. g_devices[m_handle3].device_state == kDeviceStateSampling;
  53. if (cond1 && cond2 && cond3) {
  54. if(m_queue_laser_data.size()==0 && m_bscan_start==false)
  55. m_statu = eLaser_ready;
  56. else
  57. m_statu = eLaser_busy;
  58. }
  59. else {
  60. m_statu = eLaser_disconnect;
  61. }
  62. return m_statu;
  63. }
  64. bool CLivoxMid100Laser::Connect()
  65. {
  66. return CLivoxLaser::Connect();
  67. }
  68. void CLivoxMid100Laser::Disconnect()
  69. {
  70. CLivoxLaser::Disconnect();
  71. }
  72. bool CLivoxMid100Laser::Stop()
  73. {
  74. return CLivoxLaser::Stop();
  75. }
  76. bool CLivoxMid100Laser::Start()
  77. {
  78. LOG(INFO) << " livoxMid100 start :" << this;
  79. //������ݣ���ʼ
  80. m_queue_livox_data.clear();
  81. g_count[m_handle1] = 0;
  82. g_count[m_handle2] = 0;
  83. g_count[m_handle3] = 0;
  84. return CLaser::Start();
  85. }
  86. CLivoxMid100Laser::~CLivoxMid100Laser()
  87. {
  88. }