diff --git a/LaunchRegisterKey.pro b/LaunchRegisterKey.pro index 0dcb8d0..bc8c760 100644 --- a/LaunchRegisterKey.pro +++ b/LaunchRegisterKey.pro @@ -18,18 +18,20 @@ DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ common.cpp \ main.cpp \ - network/udpdatathread.cpp \ + network/udpdatahandler.cpp \ network/udpsocketworker.cpp \ + ui/countdownmessagebox.cpp \ ui/settingwgt.cpp \ ui/widget.cpp HEADERS += \ common.h \ - network/udpdatathread.h \ + network/udpdatahandler.h \ network/udpsocketworker.h \ third_party/logger/EasySpdLog.h \ third_party/nlohmann/json.hpp \ third_party/nlohmann/json_fwd.hpp \ + ui/countdownmessagebox.h \ ui/settingwgt.h \ ui/widget.h \ utils/interface.h diff --git a/common.cpp b/common.cpp index 1074d00..7d8cf95 100644 --- a/common.cpp +++ b/common.cpp @@ -1,6 +1,8 @@ #include "common.h" #include #include +#include + #include using namespace nlohmann; @@ -12,15 +14,17 @@ Common::Common() bool Common::loadConfig(const QString &filePath) { - m_configFilePath = filePath; - std::ifstream jsonStream(filePath.toLocal8Bit()); + // 提取网络配置 + QString iniFilePath = filePath + "/network.ini"; + QSettings *configIni = new QSettings(iniFilePath, QSettings::IniFormat); + m_ipAddr = configIni->value("network/ip").toString(); + m_srcPort = configIni->value("network/src_port").toInt(); + m_dstPort = configIni->value("network/dst_port").toInt(); + + m_configFilePath = filePath + "/Config.json"; + std::ifstream jsonStream(m_configFilePath.toLocal8Bit()); m_configJson = json::parse(jsonStream); jsonStream.close(); - // 提取网络配置 - auto netCfg = m_configJson.at("network"); - m_ipAddr = QString::fromStdString(netCfg["ip"]); - m_srcPort = netCfg["src_port"]; - m_dstPort = netCfg["dst_port"]; // 提取工作模式 auto workmodes = m_configJson.at("workmode"); for (const auto& workmode : workmodes) @@ -53,7 +57,14 @@ bool Common::saveConfig(const QMap &productsCfg, const QMap< return true; } -QString Common::getHostAddress() const +bool Common::updateProductsConfig(const QMap &productsCfg) +{ + setProductConfig(productsCfg); + saveConfig(); + return true; +} + +QString Common::getIPAddr() const { return m_ipAddr; } @@ -73,7 +84,7 @@ bool Common::saveConfig() std::ofstream outFile(m_configFilePath.toLocal8Bit()); if (!outFile) { - qDebug() << "无法打开文件进行写入!"; + LError("Write config json file error!"); return false; } outFile << m_configJson.dump(4); diff --git a/common.h b/common.h index d1c29de..f378aef 100644 --- a/common.h +++ b/common.h @@ -14,21 +14,30 @@ class Common : public QObject, public Singleton Q_OBJECT friend class Singleton; public: + // 加载Config文件 bool loadConfig(const QString& filePath); - bool saveConfig(const QMap& productsCfg, const QMap& workmodeCfg); - - QString getHostAddress() const; + // 保存到Config文件 + bool saveConfig(const QMap &productsCfg, const QMap &workmodeCfg); + // 更新产品配置文件 + bool updateProductsConfig(const QMap &productsCfg); + // 获取IP地址 + QString getIPAddr() const; + // 获取端口号 int getSrcPort() const; int getDstPort() const; - + // 获取产品配置 QMap getProductConfigs(); + // 设置产品配置 void setProductConfig(const QMap& productsCfg); + // 获取工作模式 QMap getWorkModeConfigs(); + // 设置工作模式 void setWorkModeConfigs(const QMap& workmodeCfg); - + // 获取已选择的工作模式 const QMap& getSelectedProducts() const; - + // 获取当前工作模式 int getCurrentWorkMode() const; + // 设置当前工作模式 void setCurrentWorkMode(const int workMode); signals: @@ -39,10 +48,10 @@ private: void FilterSelectedProducts(); private: - QString m_configFilePath{}; + QString m_configFilePath{}; // 配置文件路径 nlohmann::json m_configJson{}; QString m_currentWorkPath{}; // 当前工作路径 - std::atomic m_currentMode{ -1 }; // 当前正在进行的工作模式 + std::atomic m_currentMode{ -1 }; // 当前正在进行的工作模式 QString m_ipAddr{}; int m_dstPort{}; int m_srcPort{}; diff --git a/main.cpp b/main.cpp index 9936b3c..140b982 100644 --- a/main.cpp +++ b/main.cpp @@ -2,6 +2,7 @@ #include +#include "common.h" #include "EasySpdLog.h" int main(int argc, char *argv[]) @@ -10,6 +11,9 @@ int main(int argc, char *argv[]) // 初始化日志类 auto loggerPath = QString(QApplication::applicationDirPath() + "/logs/log.log").toLocal8Bit(); SetLogger(loggerPath.data()); + // 加载配置文件 + QString filePath = QApplication::applicationDirPath() + "/config"; + Common::GetInstance()->loadConfig(filePath); // Widget w; w.move(0, 0); diff --git a/network/udpdatathread.cpp b/network/udpdatahandler.cpp similarity index 71% rename from network/udpdatathread.cpp rename to network/udpdatahandler.cpp index bbb5130..77eb2f5 100644 --- a/network/udpdatathread.cpp +++ b/network/udpdatahandler.cpp @@ -1,11 +1,11 @@ -#include "udpdatathread.h" +#include "udpdatahandler.h" #include #include "common.h" #include "EasySpdLog.h" #include -UdpDataThread::UdpDataThread(QObject *parent) +UdpDataHandler::UdpDataHandler(QObject *parent) : QObject(parent) , m_workerThread(new QThread()) , m_udpWorker(nullptr) @@ -13,47 +13,46 @@ UdpDataThread::UdpDataThread(QObject *parent) , m_connectStatus(false) , m_isSending(false) { - auto ipAddr = Common::GetInstance()->getHostAddress(); + auto ipAddr = Common::GetInstance()->getIPAddr(); auto recvPort = Common::GetInstance()->getSrcPort(); m_hostAddr.setAddress(ipAddr); m_udpWorker = new UdpSocketWorker(m_hostAddr, recvPort); m_udpWorker->moveToThread(m_workerThread); m_workerThread->start(); - connect(m_udpWorker, &UdpSocketWorker::dataReceived, this, &UdpDataThread::recvData); - connect(m_checkConnectTimer, &QTimer::timeout, this, &UdpDataThread::checkConnectSlot); + connect(m_udpWorker, &UdpSocketWorker::dataReceived, this, &UdpDataHandler::recvData); + connect(m_checkConnectTimer, &QTimer::timeout, this, &UdpDataHandler::checkConnectSlot); m_checkConnectTimer->start(1000); } -UdpDataThread::~UdpDataThread() +UdpDataHandler::~UdpDataHandler() { } -void UdpDataThread::sendSnId(const QString &data) +void UdpDataHandler::sendSnId(const QString &data) { QString snMsg = QString("5901%1%2").arg(data.length()).arg(data); - //m_udpWorker->sendData(snMsg.toLocal8Bit(), m_hostAddr, Common::GetInstance()->getDstPort()); m_udpWorker->startSending("send_sn", snMsg.toLocal8Bit(), m_hostAddr, Common::GetInstance()->getDstPort()); } -void UdpDataThread::sendStop() +void UdpDataHandler::sendStop() { m_isSending = false; } -void UdpDataThread::sendClose() +void UdpDataHandler::sendClose() { QString msg = QString("%1%2").arg(CONSTHEAD).arg("0301"); m_udpWorker->startSending("iecs_close", msg.toLocal8Bit(), m_hostAddr, Common::GetInstance()->getDstPort()); } -void UdpDataThread::stopClose() +void UdpDataHandler::stopClose() { m_udpWorker->stopSending("iecs_close"); } -void UdpDataThread::recvData(const QByteArray &data) +void UdpDataHandler::recvData(const QByteArray &data) { if (data.size() == 0) return; @@ -68,7 +67,7 @@ void UdpDataThread::recvData(const QByteArray &data) m_connectStatus = true; int type = dataStr.mid(6, 1).toInt(); Common::GetInstance()->setCurrentWorkMode(type); - emit connectStatus(true); + emit GetConnStatusSig(true); break; } case SIGNAL_SN: @@ -80,7 +79,7 @@ void UdpDataThread::recvData(const QByteArray &data) } else { - qDebug()<<"SIGNAL_SN:"<= 3) { Common::GetInstance()->setCurrentWorkMode(-1); - emit connectStatus(false); - qDebug()<<"disconnect"; + emit GetConnStatusSig(false); times = 0; } m_connectStatus = false; diff --git a/network/udpdatathread.h b/network/udpdatahandler.h similarity index 60% rename from network/udpdatathread.h rename to network/udpdatahandler.h index f3137da..5c33bf2 100644 --- a/network/udpdatathread.h +++ b/network/udpdatahandler.h @@ -13,21 +13,27 @@ typedef enum { SIGNAL_BEATDST //外挂软件状态 }SIGNALTYPE; -#define CONSTHEAD 59 +#define CONSTHEAD 59 //数据头 -class UdpDataThread : public QObject +class UdpDataHandler : public QObject { Q_OBJECT public: - UdpDataThread(QObject *parent = nullptr); - ~UdpDataThread(); - void sendSnId(const QString& data); + UdpDataHandler(QObject *parent = nullptr); + ~UdpDataHandler(); + // 循环发送产品SN号 + void sendSnId(const QString &data); + // 停止发送产品SN号 void sendStop(); + // 发送关闭信号 void sendClose(); + // 停止发送关闭信号 void stopClose(); signals: - void connectStatus(bool); - void registerRet(bool); + // 连接状态信号 + void GetConnStatusSig(bool); + // 注KEY是否完成信号 + void GetDoneSig(bool); private slots: void recvData(const QByteArray &data); void checkConnectSlot(); @@ -38,7 +44,7 @@ private: QHostAddress m_hostAddr; QTimer *m_checkConnectTimer; // 判断注KEY软件状态 - volatile bool m_connectStatus; + std::atomic m_connectStatus; volatile bool m_isSending; QString m_currSn; }; diff --git a/ui/countdownmessagebox.cpp b/ui/countdownmessagebox.cpp new file mode 100644 index 0000000..c3b12f2 --- /dev/null +++ b/ui/countdownmessagebox.cpp @@ -0,0 +1,37 @@ +#pragma execution_character_set("utf-8") +#include "countdownmessagebox.h" + +CountdownMessageBox::CountdownMessageBox(int timeoutSeconds, QWidget *parent) + : QMessageBox(parent) + , m_timeoutSeconds(timeoutSeconds) +{ + // 初始显示时间 + setText(tr("还有%1秒关闭...").arg(m_timeoutSeconds)); + + // 创建定时器 + m_timer = new QTimer(this); + connect(m_timer, &QTimer::timeout, this, &CountdownMessageBox::updateCountdown); + m_timer->start(1000); // 每秒触发一次 +} + +void CountdownMessageBox::showCountdownMessageBox(QWidget *parent, int timeoutSeconds, const QString &title) +{ + CountdownMessageBox msgBox(timeoutSeconds, parent); + msgBox.setWindowTitle(title); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msgBox.exec(); +} + +void CountdownMessageBox::updateCountdown() +{ + if (m_timeoutSeconds > 0) + { + --m_timeoutSeconds; + setText(tr("还有%1秒关闭...").arg(m_timeoutSeconds)); + } + else + { + m_timer->stop(); + accept(); // 关闭对话框 + } +} diff --git a/ui/countdownmessagebox.h b/ui/countdownmessagebox.h new file mode 100644 index 0000000..5cec4f2 --- /dev/null +++ b/ui/countdownmessagebox.h @@ -0,0 +1,19 @@ +#ifndef COUNTDOWNMESSAGEBOX_H +#define COUNTDOWNMESSAGEBOX_H + +#include +#include + +class CountdownMessageBox : public QMessageBox +{ +public: + explicit CountdownMessageBox(int timeoutSeconds, QWidget *parent = nullptr); + static void showCountdownMessageBox(QWidget *parent, int timeoutSeconds, const QString &title); +private slots: + void updateCountdown(); +private: + int m_timeoutSeconds; + QTimer *m_timer; +}; + +#endif // COUNTDOWNMESSAGEBOX_H diff --git a/ui/settingwgt.cpp b/ui/settingwgt.cpp index c70a47c..a7d0bc7 100644 --- a/ui/settingwgt.cpp +++ b/ui/settingwgt.cpp @@ -17,14 +17,12 @@ SettingWgt::SettingWgt(QWidget *parent) : ui(new Ui::SettingDlg) { ui->setupUi(this); - QString filePath = QApplication::applicationDirPath() + "/config/Config.json"; - Common::GetInstance()->loadConfig(filePath); + m_productsCfg = Common::GetInstance()->getProductConfigs(); m_workmodesCfg = Common::GetInstance()->getWorkModeConfigs(); m_productNums = m_productsCfg.size(); m_workModeNums = m_workmodesCfg.size(); initUI(); //一定放在前面 - loadConfig(); } SettingWgt::~SettingWgt() @@ -43,25 +41,30 @@ void SettingWgt::initUI() { QGroupBox *groupBox = new QGroupBox(workmodeCfg.name, ui->frame_set_mode); QGridLayout *groupLayout = new QGridLayout(groupBox); + QLabel *nameLab = new QLabel("正常", groupBox); groupLayout->addWidget(nameLab, 0, 0); QLineEdit *workPathEdit = new QLineEdit(workmodeCfg.workPath, groupBox); + workPathEdit->setEnabled(false); groupLayout->addWidget(workPathEdit, 0, 1); QPushButton *selectworkPathBtn = new QPushButton("<", groupBox); selectworkPathBtn->setMaximumWidth(30); groupLayout->addWidget(selectworkPathBtn, 0, 2); connect(selectworkPathBtn, &QPushButton::clicked, selectWorkPathMapper, qOverload<>(&QSignalMapper::map)); selectWorkPathMapper->setMapping(selectworkPathBtn, workmodeCfg.index); + selectworkPathBtn->hide(); QLabel *reworknameLab = new QLabel("返工", groupBox); groupLayout->addWidget(reworknameLab, 1, 0); QLineEdit *reworkPathEdit = new QLineEdit(workmodeCfg.reworkPath, groupBox); groupLayout->addWidget(reworkPathEdit, 1, 1); + reworkPathEdit->setEnabled(false); QPushButton *selectReworkPathBtn = new QPushButton("<", groupBox); selectReworkPathBtn->setMaximumWidth(30); groupLayout->addWidget(selectReworkPathBtn, 1, 2); connect(selectReworkPathBtn, &QPushButton::clicked, selectReworkPathMapper, qOverload<>(&QSignalMapper::map)); selectReworkPathMapper->setMapping(selectReworkPathBtn, workmodeCfg.index); + selectReworkPathBtn->hide(); m_workPathLineEdits.insert(workmodeCfg.index, qMakePair(workPathEdit, reworkPathEdit)); @@ -102,7 +105,7 @@ void SettingWgt::initUI() layout->addWidget(checkbox, i + 1, 1); // 产品SN适配设置输入框创建 QLineEdit *lineEdit = new QLineEdit(ui->frame_setting); - //lineEdit->setEnabled(false); + lineEdit->setEnabled(false); m_snFormatLineEdits.push_back(lineEdit); layout->addWidget(lineEdit, i + 1, 2); // 工作模式下拉框创建 @@ -113,15 +116,17 @@ void SettingWgt::initUI() } m_modeComboBoxes.push_back(comboBox); layout->addWidget(comboBox, i + 1, 3); + comboBox->setEnabled(false); } // 将 QSignalMapper 的信号连接到槽函数 connect(checkBoxMapper, static_cast(&QSignalMapper::mapped), this, &SettingWgt::onCheckBoxStateChanged); + loadConfig(); } void SettingWgt::loadConfig() { // 显示产品配置 - for (const auto& product : m_productsCfg) + for (const auto product : m_productsCfg) { int index = product.productId; bool selected = product.selected; @@ -139,14 +144,20 @@ void SettingWgt::loadConfig() void SettingWgt::onCheckBoxStateChanged(int index) { QCheckBox *checkBox = m_selectCheckBoxes[index]; - if (checkBox && checkBox->isChecked()) + if (checkBox) { - QString formatStr = m_snFormatLineEdits[index]->text(); - if (formatStr.isEmpty()) + if (checkBox->isChecked()) { - checkBox->setCheckState(Qt::Unchecked); - QMessageBox::warning(this, "启用失败", "产品SN适配为空,请先进行设置再进行启用!"); + QString formatStr = m_snFormatLineEdits[index]->text(); + if (formatStr.isEmpty()) + { + checkBox->setCheckState(Qt::Unchecked); + QMessageBox::warning(this, "启用失败", "产品SN适配为空,请先进行设置再进行启用!"); + return; + } } + m_productsCfg[index + 1].selected = checkBox->isChecked(); + Common::GetInstance()->updateProductsConfig(m_productsCfg); } } diff --git a/ui/settingwgt.h b/ui/settingwgt.h index a2f311d..8f4564c 100644 --- a/ui/settingwgt.h +++ b/ui/settingwgt.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "common.h" #include "nlohmann/json.hpp" diff --git a/ui/settingwgt.ui b/ui/settingwgt.ui index 7f245f6..89c8ced 100644 --- a/ui/settingwgt.ui +++ b/ui/settingwgt.ui @@ -13,7 +13,7 @@ Form - + @@ -34,30 +34,6 @@ - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 确认 - - - - - diff --git a/ui/widget.cpp b/ui/widget.cpp index b72e446..1ece6aa 100644 --- a/ui/widget.cpp +++ b/ui/widget.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "countdownmessagebox.h" #include "common.h" #include @@ -20,19 +21,16 @@ Widget::Widget(QWidget *parent) : QWidget(parent) , ui(new Ui::Widget) , m_settingDlg(new SettingWgt(this)) - , m_udpDataThread(new UdpDataThread(this)) + , m_udpDataThread(new UdpDataHandler(this)) , m_showSetting(false) + , m_isSwitching(false) { - QString filePath = QApplication::applicationDirPath() + "/config/Config.json"; - Common::GetInstance()->loadConfig(filePath); ui->setupUi(this); initUI(); - connect(m_settingDlg, &SettingWgt::SettingFinishSig, [this](){ - on_pushButton_setting_clicked(); - }); - connect(m_udpDataThread, &UdpDataThread::registerRet, this, &Widget::RegisterRetSlot); - connect(m_udpDataThread, &UdpDataThread::connectStatus, this, &Widget::ConnectStatusSlot); + connect(m_settingDlg, &SettingWgt::SettingFinishSig, this, &Widget::on_pushButton_setting_clicked); + connect(m_udpDataThread, &UdpDataHandler::GetDoneSig, this, &Widget::RegisterDoneSlot); + connect(m_udpDataThread, &UdpDataHandler::GetConnStatusSig, this, &Widget::GetConnStatusSlot); } Widget::~Widget() @@ -90,13 +88,13 @@ int Widget::startIECSProgram(const QString& workPath, const QString& snId) { QProcess *process = new QProcess(this); process->start(workPath); - qDebug()<<"startIECSProgram:"<waitForStarted()) { LError("Failed to start the program with arguments:{}", process->errorString()); return ExecIECSError; } m_udpDataThread->sendSnId(snId); + m_isSwitching = false; return NoError; } @@ -104,7 +102,11 @@ int Widget::checkForRepairProgram(const int mode, const QString& sn, bool& isFin { auto workModeCfg = Common::GetInstance()->getWorkModeConfigs(); QDir workDir(workModeCfg[mode].workPath); - workDir.cdUp(); + if (!workDir.cdUp()) + { + LError("Workdir cd up failed!"); + return -1; + } QString dbPath = workDir.absolutePath() + "/config.db"; return databaseQuery(dbPath, sn, isFind); } @@ -114,6 +116,7 @@ int Widget::databaseQuery(const QString& databasePath, const QString& deviceSn, // 创建和打开 SQLite 数据库 QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(databasePath); // 使用传入的数据库路径 + if (!db.open()) { LError("Failed to open database:{}", db.lastError().text()); @@ -123,38 +126,47 @@ int Widget::databaseQuery(const QString& databasePath, const QString& deviceSn, // 创建查询对象 QSqlQuery query(db); + // 准备 SQL 查询 query.prepare("SELECT COUNT(1) FROM history WHERE device_sn = :device_sn;"); query.bindValue(":device_sn", deviceSn); + // 执行查询 if (!query.exec()) { LError("Failed to execute query:{}", query.lastError().text()); isFind = false; db.close(); + QSqlDatabase::removeDatabase(QSqlDatabase::defaultConnection); return DatabaseSelectError; } + // 处理查询结果 if (query.next()) { int count = query.value(0).toInt(); isFind = (count > 0); db.close(); + QSqlDatabase::removeDatabase(QSqlDatabase::defaultConnection); return NoError; } + isFind = false; db.close(); + QSqlDatabase::removeDatabase(QSqlDatabase::defaultConnection); return DatabaseUnknownError; } -void Widget::RegisterRetSlot(bool ret) +void Widget::RegisterDoneSlot(bool ret) { + qDebug()<<"11111"; ui->lineEdit_snId->setEnabled(true); } -void Widget::ConnectStatusSlot(bool ret) +void Widget::GetConnStatusSlot(bool ret) { - if (!ret) + if (!ret && !m_isSwitching) { + qDebug()<<"ret:"<lineEdit_snId->setEnabled(true); } } @@ -164,8 +176,8 @@ void Widget::on_pushButton_setting_clicked() if (ui->widget_setting->isHidden()) { ui->pushButton_setting->setIcon(QIcon(":/resources/folding.png")); - m_settingDlg->loadConfig(); ui->widget_setting->show(); + m_settingDlg->loadConfig(); int currentWidth = this->width(); this->adjustSize(); this->resize(currentWidth, this->height()); // 只保持高度变化 @@ -190,9 +202,34 @@ void Widget::addLogItem(const QString &text) ui->list_log->addItem(text); // 添加新条目 } -int Widget::switchProgram() +int Widget::switchProgram(const QString snId, const int mode, const bool isRepair) { + static bool isFirstRepair = true; + if (isRepair && isFirstRepair) + { + isFirstRepair = false; + CountdownMessageBox::showCountdownMessageBox(this, 3, "正在切换返修程序包!"); + } + else if (!isRepair) + { + isFirstRepair = true; + } + auto workModeCfgs = Common::GetInstance()->getWorkModeConfigs(); + auto workModeCfg = workModeCfgs[mode]; + QString workPath = isRepair ? workModeCfg.reworkPath : workModeCfg.workPath; + QTimer *timer = new QTimer(this); + connect(timer, &QTimer::timeout, this, [this, timer, snId, workPath]() { + if (Common::GetInstance()->getCurrentWorkMode() == -1) + { + m_isSwitching = true; + m_udpDataThread->stopClose(); + timer->stop(); // 停止定时器 + // 启动 IECS 程序 + startIECSProgram(workPath, snId); + } + }); + timer->start(1000); return 0; } @@ -218,7 +255,7 @@ void Widget::on_lineEdit_snId_returnPressed() } if (productFormat.isEmpty()) { - QMessageBox::information(this, "警告", "当前SN与启用设值SN不匹配,请检查或重新扫码"); + QMessageBox::information(this, "警告", "当前SN与启用设值SN不匹配,请检查设置或重新扫码"); return; } ui->lineEdit_snId->setEnabled(false); @@ -232,8 +269,7 @@ void Widget::on_lineEdit_snId_returnPressed() return; } auto selectMode = selectedProducts[productFormat]; - auto workModeCfgs = Common::GetInstance()->getWorkModeConfigs(); - if (selectMode != currWorkMode) + if (selectMode != currWorkMode || isRepair) { // 切换工作模式 if (currWorkMode != -1) @@ -242,20 +278,7 @@ void Widget::on_lineEdit_snId_returnPressed() } //TODO:不相等时,m_udpDataThread发送关闭信号,等待Common单例类中的标志位变成-1后,m_udpDataThread停止发送关闭信号并启动IECS程序 //同时需要去IECS程序路径中查找数据库,判断是否使用返修程序 - auto workModeCfg = workModeCfgs[selectMode]; - QString workPath = isRepair ? workModeCfg.reworkPath : workModeCfg.workPath; - qDebug()<<"workPath:"<getCurrentWorkMode() == -1) - { - m_udpDataThread->stopClose(); - timer->stop(); // 停止定时器 - // 启动 IECS 程序 - startIECSProgram(workPath, snId); - } - }); - timer->start(1000); + switchProgram(snId, selectMode, isRepair); return; } m_udpDataThread->sendSnId(snId); diff --git a/ui/widget.h b/ui/widget.h index 4aee6b9..7dc2815 100644 --- a/ui/widget.h +++ b/ui/widget.h @@ -3,7 +3,7 @@ #include #include "settingwgt.h" -#include "udpdatathread.h" +#include "udpdatahandler.h" QT_BEGIN_NAMESPACE namespace Ui { class Widget; } @@ -24,10 +24,10 @@ private: int databaseQuery(const QString& databasePath, const QString& deviceSn, bool& isFind); private slots: - void RegisterRetSlot(bool ret); - void ConnectStatusSlot(bool ret); + void RegisterDoneSlot(bool ret); + void GetConnStatusSlot(bool ret); void addLogItem(const QString& text); - int switchProgram(); + int switchProgram(const QString snId, const int mode, const bool isRepair); void on_pushButton_setting_clicked(); void on_lineEdit_snId_returnPressed(); void on_pushButton_sendSnId_clicked(); @@ -35,7 +35,8 @@ private slots: private: Ui::Widget *ui; SettingWgt *m_settingDlg; - UdpDataThread *m_udpDataThread; + UdpDataHandler *m_udpDataThread; bool m_showSetting; + bool m_isSwitching; }; #endif // WIDGET_H