monitor_emqx.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // Created by zx on 23-3-14.
  3. //
  4. #ifndef NAVIGATION_MPC_MONITOR_MONITOR_EMQX_H_
  5. #define NAVIGATION_MPC_MONITOR_MONITOR_EMQX_H_
  6. #include <mutex>
  7. #include "emqx/paho_client.h"
  8. typedef void (*StatuCallback)(double x,double y,double theta,double v,double vth,void* context);
  9. class Monitor_emqx
  10. {
  11. public:
  12. enum SpeedType{
  13. eRotate=0,
  14. eHorizontal,
  15. evVrtical,
  16. eMPC,
  17. eStop
  18. };
  19. public:
  20. Monitor_emqx(std::string nodeId,std::string pubTopic,std::string subTopic);
  21. ~Monitor_emqx();
  22. bool Connect(std::string ip,int port);
  23. void set_statu_arrived_callback(StatuCallback callback,void* context);
  24. void set_speed(SpeedType type,double v,double a);
  25. void stop();
  26. protected:
  27. StatuCallback StatuArrivedCallback_;
  28. static void StatuArrivedCallback(std::string topic,int QOS,MqttMsg& msg,void* context);
  29. std::mutex mtx_;
  30. Paho_client* client_;
  31. void* context_;
  32. std::string nodeId_;
  33. std::string pubTopic_;
  34. std::string subTopic_;
  35. public:
  36. MqttMsg msg_;
  37. };
  38. #endif //NAVIGATION_MPC_MONITOR_MONITOR_EMQX_H_