改进串口调试助手和网络调试助手代码

master
feiyangqingyun 2021-08-21 11:19:00 +08:00
parent 1fea87f8e4
commit 978f0a588d
36 changed files with 554 additions and 280 deletions

View File

@ -1,5 +1,7 @@
HEADERS += \
$$PWD/appconfig.h
$$PWD/appconfig.h \
$$PWD/appdata.h
SOURCES += \
$$PWD/appconfig.cpp
$$PWD/appconfig.cpp \
$$PWD/appdata.cpp

View File

@ -96,65 +96,3 @@ void AppConfig::writeConfig()
set.setValue("AutoConnect", AppConfig::AutoConnect);
set.endGroup();
}
QStringList AppConfig::Intervals = QStringList();
QStringList AppConfig::Datas = QStringList();
QStringList AppConfig::Keys = QStringList();
QStringList AppConfig::Values = QStringList();
void AppConfig::readSendData()
{
//读取发送数据列表
AppConfig::Datas.clear();
QString fileName = QString("%1/%2").arg(QUIHelper::appPath()).arg(AppConfig::SendFileName);
QFile file(fileName);
if (file.size() > 0 && file.open(QFile::ReadOnly | QIODevice::Text)) {
while (!file.atEnd()) {
QString line = file.readLine();
line = line.trimmed();
line = line.replace("\r", "");
line = line.replace("\n", "");
if (!line.isEmpty()) {
AppConfig::Datas.append(line);
}
}
file.close();
}
if (AppConfig::Datas.count() == 0) {
AppConfig::Datas << "16 FF 01 01 E0 E1" << "16 FF 01 01 E1 E2";
}
}
void AppConfig::readDeviceData()
{
//读取转发数据列表
AppConfig::Keys.clear();
AppConfig::Values.clear();
QString fileName = QString("%1/%2").arg(QUIHelper::appPath()).arg(AppConfig::DeviceFileName);
QFile file(fileName);
if (file.size() > 0 && file.open(QFile::ReadOnly | QIODevice::Text)) {
while (!file.atEnd()) {
QString line = file.readLine();
line = line.trimmed();
line = line.replace("\r", "");
line = line.replace("\n", "");
if (!line.isEmpty()) {
QStringList list = line.split(";");
QString key = list.at(0);
QString value;
for (int i = 1; i < list.count(); i++) {
value += QString("%1;").arg(list.at(i));
}
//去掉末尾分号
value = value.mid(0, value.length() - 1);
AppConfig::Keys.append(key);
AppConfig::Values.append(value);
}
}
file.close();
}
}

View File

@ -33,16 +33,9 @@ public:
static int SleepTime; //延时时间
static bool AutoConnect; //自动重连
//读写配置参数及其他操作
//读写配置参数
static void readConfig(); //读取配置参数
static void writeConfig(); //写入配置参数
static QStringList Intervals;
static QStringList Datas;
static QStringList Keys;
static QStringList Values;
static void readSendData();
static void readDeviceData();
};
#endif // APPCONFIG_H

92
comtool/api/appdata.cpp Normal file
View File

@ -0,0 +1,92 @@
#include "appdata.h"
#include "quihelper.h"
QStringList AppData::Intervals = QStringList();
QStringList AppData::Datas = QStringList();
QStringList AppData::Keys = QStringList();
QStringList AppData::Values = QStringList();
QString AppData::SendFileName = "send.txt";
void AppData::readSendData()
{
//读取发送数据列表
AppData::Datas.clear();
QString fileName = QString("%1/%2").arg(QUIHelper::appPath()).arg(AppData::SendFileName);
QFile file(fileName);
if (file.size() > 0 && file.open(QFile::ReadOnly | QIODevice::Text)) {
while (!file.atEnd()) {
QString line = file.readLine();
line = line.trimmed();
line = line.replace("\r", "");
line = line.replace("\n", "");
if (!line.isEmpty()) {
AppData::Datas.append(line);
}
}
file.close();
}
//没有的时候主动添加点免得太空
if (AppData::Datas.count() == 0) {
AppData::Datas << "16 FF 01 01 E0 E1" << "16 FF 01 01 E1 E2";
}
}
QString AppData::DeviceFileName = "device.txt";
void AppData::readDeviceData()
{
//读取转发数据列表
AppData::Keys.clear();
AppData::Values.clear();
QString fileName = QString("%1/%2").arg(QUIHelper::appPath()).arg(AppData::DeviceFileName);
QFile file(fileName);
if (file.size() > 0 && file.open(QFile::ReadOnly | QIODevice::Text)) {
while (!file.atEnd()) {
QString line = file.readLine();
line = line.trimmed();
line = line.replace("\r", "");
line = line.replace("\n", "");
if (!line.isEmpty()) {
QStringList list = line.split(";");
QString key = list.at(0);
QString value;
for (int i = 1; i < list.count(); i++) {
value += QString("%1;").arg(list.at(i));
}
//去掉末尾分号
value = value.mid(0, value.length() - 1);
AppData::Keys.append(key);
AppData::Values.append(value);
}
}
file.close();
}
}
void AppData::saveData(const QString &data)
{
if (data.length() <= 0) {
return;
}
QString fileName = QString("%1/%2.txt").arg(QUIHelper::appPath()).arg(STRDATETIME);
QFile file(fileName);
if (file.open(QFile::WriteOnly | QFile::Text)) {
file.write(data.toUtf8());
file.close();
}
}
void AppData::loadIP(QComboBox *cbox)
{
//获取本机所有IP
QStringList ips = QUIHelper::getLocalIPs();
cbox->clear();
cbox->addItems(ips);
if (!ips.contains("127.0.0.1")) {
cbox->addItem("127.0.0.1");
}
}

30
comtool/api/appdata.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef APPDATA_H
#define APPDATA_H
#include "head.h"
class AppData
{
public:
//全局变量
static QStringList Intervals;
static QStringList Datas;
static QStringList Keys;
static QStringList Values;
//读取发送数据列表
static QString SendFileName;
static void readSendData();
//读取转发数据列表
static QString DeviceFileName;
static void readDeviceData();
//保存数据到文件
static void saveData(const QString &data);
//添加网卡IP地址到下拉框
static void loadIP(QComboBox *cbox);
};
#endif // APPDATA_H

View File

@ -24,8 +24,8 @@ void frmComTool::initForm()
sendCount = 0;
isShow = true;
ui->cboxSendInterval->addItems(AppConfig::Intervals);
ui->cboxData->addItems(AppConfig::Datas);
ui->cboxSendInterval->addItems(AppData::Intervals);
ui->cboxData->addItems(AppData::Datas);
//读取数据
timerRead = new QTimer(this);
@ -49,7 +49,11 @@ void frmComTool::initForm()
socket = new QTcpSocket(this);
socket->abort();
connect(socket, SIGNAL(readyRead()), this, SLOT(readDataNet()));
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(readErrorNet()));
#else
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(readErrorNet()));
#endif
timerConnect = new QTimer(this);
connect(timerConnect, SIGNAL(timeout()), this, SLOT(connectNet()));
@ -317,10 +321,10 @@ void frmComTool::readData()
//启用调试则模拟调试数据
if (ui->ckDebug->isChecked()) {
int count = AppConfig::Keys.count();
int count = AppData::Keys.count();
for (int i = 0; i < count; i++) {
if (buffer.startsWith(AppConfig::Keys.at(i))) {
sendData(AppConfig::Values.at(i));
if (buffer.startsWith(AppData::Keys.at(i))) {
sendData(AppData::Values.at(i));
break;
}
}
@ -427,7 +431,7 @@ void frmComTool::on_btnOpen_clicked()
timerRead->stop();
com->close();
com->deleteLater();
changeEnable(false);
ui->btnOpen->setText("打开串口");
on_btnClear_clicked();
@ -482,7 +486,7 @@ void frmComTool::on_btnData_clicked()
file.close();
ui->txtMain->clear();
ui->btnData->setText("管理数据");
AppConfig::readSendData();
AppData::readSendData();
}
}

View File

@ -12,3 +12,4 @@
#pragma execution_character_set("utf-8")
#include "appconfig.h"
#include "appdata.h"

View File

@ -17,11 +17,12 @@ int main(int argc, char *argv[])
QUIHelper::setTranslator(":/widgets.qm");
QUIHelper::initRand();
AppConfig::Intervals << "1" << "10" << "20" << "50" << "100" << "200" << "300" << "500" << "1000" << "1500" << "2000" << "3000" << "5000" << "10000";
AppConfig::ConfigFile = QString("%1/%2.ini").arg(QUIHelper::appPath()).arg(QUIHelper::appName());
AppConfig::readConfig();
AppConfig::readSendData();
AppConfig::readDeviceData();
AppData::Intervals << "1" << "10" << "20" << "50" << "100" << "200" << "300" << "500" << "1000" << "1500" << "2000" << "3000" << "5000" << "10000";
AppData::readSendData();
AppData::readDeviceData();
frmComTool w;
w.setWindowTitle("串口调试助手 V2021 (QQ: 517216493 WX: feiyangqingyun)");

View File

@ -1,5 +1,5 @@
### 特别说明
1. 编译完成以后记得将dll文件复制到可执行文件同一目录。
### 特别说明
1. 编译完成以后记得将动态库文件复制到可执行文件同一目录。
2. 动态库地址:[https://pan.baidu.com/s/13LDRu6mXC6gaADtrGprNVA](https://pan.baidu.com/s/13LDRu6mXC6gaADtrGprNVA) 提取码: ujm7
3. 收费增强版:[https://qtchina.blog.csdn.net/article/details/103946731](https://qtchina.blog.csdn.net/article/details/103946731)

View File

@ -1,8 +1,10 @@
HEADERS += $$PWD/appconfig.h
HEADERS += $$PWD/appconfig.h \
$$PWD/appdata.h
HEADERS += $$PWD/tcpclient.h
HEADERS += $$PWD/tcpserver.h
SOURCES += $$PWD/appconfig.cpp
SOURCES += $$PWD/appconfig.cpp \
$$PWD/appdata.cpp
SOURCES += $$PWD/tcpclient.cpp
SOURCES += $$PWD/tcpserver.cpp

View File

@ -2,9 +2,6 @@
#include "quihelper.h"
QString AppConfig::ConfigFile = "config.ini";
QString AppConfig::SendFileName = "send.txt";
QString AppConfig::DeviceFileName = "device.txt";
int AppConfig::CurrentIndex = 0;
bool AppConfig::HexSendTcpClient = false;
@ -13,6 +10,8 @@ bool AppConfig::AsciiTcpClient = false;
bool AppConfig::DebugTcpClient = false;
bool AppConfig::AutoSendTcpClient = false;
int AppConfig::IntervalTcpClient = 1000;
QString AppConfig::TcpBindIP = "127.0.0.1";
int AppConfig::TcpBindPort = 6001;
QString AppConfig::TcpServerIP = "127.0.0.1";
int AppConfig::TcpServerPort = 6000;
@ -32,6 +31,8 @@ bool AppConfig::AsciiUdpClient = false;
bool AppConfig::DebugUdpClient = false;
bool AppConfig::AutoSendUdpClient = false;
int AppConfig::IntervalUdpClient = 1000;
QString AppConfig::UdpBindIP = "127.0.0.1";
int AppConfig::UdpBindPort = 6001;
QString AppConfig::UdpServerIP = "127.0.0.1";
int AppConfig::UdpServerPort = 6000;
@ -84,6 +85,8 @@ void AppConfig::readConfig()
AppConfig::DebugTcpClient = set.value("DebugTcpClient", AppConfig::DebugTcpClient).toBool();
AppConfig::AutoSendTcpClient = set.value("AutoSendTcpClient", AppConfig::AutoSendTcpClient).toBool();
AppConfig::IntervalTcpClient = set.value("IntervalTcpClient", AppConfig::IntervalTcpClient).toInt();
AppConfig::TcpBindIP = set.value("TcpBindIP", AppConfig::TcpBindIP).toString();
AppConfig::TcpBindPort = set.value("TcpBindPort", AppConfig::TcpBindPort).toInt();
AppConfig::TcpServerIP = set.value("TcpServerIP", AppConfig::TcpServerIP).toString();
AppConfig::TcpServerPort = set.value("TcpServerPort", AppConfig::TcpServerPort).toInt();
set.endGroup();
@ -107,6 +110,8 @@ void AppConfig::readConfig()
AppConfig::DebugUdpClient = set.value("DebugUdpClient", AppConfig::DebugUdpClient).toBool();
AppConfig::AutoSendUdpClient = set.value("AutoSendUdpClient", AppConfig::AutoSendUdpClient).toBool();
AppConfig::IntervalUdpClient = set.value("IntervalUdpClient", AppConfig::IntervalUdpClient).toInt();
AppConfig::UdpBindIP = set.value("UdpBindIP", AppConfig::UdpBindIP).toString();
AppConfig::UdpBindPort = set.value("UdpBindPort", AppConfig::UdpBindPort).toInt();
AppConfig::UdpServerIP = set.value("UdpServerIP", AppConfig::UdpServerIP).toString();
AppConfig::UdpServerPort = set.value("UdpServerPort", AppConfig::UdpServerPort).toInt();
set.endGroup();
@ -161,6 +166,8 @@ void AppConfig::writeConfig()
set.setValue("DebugTcpClient", AppConfig::DebugTcpClient);
set.setValue("AutoSendTcpClient", AppConfig::AutoSendTcpClient);
set.setValue("IntervalTcpClient", AppConfig::IntervalTcpClient);
set.setValue("TcpBindIP", AppConfig::TcpBindIP);
set.setValue("TcpBindPort", AppConfig::TcpBindPort);
set.setValue("TcpServerIP", AppConfig::TcpServerIP);
set.setValue("TcpServerPort", AppConfig::TcpServerPort);
set.endGroup();
@ -182,6 +189,8 @@ void AppConfig::writeConfig()
set.setValue("DebugUdpClient", AppConfig::DebugUdpClient);
set.setValue("AutoSendUdpClient", AppConfig::AutoSendUdpClient);
set.setValue("IntervalUdpClient", AppConfig::IntervalUdpClient);
set.setValue("UdpBindIP", AppConfig::UdpBindIP);
set.setValue("UdpBindPort", AppConfig::UdpBindPort);
set.setValue("UdpServerIP", AppConfig::UdpServerIP);
set.setValue("UdpServerPort", AppConfig::UdpServerPort);
set.endGroup();
@ -218,79 +227,3 @@ void AppConfig::writeConfig()
set.setValue("SelectAllWebServer", AppConfig::SelectAllWebServer);
set.endGroup();
}
QStringList AppConfig::Intervals = QStringList();
QStringList AppConfig::Datas = QStringList();
QStringList AppConfig::Keys = QStringList();
QStringList AppConfig::Values = QStringList();
void AppConfig::readSendData()
{
//读取发送数据列表
AppConfig::Datas.clear();
QString fileName = QString("%1/%2").arg(QUIHelper::appPath()).arg(AppConfig::SendFileName);
QFile file(fileName);
if (file.size() > 0 && file.open(QFile::ReadOnly | QIODevice::Text)) {
while (!file.atEnd()) {
QString line = file.readLine();
line = line.trimmed();
line = line.replace("\r", "");
line = line.replace("\n", "");
if (!line.isEmpty()) {
AppConfig::Datas.append(line);
}
}
file.close();
}
if (AppConfig::Datas.count() == 0) {
AppConfig::Datas << "16 FF 01 01 E0 E1" << "16 FF 01 01 E1 E2";
}
}
void AppConfig::readDeviceData()
{
//读取转发数据列表
AppConfig::Keys.clear();
AppConfig::Values.clear();
QString fileName = QString("%1/%2").arg(QUIHelper::appPath()).arg(AppConfig::DeviceFileName);
QFile file(fileName);
if (file.size() > 0 && file.open(QFile::ReadOnly | QIODevice::Text)) {
while (!file.atEnd()) {
QString line = file.readLine();
line = line.trimmed();
line = line.replace("\r", "");
line = line.replace("\n", "");
if (!line.isEmpty()) {
QStringList list = line.split(";");
QString key = list.at(0);
QString value;
for (int i = 1; i < list.count(); i++) {
value += QString("%1;").arg(list.at(i));
}
//去掉末尾分号
value = value.mid(0, value.length() - 1);
AppConfig::Keys.append(key);
AppConfig::Values.append(value);
}
}
file.close();
}
}
void AppConfig::saveData(const QString &data)
{
if (data.length() <= 0) {
return;
}
QString fileName = QString("%1/%2.txt").arg(QUIHelper::appPath()).arg(STRDATETIME);
QFile file(fileName);
if (file.open(QFile::WriteOnly | QFile::Text)) {
file.write(data.toUtf8());
file.close();
}
}

View File

@ -7,9 +7,6 @@ class AppConfig
{
public:
static QString ConfigFile; //配置文件路径
static QString SendFileName; //发送配置文件名
static QString DeviceFileName; //模拟设备数据文件名
static int CurrentIndex; //当前索引
//TCP客户端配置参数
@ -19,7 +16,9 @@ public:
static bool DebugTcpClient; //启用数据调试
static bool AutoSendTcpClient; //自动发送数据
static int IntervalTcpClient; //发送数据间隔
static QString TcpServerIP; //服务器IP
static QString TcpBindIP; //绑定地址
static int TcpBindPort; //绑定端口
static QString TcpServerIP; //服务器地址
static int TcpServerPort; //服务器端口
//TCP服务器配置参数
@ -40,7 +39,9 @@ public:
static bool DebugUdpClient; //启用数据调试
static bool AutoSendUdpClient; //自动发送数据
static int IntervalUdpClient; //发送数据间隔
static QString UdpServerIP; //服务器IP
static QString UdpBindIP; //绑定地址
static int UdpBindPort; //绑定端口
static QString UdpServerIP; //服务器地址
static int UdpServerPort; //服务器端口
//UDP服务器配置参数
@ -61,7 +62,7 @@ public:
static bool DebugWebClient; //启用数据调试
static bool AutoSendWebClient; //自动发送数据
static int IntervalWebClient; //发送数据间隔
static QString WebServerIP; //服务器IP
static QString WebServerIP; //服务器地址
static int WebServerPort; //服务器端口
//WEB服务器配置参数
@ -75,17 +76,9 @@ public:
static int WebListenPort; //监听端口
static bool SelectAllWebServer; //选中所有
//读写配置参数及其他操作
//读写配置参数
static void readConfig(); //读取配置参数
static void writeConfig(); //写入配置参数
static QStringList Intervals;
static QStringList Datas;
static QStringList Keys;
static QStringList Values;
static void readSendData();
static void readDeviceData();
static void saveData(const QString &data);
};
#endif // APPCONFIG_H

92
nettool/api/appdata.cpp Normal file
View File

@ -0,0 +1,92 @@
#include "appdata.h"
#include "quihelper.h"
QStringList AppData::Intervals = QStringList();
QStringList AppData::Datas = QStringList();
QStringList AppData::Keys = QStringList();
QStringList AppData::Values = QStringList();
QString AppData::SendFileName = "send.txt";
void AppData::readSendData()
{
//读取发送数据列表
AppData::Datas.clear();
QString fileName = QString("%1/%2").arg(QUIHelper::appPath()).arg(AppData::SendFileName);
QFile file(fileName);
if (file.size() > 0 && file.open(QFile::ReadOnly | QIODevice::Text)) {
while (!file.atEnd()) {
QString line = file.readLine();
line = line.trimmed();
line = line.replace("\r", "");
line = line.replace("\n", "");
if (!line.isEmpty()) {
AppData::Datas.append(line);
}
}
file.close();
}
//没有的时候主动添加点免得太空
if (AppData::Datas.count() == 0) {
AppData::Datas << "16 FF 01 01 E0 E1" << "16 FF 01 01 E1 E2";
}
}
QString AppData::DeviceFileName = "device.txt";
void AppData::readDeviceData()
{
//读取转发数据列表
AppData::Keys.clear();
AppData::Values.clear();
QString fileName = QString("%1/%2").arg(QUIHelper::appPath()).arg(AppData::DeviceFileName);
QFile file(fileName);
if (file.size() > 0 && file.open(QFile::ReadOnly | QIODevice::Text)) {
while (!file.atEnd()) {
QString line = file.readLine();
line = line.trimmed();
line = line.replace("\r", "");
line = line.replace("\n", "");
if (!line.isEmpty()) {
QStringList list = line.split(";");
QString key = list.at(0);
QString value;
for (int i = 1; i < list.count(); i++) {
value += QString("%1;").arg(list.at(i));
}
//去掉末尾分号
value = value.mid(0, value.length() - 1);
AppData::Keys.append(key);
AppData::Values.append(value);
}
}
file.close();
}
}
void AppData::saveData(const QString &data)
{
if (data.length() <= 0) {
return;
}
QString fileName = QString("%1/%2.txt").arg(QUIHelper::appPath()).arg(STRDATETIME);
QFile file(fileName);
if (file.open(QFile::WriteOnly | QFile::Text)) {
file.write(data.toUtf8());
file.close();
}
}
void AppData::loadIP(QComboBox *cbox)
{
//获取本机所有IP
QStringList ips = QUIHelper::getLocalIPs();
cbox->clear();
cbox->addItems(ips);
if (!ips.contains("127.0.0.1")) {
cbox->addItem("127.0.0.1");
}
}

30
nettool/api/appdata.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef APPDATA_H
#define APPDATA_H
#include "head.h"
class AppData
{
public:
//全局变量
static QStringList Intervals;
static QStringList Datas;
static QStringList Keys;
static QStringList Values;
//读取发送数据列表
static QString SendFileName;
static void readSendData();
//读取转发数据列表
static QString DeviceFileName;
static void readDeviceData();
//保存数据到文件
static void saveData(const QString &data);
//添加网卡IP地址到下拉框
static void loadIP(QComboBox *cbox);
};
#endif // APPDATA_H

View File

@ -8,7 +8,11 @@ TcpClient::TcpClient(QTcpSocket *socket, QObject *parent) : QObject(parent)
ip = ip.replace("::ffff:", "");
port = socket->peerPort();
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)),this, SLOT(disconnected()));
#else
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(disconnected()));
#endif
connect(socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
connect(socket, SIGNAL(readyRead()), this, SLOT(readData()));
}
@ -50,10 +54,10 @@ void TcpClient::readData()
//自动回复数据,可以回复的数据是以;隔开,每行可以带多个;所以这里不需要继续判断
if (AppConfig::DebugTcpServer) {
int count = AppConfig::Keys.count();
int count = AppData::Keys.count();
for (int i = 0; i < count; i++) {
if (AppConfig::Keys.at(i) == buffer) {
sendData(AppConfig::Values.at(i));
if (AppData::Keys.at(i) == buffer) {
sendData(AppData::Values.at(i));
break;
}
}

View File

@ -43,10 +43,10 @@ void WebClient::textFrameReceived(const QString &data, bool isLastFrame)
//自动回复数据,可以回复的数据是以;隔开,每行可以带多个;所以这里不需要继续判断
if (AppConfig::DebugWebServer) {
int count = AppConfig::Keys.count();
int count = AppData::Keys.count();
for (int i = 0; i < count; i++) {
if (AppConfig::Keys.at(i) == buffer) {
sendData(AppConfig::Values.at(i));
if (AppData::Keys.at(i) == buffer) {
sendData(AppData::Values.at(i));
break;
}
}

View File

@ -17,18 +17,28 @@ frmTcpClient::~frmTcpClient()
void frmTcpClient::initForm()
{
isOk = false;
//实例化对象并绑定信号槽
socket = new QTcpSocket(this);
connect(socket, SIGNAL(connected()), this, SLOT(connected()));
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)),this, SLOT(disconnected()));
#else
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(disconnected()));
#endif
connect(socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
connect(socket, SIGNAL(readyRead()), this, SLOT(readData()));
//定时器发送数据
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(on_btnSend_clicked()));
ui->cboxInterval->addItems(AppConfig::Intervals);
ui->cboxData->addItems(AppConfig::Datas);
//填充数据到下拉框
ui->cboxInterval->addItems(AppData::Intervals);
ui->cboxData->addItems(AppData::Datas);
AppData::loadIP(ui->cboxBindIP);
//打印下外网地址
#ifndef emsdk
QString ip = QUIHelper::getNetIP(QUIHelper::getHtml("http://whois.pconline.com.cn/"));
append(1, QString("外网IP -> %1").arg(ip));
@ -55,13 +65,19 @@ void frmTcpClient::initConfig()
ui->cboxInterval->setCurrentIndex(ui->cboxInterval->findText(QString::number(AppConfig::IntervalTcpClient)));
connect(ui->cboxInterval, SIGNAL(currentIndexChanged(int)), this, SLOT(saveConfig()));
ui->cboxBindIP->setCurrentIndex(ui->cboxBindIP->findText(AppConfig::TcpBindIP));
connect(ui->cboxBindIP, SIGNAL(currentIndexChanged(int)), this, SLOT(saveConfig()));
ui->txtBindPort->setText(QString::number(AppConfig::TcpBindPort));
connect(ui->txtBindPort, SIGNAL(textChanged(QString)), this, SLOT(saveConfig()));
ui->txtServerIP->setText(AppConfig::TcpServerIP);
connect(ui->txtServerIP, SIGNAL(textChanged(QString)), this, SLOT(saveConfig()));
ui->txtServerPort->setText(QString::number(AppConfig::TcpServerPort));
connect(ui->txtServerPort, SIGNAL(textChanged(QString)), this, SLOT(saveConfig()));
this->changeTimer();
this->initTimer();
}
void frmTcpClient::saveConfig()
@ -72,16 +88,21 @@ void frmTcpClient::saveConfig()
AppConfig::DebugTcpClient = ui->ckDebug->isChecked();
AppConfig::AutoSendTcpClient = ui->ckAutoSend->isChecked();
AppConfig::IntervalTcpClient = ui->cboxInterval->currentText().toInt();
AppConfig::TcpBindIP = ui->cboxBindIP->currentText();
AppConfig::TcpBindPort = ui->txtBindPort->text().trimmed().toInt();
AppConfig::TcpServerIP = ui->txtServerIP->text().trimmed();
AppConfig::TcpServerPort = ui->txtServerPort->text().trimmed().toInt();
AppConfig::writeConfig();
this->changeTimer();
this->initTimer();
}
void frmTcpClient::changeTimer()
void frmTcpClient::initTimer()
{
timer->setInterval(AppConfig::IntervalTcpClient);
if (timer->interval() != AppConfig::IntervalTcpClient) {
timer->setInterval(AppConfig::IntervalTcpClient);
}
if (AppConfig::AutoSendTcpClient) {
if (!timer->isActive()) {
timer->start();
@ -168,10 +189,10 @@ void frmTcpClient::readData()
//自动回复数据,可以回复的数据是以;隔开,每行可以带多个;所以这里不需要继续判断
if (AppConfig::DebugTcpClient) {
int count = AppConfig::Keys.count();
int count = AppData::Keys.count();
for (int i = 0; i < count; i++) {
if (AppConfig::Keys.at(i) == buffer) {
sendData(AppConfig::Values.at(i));
if (AppData::Keys.at(i) == buffer) {
sendData(AppData::Values.at(i));
break;
}
}
@ -196,7 +217,13 @@ void frmTcpClient::sendData(const QString &data)
void frmTcpClient::on_btnConnect_clicked()
{
if (ui->btnConnect->text() == "连接") {
//断开所有连接和操作
socket->abort();
//绑定网卡和端口
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
socket->bind(QHostAddress(AppConfig::TcpBindIP), AppConfig::TcpBindPort);
#endif
//连接服务器
socket->connectToHost(AppConfig::TcpServerIP, AppConfig::TcpServerPort);
} else {
socket->abort();
@ -206,7 +233,7 @@ void frmTcpClient::on_btnConnect_clicked()
void frmTcpClient::on_btnSave_clicked()
{
QString data = ui->txtMain->toPlainText();
AppConfig::saveData(data);
AppData::saveData(data);
on_btnClear_clicked();
}

View File

@ -27,7 +27,7 @@ private slots:
void initForm();
void initConfig();
void saveConfig();
void changeTimer();
void initTimer();
void append(int type, const QString &data, bool clear = false);
private slots:

View File

@ -53,7 +53,7 @@
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>6</number>
</property>
@ -111,6 +111,26 @@
<item>
<widget class="QComboBox" name="cboxInterval"/>
</item>
<item>
<widget class="QLabel" name="labBindIP">
<property name="text">
<string>绑定地址</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cboxBindIP"/>
</item>
<item>
<widget class="QLabel" name="labBindPort">
<property name="text">
<string>绑定端口</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtBindPort"/>
</item>
<item>
<widget class="QLabel" name="labServerIP">
<property name="text">
@ -220,6 +240,25 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>txtMain</tabstop>
<tabstop>cboxData</tabstop>
<tabstop>btnSend</tabstop>
<tabstop>ckHexReceive</tabstop>
<tabstop>ckHexSend</tabstop>
<tabstop>ckAscii</tabstop>
<tabstop>ckShow</tabstop>
<tabstop>ckDebug</tabstop>
<tabstop>ckAutoSend</tabstop>
<tabstop>cboxInterval</tabstop>
<tabstop>cboxBindIP</tabstop>
<tabstop>txtBindPort</tabstop>
<tabstop>txtServerIP</tabstop>
<tabstop>txtServerPort</tabstop>
<tabstop>btnConnect</tabstop>
<tabstop>btnSave</tabstop>
<tabstop>btnClear</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -17,24 +17,22 @@ frmTcpServer::~frmTcpServer()
void frmTcpServer::initForm()
{
isOk = false;
//实例化对象并绑定信号槽
server = new TcpServer(this);
connect(server, SIGNAL(clientConnected(QString, int)), this, SLOT(clientConnected(QString, int)));
connect(server, SIGNAL(clientDisconnected(QString, int)), this, SLOT(clientDisconnected(QString, int)));
connect(server, SIGNAL(sendData(QString, int, QString)), this, SLOT(sendData(QString, int, QString)));
connect(server, SIGNAL(receiveData(QString, int, QString)), this, SLOT(receiveData(QString, int, QString)));
//定时器发送数据
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(on_btnSend_clicked()));
ui->cboxInterval->addItems(AppConfig::Intervals);
ui->cboxData->addItems(AppConfig::Datas);
//获取本机所有IP
QStringList ips = QUIHelper::getLocalIPs();
ui->cboxListenIP->addItems(ips);
if (!ips.contains("127.0.0.1")) {
ui->cboxListenIP->addItem("127.0.0.1");
}
//填充数据到下拉框
ui->cboxInterval->addItems(AppData::Intervals);
ui->cboxData->addItems(AppData::Datas);
AppData::loadIP(ui->cboxListenIP);
}
void frmTcpServer::initConfig()
@ -66,7 +64,7 @@ void frmTcpServer::initConfig()
ui->ckSelectAll->setChecked(AppConfig::SelectAllTcpServer);
connect(ui->ckSelectAll, SIGNAL(stateChanged(int)), this, SLOT(saveConfig()));
this->changeTimer();
this->initTimer();
}
void frmTcpServer::saveConfig()
@ -82,12 +80,15 @@ void frmTcpServer::saveConfig()
AppConfig::SelectAllTcpServer = ui->ckSelectAll->isChecked();
AppConfig::writeConfig();
this->changeTimer();
this->initTimer();
}
void frmTcpServer::changeTimer()
void frmTcpServer::initTimer()
{
timer->setInterval(AppConfig::IntervalTcpServer);
if (timer->interval() != AppConfig::IntervalTcpServer) {
timer->setInterval(AppConfig::IntervalTcpServer);
}
if (AppConfig::AutoSendTcpServer) {
if (!timer->isActive()) {
timer->start();
@ -192,7 +193,7 @@ void frmTcpServer::on_btnListen_clicked()
void frmTcpServer::on_btnSave_clicked()
{
QString data = ui->txtMain->toPlainText();
AppConfig::saveData(data);
AppData::saveData(data);
on_btnClear_clicked();
}

View File

@ -27,7 +27,7 @@ private slots:
void initForm();
void initConfig();
void saveConfig();
void changeTimer();
void initTimer();
void append(int type, const QString &data, bool clear = false);
private slots:

View File

@ -248,6 +248,8 @@
</widget>
<tabstops>
<tabstop>txtMain</tabstop>
<tabstop>cboxData</tabstop>
<tabstop>btnSend</tabstop>
<tabstop>ckHexReceive</tabstop>
<tabstop>ckHexSend</tabstop>
<tabstop>ckAscii</tabstop>
@ -263,8 +265,6 @@
<tabstop>btnClose</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>ckSelectAll</tabstop>
<tabstop>cboxData</tabstop>
<tabstop>btnSend</tabstop>
</tabstops>
<resources/>
<connections/>

View File

@ -16,14 +16,18 @@ frmUdpClient::~frmUdpClient()
void frmUdpClient::initForm()
{
//实例化对象并绑定信号槽
socket = new QUdpSocket(this);
connect(socket, SIGNAL(readyRead()), this, SLOT(readData()));
//定时器发送数据
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(on_btnSend_clicked()));
ui->cboxInterval->addItems(AppConfig::Intervals);
ui->cboxData->addItems(AppConfig::Datas);
//填充数据到下拉框
ui->cboxInterval->addItems(AppData::Intervals);
ui->cboxData->addItems(AppData::Datas);
AppData::loadIP(ui->cboxBindIP);
}
void frmUdpClient::initConfig()
@ -46,13 +50,19 @@ void frmUdpClient::initConfig()
ui->cboxInterval->setCurrentIndex(ui->cboxInterval->findText(QString::number(AppConfig::IntervalUdpClient)));
connect(ui->cboxInterval, SIGNAL(currentIndexChanged(int)), this, SLOT(saveConfig()));
ui->cboxBindIP->setCurrentIndex(ui->cboxBindIP->findText(AppConfig::UdpBindIP));
connect(ui->cboxBindIP, SIGNAL(currentIndexChanged(int)), this, SLOT(saveConfig()));
ui->txtBindPort->setText(QString::number(AppConfig::UdpBindPort));
connect(ui->txtBindPort, SIGNAL(textChanged(QString)), this, SLOT(saveConfig()));
ui->txtServerIP->setText(AppConfig::UdpServerIP);
connect(ui->txtServerIP, SIGNAL(textChanged(QString)), this, SLOT(saveConfig()));
ui->txtServerPort->setText(QString::number(AppConfig::UdpServerPort));
connect(ui->txtServerPort, SIGNAL(textChanged(QString)), this, SLOT(saveConfig()));
this->changeTimer();
this->initTimer();
}
void frmUdpClient::saveConfig()
@ -63,16 +73,21 @@ void frmUdpClient::saveConfig()
AppConfig::DebugUdpClient = ui->ckDebug->isChecked();
AppConfig::AutoSendUdpClient = ui->ckAutoSend->isChecked();
AppConfig::IntervalUdpClient = ui->cboxInterval->currentText().toInt();
AppConfig::UdpBindIP = ui->cboxBindIP->currentText();
AppConfig::UdpBindPort = ui->txtBindPort->text().trimmed().toInt();
AppConfig::UdpServerIP = ui->txtServerIP->text().trimmed();
AppConfig::UdpServerPort = ui->txtServerPort->text().trimmed().toInt();
AppConfig::writeConfig();
this->changeTimer();
this->initTimer();
}
void frmUdpClient::changeTimer()
void frmUdpClient::initTimer()
{
timer->setInterval(AppConfig::IntervalUdpClient);
if (timer->interval() != AppConfig::IntervalUdpClient) {
timer->setInterval(AppConfig::IntervalUdpClient);
}
if (AppConfig::AutoSendUdpClient) {
if (!timer->isActive()) {
timer->start();
@ -153,10 +168,10 @@ void frmUdpClient::readData()
append(1, str);
if (AppConfig::DebugUdpClient) {
int count = AppConfig::Keys.count();
int count = AppData::Keys.count();
for (int i = 0; i < count; i++) {
if (AppConfig::Keys.at(i) == buffer) {
sendData(ip, port, AppConfig::Values.at(i));
if (AppData::Keys.at(i) == buffer) {
sendData(ip, port, AppData::Values.at(i));
break;
}
}
@ -175,6 +190,13 @@ void frmUdpClient::sendData(const QString &ip, int port, const QString &data)
buffer = data.toUtf8();
}
//绑定网卡和端口
if (socket->localPort() != AppConfig::UdpBindPort) {
socket->abort();
socket->bind(QHostAddress(AppConfig::UdpBindIP), AppConfig::UdpBindPort);
}
//指定地址和端口发送数据
socket->writeDatagram(buffer, QHostAddress(ip), port);
QString str = QString("[%1:%2] %3").arg(ip).arg(port).arg(data);
@ -184,7 +206,7 @@ void frmUdpClient::sendData(const QString &ip, int port, const QString &data)
void frmUdpClient::on_btnSave_clicked()
{
QString data = ui->txtMain->toPlainText();
AppConfig::saveData(data);
AppData::saveData(data);
on_btnClear_clicked();
}

View File

@ -26,7 +26,7 @@ private slots:
void initForm();
void initConfig();
void saveConfig();
void changeTimer();
void initTimer();
void append(int type, const QString &data, bool clear = false);
private slots:

View File

@ -53,7 +53,7 @@
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>6</number>
</property>
@ -111,10 +111,30 @@
<item>
<widget class="QComboBox" name="cboxInterval"/>
</item>
<item>
<widget class="QLabel" name="labBindIP">
<property name="text">
<string>绑定地址</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cboxBindIP"/>
</item>
<item>
<widget class="QLabel" name="labBindPort">
<property name="text">
<string>绑定端口</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtBindPort"/>
</item>
<item>
<widget class="QLabel" name="labServerIP">
<property name="text">
<string>远程地址</string>
<string>服务器地址</string>
</property>
</widget>
</item>
@ -124,7 +144,7 @@
<item>
<widget class="QLabel" name="labServerPort">
<property name="text">
<string>远程端口</string>
<string>服务器端口</string>
</property>
</widget>
</item>
@ -213,6 +233,24 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>txtMain</tabstop>
<tabstop>cboxData</tabstop>
<tabstop>btnSend</tabstop>
<tabstop>ckHexReceive</tabstop>
<tabstop>ckHexSend</tabstop>
<tabstop>ckAscii</tabstop>
<tabstop>ckShow</tabstop>
<tabstop>ckDebug</tabstop>
<tabstop>ckAutoSend</tabstop>
<tabstop>cboxInterval</tabstop>
<tabstop>cboxBindIP</tabstop>
<tabstop>txtBindPort</tabstop>
<tabstop>txtServerIP</tabstop>
<tabstop>txtServerPort</tabstop>
<tabstop>btnSave</tabstop>
<tabstop>btnClear</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -16,21 +16,18 @@ frmUdpServer::~frmUdpServer()
void frmUdpServer::initForm()
{
//实例化对象并绑定信号槽
socket = new QUdpSocket(this);
connect(socket, SIGNAL(readyRead()), this, SLOT(readData()));
//定时器发送数据
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(on_btnSend_clicked()));
ui->cboxInterval->addItems(AppConfig::Intervals);
ui->cboxData->addItems(AppConfig::Datas);
//获取本机所有IP
QStringList ips = QUIHelper::getLocalIPs();
ui->cboxListenIP->addItems(ips);
if (!ips.contains("127.0.0.1")) {
ui->cboxListenIP->addItem("127.0.0.1");
}
//填充数据到下拉框
ui->cboxInterval->addItems(AppData::Intervals);
ui->cboxData->addItems(AppData::Datas);
AppData::loadIP(ui->cboxListenIP);
}
void frmUdpServer::initConfig()
@ -62,7 +59,7 @@ void frmUdpServer::initConfig()
ui->ckSelectAll->setChecked(AppConfig::SelectAllUdpServer);
connect(ui->ckSelectAll, SIGNAL(stateChanged(int)), this, SLOT(saveConfig()));
this->changeTimer();
this->initTimer();
}
void frmUdpServer::saveConfig()
@ -78,12 +75,15 @@ void frmUdpServer::saveConfig()
AppConfig::SelectAllUdpServer = ui->ckSelectAll->isChecked();
AppConfig::writeConfig();
this->changeTimer();
this->initTimer();
}
void frmUdpServer::changeTimer()
void frmUdpServer::initTimer()
{
timer->setInterval(AppConfig::IntervalUdpServer);
if (timer->interval() != AppConfig::IntervalUdpServer) {
timer->setInterval(AppConfig::IntervalUdpServer);
}
if (AppConfig::AutoSendUdpServer) {
if (!timer->isActive()) {
timer->start();
@ -165,10 +165,10 @@ void frmUdpServer::readData()
clientConnected(ip, port);
if (AppConfig::DebugUdpServer) {
int count = AppConfig::Keys.count();
int count = AppData::Keys.count();
for (int i = 0; i < count; i++) {
if (AppConfig::Keys.at(i) == buffer) {
sendData(ip, port, AppConfig::Values.at(i));
if (AppData::Keys.at(i) == buffer) {
sendData(ip, port, AppData::Values.at(i));
break;
}
}
@ -225,7 +225,7 @@ void frmUdpServer::on_btnListen_clicked()
void frmUdpServer::on_btnSave_clicked()
{
QString data = ui->txtMain->toPlainText();
AppConfig::saveData(data);
AppData::saveData(data);
on_btnClear_clicked();
}

View File

@ -26,7 +26,7 @@ private slots:
void initForm();
void initConfig();
void saveConfig();
void changeTimer();
void initTimer();
void append(int type, const QString &data, bool clear = false);
private slots:

View File

@ -241,6 +241,8 @@
</widget>
<tabstops>
<tabstop>txtMain</tabstop>
<tabstop>cboxData</tabstop>
<tabstop>btnSend</tabstop>
<tabstop>ckHexReceive</tabstop>
<tabstop>ckHexSend</tabstop>
<tabstop>ckAscii</tabstop>
@ -253,8 +255,8 @@
<tabstop>btnListen</tabstop>
<tabstop>btnSave</tabstop>
<tabstop>btnClear</tabstop>
<tabstop>cboxData</tabstop>
<tabstop>btnSend</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>ckSelectAll</tabstop>
</tabstops>
<resources/>
<connections/>

View File

@ -17,6 +17,8 @@ frmWebClient::~frmWebClient()
void frmWebClient::initForm()
{
isOk = false;
//实例化对象并绑定信号槽
socket = new QWebSocket("WebSocket", QWebSocketProtocol::VersionLatest, this);
connect(socket, SIGNAL(connected()), this, SLOT(connected()));
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(disconnected()));
@ -29,11 +31,13 @@ void frmWebClient::initForm()
//connect(socket, SIGNAL(textFrameReceived(QString, bool)), this, SLOT(textFrameReceived(QString, bool)));
//connect(socket, SIGNAL(binaryFrameReceived(QByteArray, bool)), this, SLOT(binaryFrameReceived(QByteArray, bool)));
//定时器发送数据
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(on_btnSend_clicked()));
ui->cboxInterval->addItems(AppConfig::Intervals);
ui->cboxData->addItems(AppConfig::Datas);
//填充数据到下拉框
ui->cboxInterval->addItems(AppData::Intervals);
ui->cboxData->addItems(AppData::Datas);
}
void frmWebClient::initConfig()
@ -62,7 +66,7 @@ void frmWebClient::initConfig()
ui->txtServerPort->setText(QString::number(AppConfig::WebServerPort));
connect(ui->txtServerPort, SIGNAL(textChanged(QString)), this, SLOT(saveConfig()));
this->changeTimer();
this->initTimer();
}
void frmWebClient::saveConfig()
@ -77,12 +81,15 @@ void frmWebClient::saveConfig()
AppConfig::WebServerPort = ui->txtServerPort->text().trimmed().toInt();
AppConfig::writeConfig();
this->changeTimer();
this->initTimer();
}
void frmWebClient::changeTimer()
void frmWebClient::initTimer()
{
timer->setInterval(AppConfig::IntervalWebClient);
if (timer->interval() != AppConfig::IntervalWebClient) {
timer->setInterval(AppConfig::IntervalWebClient);
}
if (AppConfig::AutoSendWebClient) {
if (!timer->isActive()) {
timer->start();
@ -174,10 +181,10 @@ void frmWebClient::textFrameReceived(const QString &data, bool isLastFrame)
//自动回复数据,可以回复的数据是以;隔开,每行可以带多个;所以这里不需要继续判断
if (AppConfig::DebugWebClient) {
int count = AppConfig::Keys.count();
int count = AppData::Keys.count();
for (int i = 0; i < count; i++) {
if (AppConfig::Keys.at(i) == buffer) {
sendData(AppConfig::Values.at(i));
if (AppData::Keys.at(i) == buffer) {
sendData(AppData::Values.at(i));
break;
}
}
@ -220,7 +227,7 @@ void frmWebClient::on_btnConnect_clicked()
void frmWebClient::on_btnSave_clicked()
{
QString data = ui->txtMain->toPlainText();
AppConfig::saveData(data);
AppData::saveData(data);
on_btnClear_clicked();
}

View File

@ -27,7 +27,7 @@ private slots:
void initForm();
void initConfig();
void saveConfig();
void changeTimer();
void initTimer();
void append(int type, const QString &data, bool clear = false);
private slots:

View File

@ -17,24 +17,22 @@ frmWebServer::~frmWebServer()
void frmWebServer::initForm()
{
isOk = false;
//实例化对象并绑定信号槽
server = new WebServer("WebServer", QWebSocketServer::NonSecureMode, this);
connect(server, SIGNAL(clientConnected(QString, int)), this, SLOT(clientConnected(QString, int)));
connect(server, SIGNAL(clientDisconnected(QString, int)), this, SLOT(clientDisconnected(QString, int)));
connect(server, SIGNAL(sendData(QString, int, QString)), this, SLOT(sendData(QString, int, QString)));
connect(server, SIGNAL(receiveData(QString, int, QString)), this, SLOT(receiveData(QString, int, QString)));
//定时器发送数据
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(on_btnSend_clicked()));
ui->cboxInterval->addItems(AppConfig::Intervals);
ui->cboxData->addItems(AppConfig::Datas);
//获取本机所有IP
QStringList ips = QUIHelper::getLocalIPs();
ui->cboxListenIP->addItems(ips);
if (!ips.contains("127.0.0.1")) {
ui->cboxListenIP->addItem("127.0.0.1");
}
//填充数据到下拉框
ui->cboxInterval->addItems(AppData::Intervals);
ui->cboxData->addItems(AppData::Datas);
AppData::loadIP(ui->cboxListenIP);
}
void frmWebServer::initConfig()
@ -66,7 +64,7 @@ void frmWebServer::initConfig()
ui->ckSelectAll->setChecked(AppConfig::SelectAllWebServer);
connect(ui->ckSelectAll, SIGNAL(stateChanged(int)), this, SLOT(saveConfig()));
this->changeTimer();
this->initTimer();
}
void frmWebServer::saveConfig()
@ -82,12 +80,15 @@ void frmWebServer::saveConfig()
AppConfig::SelectAllWebServer = ui->ckSelectAll->isChecked();
AppConfig::writeConfig();
this->changeTimer();
this->initTimer();
}
void frmWebServer::changeTimer()
void frmWebServer::initTimer()
{
timer->setInterval(AppConfig::IntervalWebServer);
if (timer->interval() != AppConfig::IntervalWebServer) {
timer->setInterval(AppConfig::IntervalWebServer);
}
if (AppConfig::AutoSendWebServer) {
if (!timer->isActive()) {
timer->start();
@ -192,7 +193,7 @@ void frmWebServer::on_btnListen_clicked()
void frmWebServer::on_btnSave_clicked()
{
QString data = ui->txtMain->toPlainText();
AppConfig::saveData(data);
AppData::saveData(data);
on_btnClear_clicked();
}

View File

@ -27,7 +27,7 @@ private slots:
void initForm();
void initConfig();
void saveConfig();
void changeTimer();
void initTimer();
void append(int type, const QString &data, bool clear = false);
private slots:

View File

@ -246,6 +246,26 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>txtMain</tabstop>
<tabstop>cboxData</tabstop>
<tabstop>btnSend</tabstop>
<tabstop>ckHexReceive</tabstop>
<tabstop>ckHexSend</tabstop>
<tabstop>ckAscii</tabstop>
<tabstop>ckShow</tabstop>
<tabstop>ckDebug</tabstop>
<tabstop>ckAutoSend</tabstop>
<tabstop>cboxInterval</tabstop>
<tabstop>cboxListenIP</tabstop>
<tabstop>txtListenPort</tabstop>
<tabstop>btnListen</tabstop>
<tabstop>btnSave</tabstop>
<tabstop>btnClear</tabstop>
<tabstop>btnClose</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>ckSelectAll</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -15,3 +15,4 @@
#pragma execution_character_set("utf-8")
#include "appconfig.h"
#include "appdata.h"

View File

@ -13,11 +13,12 @@ int main(int argc, char *argv[])
QUIHelper::setTranslator(":/widgets.qm");
QUIHelper::initRand();
AppConfig::Intervals << "1" << "10" << "20" << "50" << "100" << "200" << "300" << "500" << "1000" << "1500" << "2000" << "3000" << "5000" << "10000";
AppConfig::ConfigFile = QString("%1/%2.ini").arg(QUIHelper::appPath()).arg(QUIHelper::appName());
AppConfig::readConfig();
AppConfig::readSendData();
AppConfig::readDeviceData();
AppData::Intervals << "1" << "10" << "20" << "50" << "100" << "200" << "300" << "500" << "1000" << "1500" << "2000" << "3000" << "5000" << "10000";
AppData::readSendData();
AppData::readDeviceData();
frmMain w;
w.setWindowTitle("网络调试助手 V2021 (QQ: 517216493 WX: feiyangqingyun)");

View File

@ -1,5 +1,5 @@
### 特别说明
1. 编译完成以后记得将dll文件复制到可执行文件同一目录。
### 特别说明
1. 编译完成以后记得将动态库文件复制到可执行文件同一目录。
2. 动态库地址:[https://pan.baidu.com/s/13LDRu6mXC6gaADtrGprNVA](https://pan.baidu.com/s/13LDRu6mXC6gaADtrGprNVA) 提取码: ujm7
3. 收费增强版:[https://qtchina.blog.csdn.net/article/details/103946067](https://qtchina.blog.csdn.net/article/details/103946067)