mqtt_communication.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include <pcl/point_types.h>
  3. #include <pcl/point_cloud.h>
  4. #include "pahoc/mqtt_async.h"
  5. #include "tool/log.hpp"
  6. #include "vzense/device_tof3d.h"
  7. class Tof3DMqttAsyncClient : public MqttAsyncClient {
  8. public:
  9. static Tof3DMqttAsyncClient *iter() {
  10. static Tof3DMqttAsyncClient *instance = nullptr;
  11. if (instance == nullptr) {
  12. instance = new Tof3DMqttAsyncClient();
  13. }
  14. return instance;
  15. }
  16. void init(const std::string &file);
  17. protected:
  18. Tof3DMqttAsyncClient() = default;
  19. private:
  20. void run();
  21. static int CloudDataArrived(MqttAsyncClient *client, char *topicName, int topicLen, MQTTAsync_message *message);
  22. public:
  23. private:
  24. std::mutex m_cloud_mutex;
  25. std::map<long, DeviceTof3D::DeviceTof3DSaveInfo> m_lf_info;
  26. std::map<long, DeviceTof3D::DeviceTof3DSaveInfo> m_rf_info;
  27. std::map<long, DeviceTof3D::DeviceTof3DSaveInfo> m_lr_info;
  28. std::map<long, DeviceTof3D::DeviceTof3DSaveInfo> m_rr_info;
  29. std::thread *t = nullptr;
  30. Thread_condition *condit = nullptr;
  31. };