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. eStop=0,
  14. eRotate=1,
  15. eHorizontal=2,
  16. eMPC=3,
  17. };
  18. public:
  19. Monitor_emqx(std::string nodeId,std::string pubTopic,std::string subTopic);
  20. ~Monitor_emqx();
  21. bool Connect(std::string ip,int port);
  22. void set_statu_arrived_callback(StatuCallback callback,void* context);
  23. void set_speed(SpeedType type,double v,double a);
  24. void stop();
  25. protected:
  26. StatuCallback StatuArrivedCallback_;
  27. static void StatuArrivedCallback(std::string topic,int QOS,MqttMsg& msg,void* context);
  28. std::mutex mtx_;
  29. Paho_client* client_;
  30. void* context_;
  31. std::string nodeId_;
  32. std::string pubTopic_;
  33. std::string subTopic_;
  34. public:
  35. int heat_=0;
  36. MqttMsg msg_;
  37. };
  38. #endif //NAVIGATION_MPC_MONITOR_MONITOR_EMQX_H_