[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 "modbusrtu.h"
#include <windef.h>
#include <QThread>
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 {

View File

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

View File

@ -26,11 +26,15 @@
#include <QTreeView>
#include "modbusrtu.h"
#include <QWidget>
#include <QCloseEvent>
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);
}

View File

@ -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<int> 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();

View File

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

View File

@ -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";

View File

@ -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<int> byteArray,int dataType);
void sig_showReadHoldingRegs(QByteArray byteArray,int dataType, int row, int nb);
public slots:
};