|
@@ -60,18 +60,23 @@ firingWidget::~firingWidget() {
|
|
}
|
|
}
|
|
|
|
|
|
void firingWidget::sendMqttMessage(const QString &topic, const QByteArray &message) {
|
|
void firingWidget::sendMqttMessage(const QString &topic, const QByteArray &message) {
|
|
|
|
+ qDebug() << ANSI_COLOR_GREEN << "XXX Sending MQTT message to topic:" << topic << "with message:" << message
|
|
|
|
+ << ANSI_COLOR_RESET;
|
|
if (mainMqttClient->isConnected()) {
|
|
if (mainMqttClient->isConnected()) {
|
|
mainMqttClient->sendMessage(topic, message, quint8(2), false);
|
|
mainMqttClient->sendMessage(topic, message, quint8(2), false);
|
|
} else {
|
|
} else {
|
|
QMessageBox::warning(nullptr, "MQTT未连接", "MQTT未连接, 无法发送消息: " + topic + ", " + message);
|
|
QMessageBox::warning(nullptr, "MQTT未连接", "MQTT未连接, 无法发送消息: " + topic + ", " + message);
|
|
Logger::getInstance().error("MQTT未连接, 无法发送消息" + topic + ", " + message);
|
|
Logger::getInstance().error("MQTT未连接, 无法发送消息" + topic + ", " + message);
|
|
}
|
|
}
|
|
|
|
+ qDebug() << ANSI_COLOR_GREEN << "XXXy Sending MQTT message to topic:" << topic << "with message:" << message;
|
|
}
|
|
}
|
|
|
|
|
|
void firingWidget::startBlasting() {
|
|
void firingWidget::startBlasting() {
|
|
// 等待3s mqtt连接后再发送mqtt消息
|
|
// 等待3s mqtt连接后再发送mqtt消息
|
|
m_lastStage = FiringStages::Starting;
|
|
m_lastStage = FiringStages::Starting;
|
|
|
|
+ qDebug() << ANSI_COLOR_GREEN << "Firing widget started with topic: 1" << m_topic << ANSI_COLOR_RESET;
|
|
emit lastStageChanged(FiringStages::Starting);
|
|
emit lastStageChanged(FiringStages::Starting);
|
|
|
|
+ qDebug() << ANSI_COLOR_GREEN << "Firing widget started with topic: 2" << m_topic << ANSI_COLOR_RESET;
|
|
checkBlasterConnection();
|
|
checkBlasterConnection();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -86,6 +91,7 @@ void firingWidget::checkBlasterConnection() {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
if (m_lastMsgTime.secsTo(QDateTime::currentDateTime()) > 3) {
|
|
if (m_lastMsgTime.secsTo(QDateTime::currentDateTime()) > 3) {
|
|
|
|
+ m_connectionCheckTimer->stop();
|
|
QMessageBox msgBox;
|
|
QMessageBox msgBox;
|
|
msgBox.setWindowTitle("起爆检测测试错误");
|
|
msgBox.setWindowTitle("起爆检测测试错误");
|
|
msgBox.setText("超时未收到爆破器消息,是否继续等待");
|
|
msgBox.setText("超时未收到爆破器消息,是否继续等待");
|
|
@@ -99,15 +105,17 @@ void firingWidget::checkBlasterConnection() {
|
|
"border-radius: 4px; }");
|
|
"border-radius: 4px; }");
|
|
msgBox.exec();
|
|
msgBox.exec();
|
|
if (msgBox.clickedButton() == noButton) {
|
|
if (msgBox.clickedButton() == noButton) {
|
|
- m_connectionCheckTimer->stop();
|
|
|
|
sendCancelFiringMsg();
|
|
sendCancelFiringMsg();
|
|
- emit closeFiring(m_curProjUuid);
|
|
|
|
|
|
+ emit closeFiring(m_curProjUuid, m_row);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ m_connectionCheckTimer->start(1000);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- m_connectionCheckTimer->start(5000);
|
|
|
|
|
|
+ qDebug() << ANSI_COLOR_GREEN << "Firing widget initialized with topic: 6" << m_connectionCheckTimer
|
|
|
|
+ << ANSI_COLOR_RESET;
|
|
|
|
+ m_connectionCheckTimer->start(1000);
|
|
}
|
|
}
|
|
void firingWidget::on_pushButton_2_clicked() { emit countdown(m_curProjUuid, m_topic, "message"); }
|
|
void firingWidget::on_pushButton_2_clicked() { emit countdown(m_curProjUuid, m_topic, "message"); }
|
|
|
|
|
|
@@ -275,7 +283,7 @@ void firingWidget::handleProjectFiringMqttMessage(const QMqttMessage &message) {
|
|
emit updateProjectStatus(m_curProjUuid, BlastStatus::Blasted);
|
|
emit updateProjectStatus(m_curProjUuid, BlastStatus::Blasted);
|
|
ui->pushButton_2->setText("已完成起爆");
|
|
ui->pushButton_2->setText("已完成起爆");
|
|
navProgress->setState(FiringStages::BlastFinished);
|
|
navProgress->setState(FiringStages::BlastFinished);
|
|
- emit closeFiring(m_curProjUuid);
|
|
|
|
|
|
+ emit closeFiring(m_curProjUuid, m_row);
|
|
break;
|
|
break;
|
|
case FiringStages::CancelConfirmed:
|
|
case FiringStages::CancelConfirmed:
|
|
navProgress->setState(FiringStages::BlastFinished);
|
|
navProgress->setState(FiringStages::BlastFinished);
|
|
@@ -285,7 +293,7 @@ void firingWidget::handleProjectFiringMqttMessage(const QMqttMessage &message) {
|
|
emit progressChanged(FiringStages::Starting, m_row);
|
|
emit progressChanged(FiringStages::Starting, m_row);
|
|
emit updateBlastStatus(FiringStages::Starting, m_row);
|
|
emit updateBlastStatus(FiringStages::Starting, m_row);
|
|
emit updateProjectStatus(m_curProjUuid, BlastStatus::Created);
|
|
emit updateProjectStatus(m_curProjUuid, BlastStatus::Created);
|
|
- emit closeFiring(m_curProjUuid);
|
|
|
|
|
|
+ emit closeFiring(m_curProjUuid, m_row);
|
|
|
|
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
@@ -300,7 +308,7 @@ void firingWidget::handleProjectFiringMqttMessage(const QMqttMessage &message) {
|
|
if (jsonObj.contains("data") && jsonObj["data"].isObject()) {
|
|
if (jsonObj.contains("data") && jsonObj["data"].isObject()) {
|
|
QJsonObject dataObject = jsonObj["data"].toObject();
|
|
QJsonObject dataObject = jsonObj["data"].toObject();
|
|
emit updateData(dataObject);
|
|
emit updateData(dataObject);
|
|
- emit closeFiring(m_curProjUuid);
|
|
|
|
|
|
+ emit closeFiring(m_curProjUuid, m_row);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -344,9 +352,11 @@ void firingWidget::onSafeChecked(const QString projectUuid) {
|
|
|
|
|
|
// 状态改变
|
|
// 状态改变
|
|
void firingWidget::handleFiringStageChanged(int newStage) {
|
|
void firingWidget::handleFiringStageChanged(int newStage) {
|
|
|
|
+ qDebug() << ANSI_COLOR_GREEN << "Stage 值变为: " << newStage << ANSI_COLOR_RESET;
|
|
QString topic = "hxgc/" + m_curProjUuid + "/P";
|
|
QString topic = "hxgc/" + m_curProjUuid + "/P";
|
|
QString message;
|
|
QString message;
|
|
QString buttonText;
|
|
QString buttonText;
|
|
|
|
+ qDebug() << ANSI_COLOR_GREEN << "Stage 值变为: i1" << newStage << ANSI_COLOR_RESET;
|
|
switch (newStage) {
|
|
switch (newStage) {
|
|
case FiringStages::Starting:
|
|
case FiringStages::Starting:
|
|
message = "起爆测试";
|
|
message = "起爆测试";
|
|
@@ -383,6 +393,7 @@ void firingWidget::handleFiringStageChanged(int newStage) {
|
|
|
|
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ qDebug() << ANSI_COLOR_GREEN << "Stage 值变为: i2" << newStage << ANSI_COLOR_RESET;
|
|
|
|
|
|
if (!message.isEmpty()) {
|
|
if (!message.isEmpty()) {
|
|
if (m_lastStage == FiringStages::NetChargingFinished && !m_select) {
|
|
if (m_lastStage == FiringStages::NetChargingFinished && !m_select) {
|
|
@@ -402,9 +413,9 @@ void firingWidget::handleFiringStageChanged(int newStage) {
|
|
[this, topic, message]() { this->onButtonPressedReceived(topic, message); });
|
|
[this, topic, message]() { this->onButtonPressedReceived(topic, message); });
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- qDebug() << "serialTool Not fond.";
|
|
|
|
|
|
+ qDebug() << "serialTool Not found.";
|
|
// 在准备起爆状态下 但是没有获取串口
|
|
// 在准备起爆状态下 但是没有获取串口
|
|
- m_lastStage = 10;
|
|
|
|
|
|
+ m_lastStage = FiringStages::PendingTriggerButtonClick;
|
|
}
|
|
}
|
|
} else if (m_lastStage == FiringStages::NetChargingFinished && m_select) {
|
|
} else if (m_lastStage == FiringStages::NetChargingFinished && m_select) {
|
|
qDebug() << "多台起爆:待起爆状态";
|
|
qDebug() << "多台起爆:待起爆状态";
|