|
@@ -27,7 +27,7 @@
|
|
|
firingWidget::firingWidget(const int &row, const bool &select, const QString &uuid, QWidget *parent)
|
|
|
: QWidget(parent),
|
|
|
ui(new Ui::firingWidget),
|
|
|
- m_curProjUuid(uuid),
|
|
|
+ m_blasterDevUuid(uuid),
|
|
|
m_row(row),
|
|
|
m_select(select),
|
|
|
daoProj(DatabaseManager::getInstance().getDatabase()),
|
|
@@ -44,13 +44,13 @@ firingWidget::firingWidget(const int &row, const bool &select, const QString &uu
|
|
|
ui->scrollArea->setStyleSheet("background: rgba(0, 0, 0, 22); border-radius: 20px;");
|
|
|
ui->verticalLayout->addWidget(navProgress);
|
|
|
// TODO
|
|
|
- m_curProjUuid = "61c93e60e50e3439";
|
|
|
- m_topic = "hxgc/" + m_curProjUuid + "/BlastTaskReply";
|
|
|
- qDebug() << ANSI_COLOR_GREEN << "Firing widget created with topic: " << m_topic << ANSI_COLOR_RESET;
|
|
|
- QStringList topics = {m_topic};
|
|
|
+ m_blasterDevUuid = "61c93e60e50e3439";
|
|
|
+ m_blasterPubTopic = "hxgc/" + m_blasterDevUuid + "/BlastTaskReply";
|
|
|
+ qDebug() << ANSI_COLOR_GREEN << "Firing widget created with topic: " << m_blasterPubTopic << ANSI_COLOR_RESET;
|
|
|
+ QStringList topics = {m_blasterPubTopic};
|
|
|
m_connectionCheckTimer = new QTimer(this);
|
|
|
|
|
|
- m_subscription = mainMqttClient->subscribeToTopic(m_topic);
|
|
|
+ m_subscription = mainMqttClient->subscribeToTopic(m_blasterPubTopic);
|
|
|
connect(m_subscription, &QMqttSubscription::messageReceived, this, &firingWidget::handleProjectFiringMqttMessage);
|
|
|
|
|
|
connect(this, &firingWidget::lastStageChanged, this, &firingWidget::handleFiringStageChanged);
|
|
@@ -75,9 +75,9 @@ void firingWidget::sendMqttMessage(const QString &topic, const QByteArray &messa
|
|
|
void firingWidget::startBlasting() {
|
|
|
// 等待3s mqtt连接后再发送mqtt消息
|
|
|
m_lastStage = FiringStages::Starting;
|
|
|
- qDebug() << ANSI_COLOR_GREEN << "Firing widget started with topic: 1" << m_topic << ANSI_COLOR_RESET;
|
|
|
+ qDebug() << ANSI_COLOR_GREEN << "Firing widget started with topic: 1" << m_blasterPubTopic << ANSI_COLOR_RESET;
|
|
|
emit lastStageChanged(FiringStages::Starting);
|
|
|
- qDebug() << ANSI_COLOR_GREEN << "Firing widget started with topic: 2" << m_topic << ANSI_COLOR_RESET;
|
|
|
+ qDebug() << ANSI_COLOR_GREEN << "Firing widget started with topic: 2" << m_blasterPubTopic << ANSI_COLOR_RESET;
|
|
|
checkBlasterConnection();
|
|
|
}
|
|
|
|
|
@@ -93,7 +93,7 @@ void firingWidget::checkBlasterConnection() {
|
|
|
m_connectionCheckTimer->stop();
|
|
|
return;
|
|
|
}
|
|
|
- if (m_lastMsgTime.secsTo(QDateTime::currentDateTime()) > 3) {
|
|
|
+ if (m_lastMsgTime.secsTo(QDateTime::currentDateTime()) > 10) {
|
|
|
m_connectionCheckTimer->stop();
|
|
|
QMessageBox msgBox;
|
|
|
msgBox.setWindowTitle("起爆检测测试错误");
|
|
@@ -111,10 +111,10 @@ void firingWidget::checkBlasterConnection() {
|
|
|
emit lastStageChanged(FiringStages::ForceCanceled);
|
|
|
return;
|
|
|
}
|
|
|
- m_connectionCheckTimer->start(5000);
|
|
|
+ m_connectionCheckTimer->start(10000);
|
|
|
}
|
|
|
});
|
|
|
- m_connectionCheckTimer->start(1000);
|
|
|
+ m_connectionCheckTimer->start(10000);
|
|
|
}
|
|
|
|
|
|
void firingWidget::handleProjectFiringMqttMessage(const QMqttMessage &message) {
|
|
@@ -134,7 +134,7 @@ void firingWidget::handleProjectFiringMqttMessage(const QMqttMessage &message) {
|
|
|
int status = relayInfo["status"].toInt();
|
|
|
if (ErrorBlastStatus::isErrorStatus(status)) {
|
|
|
Logger::getInstance().error(QString("爆破器返回异常. 工程uuid: %1; 错误code: %2")
|
|
|
- .arg(m_curProjUuid, ErrorBlastStatus::getErrorMessage(status)));
|
|
|
+ .arg(m_blasterDevUuid, ErrorBlastStatus::getErrorMessage(status)));
|
|
|
QMessageBox::critical(nullptr, "爆破器报错",
|
|
|
QString("错误错误信息: %1").arg(ErrorBlastStatus::getErrorMessage(status)));
|
|
|
sendCancelFiringMsg();
|
|
@@ -212,10 +212,10 @@ void firingWidget::handleProjectFiringMqttMessage(const QMqttMessage &message) {
|
|
|
ui->pushButton_2->setEnabled(false);
|
|
|
emit progressChanged(FiringStages::BlastFinished, m_row);
|
|
|
emit updatefiringStage(FiringStages::BlastFinished, m_row);
|
|
|
- emit updateProjectStatus(m_curProjUuid, BlastStatus::Blasted);
|
|
|
+ emit updateProjectStatus(m_blasterDevUuid, BlastStatus::Blasted);
|
|
|
ui->pushButton_2->setText("已完成起爆");
|
|
|
navProgress->setState(FiringStages::BlastFinished);
|
|
|
- emit closeFiring(m_curProjUuid, m_row);
|
|
|
+ emit closeFiring(m_blasterDevUuid, m_row);
|
|
|
break;
|
|
|
case FiringStages::CancelConfirmed:
|
|
|
navProgress->setState(FiringStages::BlastFinished);
|
|
@@ -224,8 +224,8 @@ void firingWidget::handleProjectFiringMqttMessage(const QMqttMessage &message) {
|
|
|
|
|
|
emit progressChanged(FiringStages::Starting, m_row);
|
|
|
emit updatefiringStage(FiringStages::CancelConfirmed, m_row);
|
|
|
- emit updateProjectStatus(m_curProjUuid, BlastStatus::Created);
|
|
|
- emit closeFiring(m_curProjUuid, m_row);
|
|
|
+ emit updateProjectStatus(m_blasterDevUuid, BlastStatus::Created);
|
|
|
+ emit closeFiring(m_blasterDevUuid, m_row);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
@@ -244,11 +244,11 @@ void firingWidget::onCountdownFinished(const QString &topic, const QString &mess
|
|
|
}
|
|
|
|
|
|
void firingWidget::onMqttDisconnected() {
|
|
|
- Logger::getInstance().info(QString("Project(%1) firing MQTT disconncted.").arg(m_curProjUuid));
|
|
|
+ Logger::getInstance().info(QString("Project(%1) firing MQTT disconncted.").arg(m_blasterDevUuid));
|
|
|
}
|
|
|
|
|
|
void firingWidget::onMqttConnected() {
|
|
|
- Logger::getInstance().info(QString("Project(%1) firing MQTT connected.").arg(m_curProjUuid));
|
|
|
+ Logger::getInstance().info(QString("Project(%1) firing MQTT connected.").arg(m_blasterDevUuid));
|
|
|
}
|
|
|
|
|
|
void firingWidget::onButtonPressedReceived(const QString &topic, const QString &message) {
|
|
@@ -259,26 +259,15 @@ void firingWidget::onButtonPressedReceived(const QString &topic, const QString &
|
|
|
Logger::getInstance().error(QString("onButtonPressedReceived: Failed to send data: %1").arg(data));
|
|
|
return;
|
|
|
}
|
|
|
- emit countdown(m_curProjUuid, topic, message);
|
|
|
+ emit countdown(m_blasterDevUuid, topic, message);
|
|
|
qDebug() << "Data sent successfully";
|
|
|
}
|
|
|
|
|
|
-void firingWidget::onSafeChecked(const QString projectUuid) {
|
|
|
- if (projectUuid == m_curProjUuid) {
|
|
|
- m_lastStage = 3; // 设置为待安全确认状态
|
|
|
- emit projSafeCheckSuccess(m_curProjUuid);
|
|
|
- emit lastStageChanged(m_lastStage);
|
|
|
- qDebug() << ANSI_COLOR_GREEN << "安全确认成功,进入待起爆状态" << ANSI_COLOR_RESET;
|
|
|
- } else {
|
|
|
- qDebug() << "Project UUID mismatch, expected: " << m_curProjUuid << ", got: " << projectUuid;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
// 状态改变
|
|
|
void firingWidget::handleFiringStageChanged(int newStage) {
|
|
|
qDebug() << ANSI_COLOR_GREEN << "handleFiringStageChanged: " << newStage << ANSI_COLOR_RESET;
|
|
|
- m_curProjUuid = "61c93e60e50e3439";
|
|
|
- QString topic = "hxgc/" + m_curProjUuid + "/BlastTask";
|
|
|
+ m_blasterDevUuid = "61c93e60e50e3439";
|
|
|
+ QString topic = "hxgc/" + m_blasterDevUuid + "/BlastTask";
|
|
|
QString message;
|
|
|
QString buttonText;
|
|
|
switch (newStage) {
|
|
@@ -316,9 +305,9 @@ void firingWidget::handleFiringStageChanged(int newStage) {
|
|
|
case FiringStages::ForceCanceled:
|
|
|
// 强制取消
|
|
|
sendCancelFiringMsg();
|
|
|
- emit updateProjectStatus(m_curProjUuid, BlastStatus::Created);
|
|
|
+ emit updateProjectStatus(m_blasterDevUuid, BlastStatus::Created);
|
|
|
emit updatefiringStage(FiringStages::ForceCanceled, m_row);
|
|
|
- emit closeFiring(m_curProjUuid, m_row);
|
|
|
+ emit closeFiring(m_blasterDevUuid, m_row);
|
|
|
break;
|
|
|
default:
|
|
|
|
|
@@ -350,7 +339,7 @@ void firingWidget::handleFiringStageChanged(int newStage) {
|
|
|
}
|
|
|
} else if (m_lastStage == FiringStages::NetChargingFinished && m_select) {
|
|
|
qDebug() << "多台起爆:待起爆状态";
|
|
|
- emit batchFiringSignal(m_curProjUuid);
|
|
|
+ emit batchFiringSignal(m_blasterDevUuid);
|
|
|
} else {
|
|
|
qDebug() << "Stage 值变为: " << newStage << "发送消息" << message.toUtf8();
|
|
|
}
|
|
@@ -359,6 +348,6 @@ void firingWidget::handleFiringStageChanged(int newStage) {
|
|
|
|
|
|
void firingWidget::sendCancelFiringMsg() {
|
|
|
QString message = "取消流程";
|
|
|
- QString topic = "hxgc/" + m_curProjUuid + "/BlastTask";
|
|
|
+ QString topic = "hxgc/" + m_blasterDevUuid + "/BlastTask";
|
|
|
sendMqttMessage(topic, message.toUtf8());
|
|
|
}
|