dealmqtteventthread.h 850 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef DEALMQTTEVENTTHREAD_H
  2. #define DEALMQTTEVENTTHREAD_H
  3. #include <QThread>
  4. #include <QDateTime>
  5. #include <QJsonDocument>
  6. #include <QJsonObject>
  7. #include <QJsonValue>
  8. #include <QJsonArray>
  9. #include <QJsonParseError>
  10. #include <QVariantMap>
  11. class MqttEventData{
  12. public:
  13. explicit MqttEventData(QString t = "",QByteArray d = "" ){
  14. topic = t;
  15. data = d;
  16. }
  17. QString topic;
  18. QByteArray data;
  19. };
  20. class DealMqttEventThread : public QThread
  21. {
  22. Q_OBJECT
  23. public:
  24. explicit DealMqttEventThread(QObject *parent = nullptr);
  25. void run();
  26. void stop();
  27. void appendMqttData(MqttEventData mqttData);
  28. signals:
  29. void dmq_log(QString log);
  30. void dmqSql(QString sql);
  31. void dmqAlarm(QString sql);
  32. public slots:
  33. private:
  34. bool keep;
  35. QList<MqttEventData> mqttDataList;
  36. };
  37. #endif // DEALMQTTEVENTTHREAD_H