[Add] English version 1.0.0

This commit is contained in:
Carl 2024-11-04 18:07:54 +08:00
parent d36da2f3ce
commit d4ae45d1dc
9 changed files with 83 additions and 45 deletions

Binary file not shown.

Binary file not shown.

View File

@ -10,6 +10,7 @@
#include "appserial.h" #include "appserial.h"
#include "modbusrtu.h" #include "modbusrtu.h"
#include <windef.h> #include <windef.h>
#include <QThread>
DialogLogin::DialogLogin(QWidget *parent) DialogLogin::DialogLogin(QWidget *parent)
: QDialog(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_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_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() 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->statusBarConnectedIcon->setPixmap(QPixmap(QIcon(":/Image/connected2.png").pixmap(QSize(24, 24))));
m_MainWindow->show(); m_MainWindow->show();
// m_MainWindow->showMaximized(); // m_MainWindow->showMaximized();
// m_ModbusRTU->start();
m_ModbusRTU->start(); m_ModbusRTU->start();
} }
else { else {

View File

@ -31,6 +31,7 @@ private:
AppSerial *m_Serial; AppSerial *m_Serial;
ModbusRTU *m_ModbusRTU; ModbusRTU *m_ModbusRTU;
QSettings *ini; QSettings *ini;
// QThread *thread;
int BCUNumbers; int BCUNumbers;
signals: signals:

View File

@ -26,11 +26,15 @@
#include <QTreeView> #include <QTreeView>
#include "modbusrtu.h" #include "modbusrtu.h"
#include <QWidget> #include <QWidget>
#include <QCloseEvent>
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
, ui(new Ui::MainWindow) , 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); ui->setupUi(this);
this->init(); this->init();
this->setMenuStyle(); this->setMenuStyle();
@ -218,12 +222,12 @@ void MainWindow::init()
//设置按钮的提示文本 //设置按钮的提示文本
ui->btnHome->setToolTip("概述信息"); ui->btnHome->setToolTip("概述信息(Overview Information)");
ui->btnBattery->setToolTip("详细信息"); ui->btnBattery->setToolTip("详细信息(Detailed Information)");
ui->btnParaSet->setToolTip("参数设置"); ui->btnParaSet->setToolTip("参数设置(Parameter Settings)");
ui->btnDebug->setToolTip("报文信息"); ui->btnDebug->setToolTip("报文信息(Message Information)");
ui->btnFlash->setToolTip("升级调试"); ui->btnFlash->setToolTip("升级调试(Upgrade Debugging)");
ui->btnSetup->setToolTip("串口信息"); ui->btnSetup->setToolTip("串口信息(Serial Port)");
ui->btnSetup->setStyleSheet("QToolTip { position: absolute; left: 20px; top: 20px; }"); ui->btnSetup->setStyleSheet("QToolTip { position: absolute; left: 20px; top: 20px; }");
// ui->btnRecord->setToolTip("记录导出"); // 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() void MainWindow::on_pageParaSetWrite_clicked()
{ {
BatteryConfig::Item item; BatteryConfig::Item item;
@ -3705,4 +3716,5 @@ void MainWindow::on_pageParaSetWrite_clicked()
void MainWindow::on_tabChanged(int index) void MainWindow::on_tabChanged(int index)
{ {
tabWidget_paraset_index = index; tabWidget_paraset_index = index;
ui->pageParaSetCheck->setCheckState(Qt::Unchecked);
} }

View File

@ -119,6 +119,7 @@ signals:
void closeLogin(); void closeLogin();
void write_regs_signals(int addr, const uint16_t data); void write_regs_signals(int addr, const uint16_t data);
void read_regs_signals(int addr, int nb, uint16_t *data, int row); void read_regs_signals(int addr, int nb, uint16_t *data, int row);
void closeThread();
public: public:
void slot_getBcuNumberFromDialoglogin(int number); void slot_getBcuNumberFromDialoglogin(int number);
@ -131,6 +132,9 @@ public:
void slot_pageHomeBaseInfo47_49_51_53_55(QList<int> byteArray, int dataType); void slot_pageHomeBaseInfo47_49_51_53_55(QList<int> byteArray, int dataType);
void slot_pageParaSetShow(QByteArray byteArray, int dataType, int row, int nb); void slot_pageParaSetShow(QByteArray byteArray, int dataType, int row, int nb);
protected:
void closeEvent(QCloseEvent *e) override;
private slots: private slots:
void on_pageParaSetCheck_stateChanged(int arg1); void on_pageParaSetCheck_stateChanged(int arg1);
void on_pageParaSetRead_clicked(); void on_pageParaSetRead_clicked();

View File

@ -281,7 +281,7 @@ background-color: rgba(255, 255, 255, 0);
<string notr="true"/> <string notr="true"/>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="pageHome"> <widget class="QWidget" name="pageHome">
<property name="styleSheet"> <property name="styleSheet">
@ -290,7 +290,7 @@ background-color: rgba(255, 255, 255, 0);
}</string> }</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_7" columnstretch="2,5" columnminimumwidth="0,0"> <layout class="QGridLayout" name="gridLayout_7" columnstretch="2,6" columnminimumwidth="0,0">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="styleSheet"> <property name="styleSheet">
@ -482,8 +482,11 @@ background-color: rgba(255, 255, 255, 0);
<pointsize>9</pointsize> <pointsize>9</pointsize>
</font> </font>
</property> </property>
<property name="locale">
<locale language="Chinese" country="China"/>
</property>
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;总正继电器&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>总正继电器</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
@ -499,7 +502,7 @@ background-color: rgba(255, 255, 255, 0);
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;预充继电器&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>预充继电器</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
@ -515,7 +518,7 @@ background-color: rgba(255, 255, 255, 0);
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;总负继电器&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>总负继电器</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
@ -531,7 +534,7 @@ background-color: rgba(255, 255, 255, 0);
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;隔离开关&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>隔离开关</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
@ -749,8 +752,8 @@ background-color: rgba(255, 255, 255, 0);
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>614</width> <width>1113</width>
<height>235</height> <height>379</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_12"> <layout class="QGridLayout" name="gridLayout_12">
@ -2378,7 +2381,7 @@ background-color: rgba(255, 255, 255, 0);
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTabWidget" name="tabWidgetBCU"> <widget class="QTabWidget" name="tabWidgetBCU">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="BCU_sysInfo"> <widget class="QWidget" name="BCU_sysInfo">
<attribute name="title"> <attribute name="title">
@ -19177,7 +19180,7 @@ background-color: rgba(255, 255, 255, 0);
<item> <item>
<widget class="QCheckBox" name="pageParaSetCheck"> <widget class="QCheckBox" name="pageParaSetCheck">
<property name="text"> <property name="text">
<string>check all</string> <string>全部勾选</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -19197,14 +19200,14 @@ background-color: rgba(255, 255, 255, 0);
<item> <item>
<widget class="QPushButton" name="pageParaSetRead"> <widget class="QPushButton" name="pageParaSetRead">
<property name="text"> <property name="text">
<string>read</string> <string>读取</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pageParaSetWrite"> <widget class="QPushButton" name="pageParaSetWrite">
<property name="text"> <property name="text">
<string>write</string> <string>写入</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -19355,14 +19358,14 @@ background-color: rgba(255, 255, 255, 0);
<item row="0" column="1"> <item row="0" column="1">
<widget class="QCheckBox" name="pageDebugCheckBoxDisplay"> <widget class="QCheckBox" name="pageDebugCheckBoxDisplay">
<property name="text"> <property name="text">
<string>Display</string> <string>显示</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QPushButton" name="pageDebugBtnClear"> <widget class="QPushButton" name="pageDebugBtnClear">
<property name="text"> <property name="text">
<string>Clear</string> <string>清除</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -19392,21 +19395,21 @@ li.checked::marker { content: &quot;\2612&quot;; }
<item row="0" column="3"> <item row="0" column="3">
<widget class="QCheckBox" name="pageDebugCheckBoxSaveLog"> <widget class="QCheckBox" name="pageDebugCheckBoxSaveLog">
<property name="text"> <property name="text">
<string>Save Log</string> <string>保存</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QPushButton" name="btnSendData"> <widget class="QPushButton" name="btnSendData">
<property name="text"> <property name="text">
<string>SendData</string> <string>发送数据</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QCheckBox" name="pageDebugCheckBoxStarmp"> <widget class="QCheckBox" name="pageDebugCheckBoxStarmp">
<property name="text"> <property name="text">
<string>Time Starmp</string> <string>时间戳</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -19452,13 +19455,13 @@ li.checked::marker { content: &quot;\2612&quot;; }
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
<property name="title"> <property name="title">
<string>File</string> <string>文件</string>
</property> </property>
<addaction name="actionExit"/> <addaction name="actionExit"/>
</widget> </widget>
<widget class="QMenu" name="menuConnection"> <widget class="QMenu" name="menuConnection">
<property name="title"> <property name="title">
<string>Connection</string> <string>连接</string>
</property> </property>
<addaction name="actionConnect"/> <addaction name="actionConnect"/>
<addaction name="actionDisconnect"/> <addaction name="actionDisconnect"/>
@ -19467,36 +19470,30 @@ li.checked::marker { content: &quot;\2612&quot;; }
</widget> </widget>
<widget class="QMenu" name="menuView"> <widget class="QMenu" name="menuView">
<property name="title"> <property name="title">
<string>View</string> <string>视图</string>
</property> </property>
<addaction name="actionShow_Status_bar"/> <addaction name="actionShow_Status_bar"/>
</widget> </widget>
<widget class="QMenu" name="menuHelp"> <widget class="QMenu" name="menuHelp">
<property name="title"> <property name="title">
<string>Help</string> <string>帮助</string>
</property> </property>
</widget> </widget>
<widget class="QMenu" name="menuLanguage"> <widget class="QMenu" name="menuLanguage">
<property name="title"> <property name="title">
<string>Language</string> <string>语言</string>
</property> </property>
<addaction name="actionEnglish"/> <addaction name="actionEnglish"/>
<addaction name="actionChinese"/> <addaction name="actionChinese"/>
</widget> </widget>
<widget class="QMenu" name="menuDebug"> <widget class="QMenu" name="menuDebug">
<property name="title"> <property name="title">
<string>Debug</string> <string>调试</string>
</property>
</widget>
<widget class="QMenu" name="menuFlash">
<property name="title">
<string>Flash</string>
</property> </property>
</widget> </widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
<addaction name="menuConnection"/> <addaction name="menuConnection"/>
<addaction name="menuDebug"/> <addaction name="menuDebug"/>
<addaction name="menuFlash"/>
<addaction name="menuView"/> <addaction name="menuView"/>
<addaction name="menuHelp"/> <addaction name="menuHelp"/>
<addaction name="menuLanguage"/> <addaction name="menuLanguage"/>
@ -19509,22 +19506,22 @@ li.checked::marker { content: &quot;\2612&quot;; }
</action> </action>
<action name="actionExit"> <action name="actionExit">
<property name="text"> <property name="text">
<string>Exit</string> <string>退出</string>
</property> </property>
</action> </action>
<action name="actionConnect"> <action name="actionConnect">
<property name="text"> <property name="text">
<string>Connect</string> <string>连接</string>
</property> </property>
</action> </action>
<action name="actionDisconnect"> <action name="actionDisconnect">
<property name="text"> <property name="text">
<string>Disconnect</string> <string>断开</string>
</property> </property>
</action> </action>
<action name="actionAuto_Connect"> <action name="actionAuto_Connect">
<property name="text"> <property name="text">
<string>Auto Connect</string> <string>自动连接</string>
</property> </property>
</action> </action>
<action name="actionShow_Status_bar"> <action name="actionShow_Status_bar">
@ -19535,7 +19532,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Show Status Bar</string> <string>显示状态栏</string>
</property> </property>
</action> </action>
<action name="actionEnglish"> <action name="actionEnglish">
@ -19549,7 +19546,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>English</string> <string>英语</string>
</property> </property>
</action> </action>
<action name="actionChinese"> <action name="actionChinese">
@ -19560,7 +19557,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Chinese</string> <string>中文</string>
</property> </property>
</action> </action>
</widget> </widget>

View File

@ -7,6 +7,8 @@
ModbusRTU::ModbusRTU(QObject *parent) : QThread(parent) ModbusRTU::ModbusRTU(QObject *parent) : QThread(parent)
{ {
init(); init();
// start();
} }
ModbusRTU::~ModbusRTU() ModbusRTU::~ModbusRTU()
@ -23,6 +25,8 @@ void ModbusRTU::init()
void ModbusRTU::run() void ModbusRTU::run()
{ {
qDebug() << "进入线程:" << QThread::currentThread(); qDebug() << "进入线程:" << QThread::currentThread();
// QMetaObject::invokeMethod(QThread::currentThread(), "read_regs_slot", Qt::QueuedConnection);
// QMetaObject::invokeMethod(QThread::currentThread(), "write_regs_slot", Qt::QueuedConnection);
while(true) while(true)
{ {
// qDebug() << "11111111111111111111111111111111"; // qDebug() << "11111111111111111111111111111111";
@ -166,6 +170,7 @@ void ModbusRTU::run()
void ModbusRTU::write_regs_slot(int addr,const uint16_t data) void ModbusRTU::write_regs_slot(int addr,const uint16_t data)
{ {
qDebug() << "write:进入线程:" << QThread::currentThread();
int rc = write_single_register(addr, data); int rc = write_single_register(addr, data);
if(MODBUS_ERR == rc) { if(MODBUS_ERR == rc) {
qDebug() << "######modbus no message"; 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) 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); int rc = read_holding_register(addr, nb, data);
if(MODBUS_ERR == rc) { if(MODBUS_ERR == rc) {
// qDebug() << "modbus no message"; // qDebug() << "modbus no message";

View File

@ -13,6 +13,8 @@ class ModbusRTU : public QThread
public: public:
ModbusRTU(QObject *parent = nullptr); ModbusRTU(QObject *parent = nullptr);
~ModbusRTU(); ~ModbusRTU();
public slots:
void write_regs_slot(int addr, const uint16_t data); void write_regs_slot(int addr, const uint16_t data);
void read_regs_slot(int addr, int nb, uint16_t *data, int row); void read_regs_slot(int addr, int nb, uint16_t *data, int row);
@ -25,7 +27,7 @@ public:
int dataBit; int dataBit;
int stopBit; int stopBit;
protected: public:
void run() override; void run() override;
private: private:
@ -70,6 +72,7 @@ signals:
void sig_showModbusData_base_info_list_47_49_51_53_55(QList<int> byteArray,int dataType); void sig_showModbusData_base_info_list_47_49_51_53_55(QList<int> byteArray,int dataType);
void sig_showReadHoldingRegs(QByteArray byteArray,int dataType, int row, int nb); void sig_showReadHoldingRegs(QByteArray byteArray,int dataType, int row, int nb);
public slots: public slots:
}; };