environmentcore.h 881 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef ENVIRONMENTCORE_H
  2. #define ENVIRONMENTCORE_H
  3. #include <QObject>
  4. #include <qmqtt.h>
  5. #include <QSqlDatabase>
  6. #include <QSqlQuery>
  7. #include <QDateTime>
  8. #include <QTimer>
  9. #include "logthread.h"
  10. #include "mqttpub.h"
  11. #include "mqttsub.h"
  12. class EnvironmentCore : public QObject
  13. {
  14. Q_OBJECT
  15. public:
  16. explicit EnvironmentCore(QObject *parent = nullptr);
  17. ~EnvironmentCore();
  18. void start();
  19. void shm_init();
  20. bool shm_load();
  21. signals:
  22. public slots:
  23. void onConnected();
  24. void dataLog(QString log);
  25. void receiveDevData(QString topic,QByteArray data);
  26. void mqtt_data(QString mqtt_msg);
  27. void time_out();
  28. private:
  29. LogThread *logthread;
  30. MqttPub *mqttpub;
  31. MqttSub *mqttsub;
  32. QMQTT::Client *m_client;
  33. QSqlDatabase db;
  34. quint16 mqttIdx;
  35. QString ip,port,username,password;
  36. QTimer *timer;
  37. };
  38. #endif // ENVIRONMENTCORE_H