From d4ae45d1dc8f1e87933e85bca2fdfe3fad777bfc Mon Sep 17 00:00:00 2001 From: Carl <732416424@qq.com> Date: Mon, 4 Nov 2024 18:07:54 +0800 Subject: [PATCH] [Add] English version 1.0.0 --- Language/BatteryMonitor_CHN.qm | Bin 1713 -> 22 bytes Language/BatteryMonitor_ENG.qm | Bin 979 -> 14230 bytes dialoglogin.cpp | 19 ++++++++- dialoglogin.h | 1 + mainwindow.cpp | 24 +++++++++--- mainwindow.h | 4 ++ mainwindow.ui | 69 ++++++++++++++++----------------- modbusrtu.cpp | 6 +++ modbusrtu.h | 5 ++- 9 files changed, 83 insertions(+), 45 deletions(-) diff --git a/Language/BatteryMonitor_CHN.qm b/Language/BatteryMonitor_CHN.qm index bd7bce8cc0bbb38a0b1b74b0b1b2aee4e6cf90c9..ae247bce803ef44461bb43c214ed3b03f201f91f 100644 GIT binary patch delta 8 PcmdnUD>gxdiP0GV3EBa_ literal 1713 zcmah|T}TvB6u#@;-JRW47b+;Chw&lk#aJUjDhzj3q};&OcHrP)f{A3)V zJRadm47MHNsqJ7#5T5sgokxxa@UfR8M>)pQgI)5_gR@{Oyislx?l*Yp1JH%C-jO^wM|1g{|2gm$7ewxSfjBPp&gk>vn!QT@if_PXE<5Gvsc<(GJDc$AwuMe`7 zneHJdbK+y&<+HD27j?4y3RRKVpd^YkrdYW+Q*Y(YOt0?X4iGiY))9r8(1t87vG-IaLa*Og!$dH?BowTq4>G_KkB+-CYMa8%N$ny|t#^x8ktJ(WTxmZK?# zGP|n8L`uk*=?y4c)lMxl!vpBhqOK5E9m~-L+RJ@kg;fhF%NF4D`=)vw=BQ2)3t>=C z+_{}*>}!iAL- diff --git a/Language/BatteryMonitor_ENG.qm b/Language/BatteryMonitor_ENG.qm index 2851da24cb1ff9b70234f1fa7da5c776252a1912..469fbfd57f674739ab803a18ab088369cf351d8b 100644 GIT binary patch literal 14230 zcmbVS3s_Xwwcay>!vF&ZCy0myQG8b;K9ZQE#s`>a6D|adruW`jDH8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ZfZMRIlFU4W?pJ>DuzlFL)meehoXuLswy)-55IA&E~!bS>G;)f zxnve6 zy)-eMfNd-RMTFeUADoe2t`J<3SW;T7;FMT|-(Hrm%+zxHO1KMv&T>jDDM>A=#IKSQ lq>_k;1gj$=+&DnydF1C32o$h!!Ko#s7-8H2Ox#S2i~zNh6M_H$ diff --git a/dialoglogin.cpp b/dialoglogin.cpp index 27409d0..c624531 100644 --- a/dialoglogin.cpp +++ b/dialoglogin.cpp @@ -10,6 +10,7 @@ #include "appserial.h" #include "modbusrtu.h" #include +#include DialogLogin::DialogLogin(QWidget *parent) : QDialog(parent) @@ -84,11 +85,24 @@ void DialogLogin::init() connect(m_ModbusRTU, &ModbusRTU::sig_showModbusData_base_info_list_47_49_51_53_55, m_MainWindow, &MainWindow::slot_pageHomeBaseInfo47_49_51_53_55); //写寄存器的信号与槽的连接 - connect(m_MainWindow, &MainWindow::write_regs_signals, m_ModbusRTU, &ModbusRTU::write_regs_slot); + connect(m_MainWindow, &MainWindow::write_regs_signals, m_ModbusRTU, &ModbusRTU::write_regs_slot, Qt::QueuedConnection); //读寄存器的信号与槽的连接 - connect(m_MainWindow, &MainWindow::read_regs_signals, m_ModbusRTU, &ModbusRTU::read_regs_slot); + connect(m_MainWindow, &MainWindow::read_regs_signals, m_ModbusRTU, &ModbusRTU::read_regs_slot, Qt::QueuedConnection); connect(m_ModbusRTU, &ModbusRTU::sig_showReadHoldingRegs, m_MainWindow, &MainWindow::slot_pageParaSetShow); + + //主窗口关闭时,关闭线程 + connect(m_MainWindow, &MainWindow::closeThread, this, [=]{ + qDebug() << "关闭线程"; + m_ModbusRTU->quit(); + }); + + // QMetaObject::invokeMethod(m_ModbusRTU,"read_regs_slot",Qt::QueuedConnection); + // connect(m_ModbusRTU, &ModbusRTU::sig_readMoveToThread, m_ModbusRTU, &ModbusRTU::read_regs_slot, Qt::QueuedConnection); + // thread = new QThread; + + // m_ModbusRTU->moveToThread(thread); + // thread->start(); } void DialogLogin::serialInit() @@ -247,6 +261,7 @@ void DialogLogin::slot_btnConnect_clicked() m_MainWindow->statusBarConnectedIcon->setPixmap(QPixmap(QIcon(":/Image/connected2.png").pixmap(QSize(24, 24)))); m_MainWindow->show(); // m_MainWindow->showMaximized(); + // m_ModbusRTU->start(); m_ModbusRTU->start(); } else { diff --git a/dialoglogin.h b/dialoglogin.h index 50cd32c..2ddb72b 100644 --- a/dialoglogin.h +++ b/dialoglogin.h @@ -31,6 +31,7 @@ private: AppSerial *m_Serial; ModbusRTU *m_ModbusRTU; QSettings *ini; + // QThread *thread; int BCUNumbers; signals: diff --git a/mainwindow.cpp b/mainwindow.cpp index 7f1be71..8ad5ede 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -26,11 +26,15 @@ #include #include "modbusrtu.h" #include +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { + qDebug() << "mainwindow:进入线程:" << QThread::currentThread(); + // QMetaObject::invokeMethod(this, "write_regs_slot", Qt::QueuedConnection); + // QMetaObject::invokeMethod(this, "read_regs_slot", Qt::QueuedConnection); ui->setupUi(this); this->init(); this->setMenuStyle(); @@ -218,12 +222,12 @@ void MainWindow::init() //设置按钮的提示文本 - ui->btnHome->setToolTip("概述信息"); - ui->btnBattery->setToolTip("详细信息"); - ui->btnParaSet->setToolTip("参数设置"); - ui->btnDebug->setToolTip("报文信息"); - ui->btnFlash->setToolTip("升级调试"); - ui->btnSetup->setToolTip("串口信息"); + ui->btnHome->setToolTip("概述信息(Overview Information)"); + ui->btnBattery->setToolTip("详细信息(Detailed Information)"); + ui->btnParaSet->setToolTip("参数设置(Parameter Settings)"); + ui->btnDebug->setToolTip("报文信息(Message Information)"); + ui->btnFlash->setToolTip("升级调试(Upgrade Debugging)"); + ui->btnSetup->setToolTip("串口信息(Serial Port)"); ui->btnSetup->setStyleSheet("QToolTip { position: absolute; left: 20px; top: 20px; }"); // ui->btnRecord->setToolTip("记录导出"); @@ -3307,6 +3311,13 @@ void MainWindow::slot_pageParaSetShow(QByteArray byteArray, int dataType, int ro } +void MainWindow::closeEvent(QCloseEvent *e) +{ + emit closeThread(); + + QWidget::closeEvent(e); +} + void MainWindow::on_pageParaSetWrite_clicked() { BatteryConfig::Item item; @@ -3705,4 +3716,5 @@ void MainWindow::on_pageParaSetWrite_clicked() void MainWindow::on_tabChanged(int index) { tabWidget_paraset_index = index; + ui->pageParaSetCheck->setCheckState(Qt::Unchecked); } diff --git a/mainwindow.h b/mainwindow.h index 999d5bb..503af76 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -119,6 +119,7 @@ signals: void closeLogin(); void write_regs_signals(int addr, const uint16_t data); void read_regs_signals(int addr, int nb, uint16_t *data, int row); + void closeThread(); public: void slot_getBcuNumberFromDialoglogin(int number); @@ -131,6 +132,9 @@ public: void slot_pageHomeBaseInfo47_49_51_53_55(QList byteArray, int dataType); void slot_pageParaSetShow(QByteArray byteArray, int dataType, int row, int nb); +protected: + void closeEvent(QCloseEvent *e) override; + private slots: void on_pageParaSetCheck_stateChanged(int arg1); void on_pageParaSetRead_clicked(); diff --git a/mainwindow.ui b/mainwindow.ui index d6c6ea9..36779a0 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -281,7 +281,7 @@ background-color: rgba(255, 255, 255, 0); - 2 + 1 @@ -290,7 +290,7 @@ background-color: rgba(255, 255, 255, 0); } - + @@ -482,8 +482,11 @@ background-color: rgba(255, 255, 255, 0); 9 + + + - <html><head/><body><p align="center">总正继电器</p></body></html> + 总正继电器 Qt::AlignCenter @@ -499,7 +502,7 @@ background-color: rgba(255, 255, 255, 0); - <html><head/><body><p align="center">预充继电器</p></body></html> + 预充继电器 Qt::AlignCenter @@ -515,7 +518,7 @@ background-color: rgba(255, 255, 255, 0); - <html><head/><body><p align="center">总负继电器</p></body></html> + 总负继电器 Qt::AlignCenter @@ -531,7 +534,7 @@ background-color: rgba(255, 255, 255, 0); - <html><head/><body><p align="center">隔离开关</p></body></html> + 隔离开关 Qt::AlignCenter @@ -749,8 +752,8 @@ background-color: rgba(255, 255, 255, 0); 0 0 - 614 - 235 + 1113 + 379 @@ -2378,7 +2381,7 @@ background-color: rgba(255, 255, 255, 0); - 1 + 2 @@ -19177,7 +19180,7 @@ background-color: rgba(255, 255, 255, 0); - check all + 全部勾选 @@ -19197,14 +19200,14 @@ background-color: rgba(255, 255, 255, 0); - read + 读取 - write + 写入 @@ -19355,14 +19358,14 @@ background-color: rgba(255, 255, 255, 0); - Display + 显示 - Clear + 清除 @@ -19392,21 +19395,21 @@ li.checked::marker { content: "\2612"; } - Save Log + 保存 - SendData + 发送数据 - Time Starmp + 时间戳 @@ -19452,13 +19455,13 @@ li.checked::marker { content: "\2612"; } - File + 文件 - Connection + 连接 @@ -19467,36 +19470,30 @@ li.checked::marker { content: "\2612"; } - View + 视图 - Help + 帮助 - Language + 语言 - Debug - - - - - Flash + 调试 - @@ -19509,22 +19506,22 @@ li.checked::marker { content: "\2612"; } - Exit + 退出 - Connect + 连接 - Disconnect + 断开 - Auto Connect + 自动连接 @@ -19535,7 +19532,7 @@ li.checked::marker { content: "\2612"; } true - Show Status Bar + 显示状态栏 @@ -19549,7 +19546,7 @@ li.checked::marker { content: "\2612"; } true - English + 英语 @@ -19560,7 +19557,7 @@ li.checked::marker { content: "\2612"; } true - Chinese + 中文 diff --git a/modbusrtu.cpp b/modbusrtu.cpp index 6bfb632..6741674 100644 --- a/modbusrtu.cpp +++ b/modbusrtu.cpp @@ -7,6 +7,8 @@ ModbusRTU::ModbusRTU(QObject *parent) : QThread(parent) { init(); + // start(); + } ModbusRTU::~ModbusRTU() @@ -23,6 +25,8 @@ void ModbusRTU::init() void ModbusRTU::run() { qDebug() << "进入线程:" << QThread::currentThread(); + // QMetaObject::invokeMethod(QThread::currentThread(), "read_regs_slot", Qt::QueuedConnection); + // QMetaObject::invokeMethod(QThread::currentThread(), "write_regs_slot", Qt::QueuedConnection); while(true) { // qDebug() << "11111111111111111111111111111111"; @@ -166,6 +170,7 @@ void ModbusRTU::run() void ModbusRTU::write_regs_slot(int addr,const uint16_t data) { + qDebug() << "write:进入线程:" << QThread::currentThread(); int rc = write_single_register(addr, data); if(MODBUS_ERR == rc) { qDebug() << "######modbus no message"; @@ -175,6 +180,7 @@ void ModbusRTU::write_regs_slot(int addr,const uint16_t data) void ModbusRTU::read_regs_slot(int addr, int nb, uint16_t *data, int row) { + qDebug() << "read:进入线程:" << QThread::currentThread(); int rc = read_holding_register(addr, nb, data); if(MODBUS_ERR == rc) { // qDebug() << "modbus no message"; diff --git a/modbusrtu.h b/modbusrtu.h index 6727d85..f23d86e 100644 --- a/modbusrtu.h +++ b/modbusrtu.h @@ -13,6 +13,8 @@ class ModbusRTU : public QThread public: ModbusRTU(QObject *parent = nullptr); ~ModbusRTU(); + +public slots: void write_regs_slot(int addr, const uint16_t data); void read_regs_slot(int addr, int nb, uint16_t *data, int row); @@ -25,7 +27,7 @@ public: int dataBit; int stopBit; -protected: +public: void run() override; private: @@ -70,6 +72,7 @@ signals: void sig_showModbusData_base_info_list_47_49_51_53_55(QList byteArray,int dataType); void sig_showReadHoldingRegs(QByteArray byteArray,int dataType, int row, int nb); + public slots: };