firingwidget.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #ifndef FIRINGWIDGET_H
  2. #define FIRINGWIDGET_H
  3. #include <QJsonDocument>
  4. #include <QJsonObject>
  5. #include <QWidget>
  6. #include "../blastRecord/hblastrecord.h"
  7. #include "../blastRecord/hblastrecorddao.h"
  8. #include "../blastRecordDet/hblastrecorddetdao.h"
  9. #include "../blastRegRecord/hblastregrecorddao.h"
  10. #include "../databasemanager.h"
  11. #include "../des3encryption.h"
  12. #include "../mqtt/mqttclient.h"
  13. #include "../mqttthread.h"
  14. #include "../serial/serialtool.h"
  15. #include "navprogress.h"
  16. namespace Ui {
  17. class firingWidget;
  18. }
  19. class firingWidget : public QWidget {
  20. Q_OBJECT
  21. public:
  22. explicit firingWidget(const int &row, const bool &select, const QString &uuid = "",
  23. QWidget *parent = nullptr);
  24. ~firingWidget();
  25. void cancelBlasting();
  26. void testonBlastSucess(const QJsonObject &data);
  27. public slots:
  28. void onCountdownFinished(const QString &topic, const QString &message);
  29. private slots:
  30. void on_pushButton_2_clicked();
  31. void on_sendTest_4_clicked();
  32. void handleMessageAndTopic(const QByteArray &message, const QMqttTopicName &topic);
  33. signals:
  34. void progressChanged(int value, int row);
  35. void lastStageChanged(int newStage);
  36. void updateBlastStatus(int status, int row);
  37. void selectSignal(QString uuid);
  38. void updateButton(int status, int row);
  39. void updateProjectStatus(QString uuid);
  40. void updateData(const QJsonObject &jsonObj);
  41. void countdown(QString uuid, const QString &topic, const QString &message);
  42. void closeFiring(QString uuid);
  43. private slots:
  44. // 处理 MQTT 连接成功的槽函数
  45. void onMqttConnected();
  46. // 双键按下
  47. void onButtonPressedReceived(const QString &topic, const QString &message);
  48. void onLastStageChanged(int newStage);
  49. void onBlastSucess(const QJsonObject &data);
  50. private:
  51. bool recordBlastEquipments(const QJsonObject &jsonObj);
  52. QList<HBlastRecordDet *> recordDetsData(const QJsonObject &jsonObj);
  53. bool uploadToDanLing(const QJsonObject &jsonObj);
  54. HBlastRecord *recordBlastProject(const QJsonObject &jsonObj);
  55. void saveAndUploadRecord(const QJsonObject &jsonObj);
  56. void uploadToServer(const QJsonObject &jsonObj);
  57. void sendMqttMessage(const QString &topic, const QByteArray &message);
  58. void startBlasting();
  59. private:
  60. Ui::firingWidget *ui;
  61. MqttClient *pcPorjectBC;
  62. HBlastRecordDao dao;
  63. HBlastRecordDetDao daoDet;
  64. HBlastRegRecordDao daoReg;
  65. NavProgress *navProgress;
  66. MqttThread *mqttThread;
  67. SerialTool *serialTool = nullptr;
  68. QString m_uuid; // 用于存储 uuid
  69. QString reg_uuid; // 用于存储 uuid
  70. QString blast_uuid; // 用于存储 uuid
  71. QString topic;
  72. int m_row;
  73. int lastStage = -1; // 用于记录上一次的 stage 状态
  74. bool m_isMqttConnected = false;
  75. bool m_select;
  76. QMetaObject::Connection connection; // 声明 connection 变量
  77. QMetaObject::Connection connectionPress;
  78. QString lat;
  79. QString lon;
  80. };
  81. #endif // FIRINGWIDGET_H