mqttmsg.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // Created by zx on 23-2-22.
  3. //
  4. #ifndef PAHOC_SAMPLE_SAMPLES_DEVICE_MSG_H_
  5. #define PAHOC_SAMPLE_SAMPLES_DEVICE_MSG_H_
  6. #include "message.pb.h"
  7. #include <mutex>
  8. class MqttMsg
  9. {
  10. public:
  11. enum Dtype
  12. {
  13. ePointCloudXYZ,
  14. ePointCloudXYZI,
  15. eString,
  16. eImage,
  17. eAGVStatu,
  18. eAGVSpeed
  19. };
  20. public:
  21. MqttMsg();
  22. MqttMsg(char* data,const int length);
  23. MqttMsg(const MqttMsg& msg);
  24. MqttMsg& operator=(const MqttMsg& msg);
  25. ~MqttMsg();
  26. char* data()const;
  27. int length()const;
  28. void fromProtoMessage(const google::protobuf::Message& messge);
  29. bool toProtoMessage(google::protobuf::Message& message)const;
  30. /*void fromStatu(double x,double y,double theta,double v,double vth);
  31. void fromNavSpeed(const NavMessage::Speed& speed);
  32. void fromNavCmd(const NavMessage::NavCmd& cmd);
  33. void fromNavStatu(const NavMessage::NavStatu& statu);
  34. bool toStatu(double& x,double& y,double& theta,double& v,double& vth);
  35. bool toNavSpeed(NavMessage::Speed& speed);
  36. bool toNavCmd(NavMessage::NavCmd& cmd);
  37. bool toNavStatu(NavMessage::NavStatu& statu);*/
  38. protected:
  39. char* data_=nullptr;
  40. int length_=0;
  41. std::mutex mutex_;
  42. };
  43. #endif //PAHOC_SAMPLE_SAMPLES_DEVICE_MSG_H_