From a630c5a85b33e94877d3048554c3dc82472342d5 Mon Sep 17 00:00:00 2001 From: "CHINAMI-TV221UM\\Administrator" Date: Thu, 4 Jul 2024 15:23:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=BB=A4=E6=B3=A2=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backup.cpp | 130 ++++++++++++++++ Backup.h | 36 +++++ Backup.ui | 150 +++++++++++++++++++ BoardSetting.cpp | 26 ++-- ChannelList.cpp | 215 ++++++++++++++++++++------- ChannelList.h | 3 + ChannelSetting.cpp | 60 +++++--- ChannelSetting.h | 4 +- CharacteristicList.cpp | 16 +- Configuration.cpp | 20 +++ Configuration.ui | 41 +++++- CustomFilter.cpp | 206 ++++++++++++++++++++++++++ CustomFilter.h | 39 +++++ CustomFilter.ui | 328 +++++++++++++++++++++++++++++++++++++++++ DataWatch3500_GUI.pro | 10 ++ ImportConfig.cpp | 246 +++++++++++++++++++++++++++++++ ImportConfig.h | 35 +++++ ImportConfig.ui | 150 +++++++++++++++++++ TerminalInfo.cpp | 23 ++- TerminalInfo.h | 4 + TerminalInfo.ui | 70 ++++++++- TriggerConfig.cpp | 38 +++-- UnitSetting.ui | 66 +++++++++ WaveDisplay.cpp | 12 +- WaveDisplay.h | 1 + WorkingCondition.ui | 44 +++--- channellist.ui | 10 ++ channelsetting.ui | 197 ++++++++++--------------- global.h | 5 + main.cpp | 2 + mainwindow.cpp | 11 +- qss/blacksoft.css | 34 ++++- realtimeform.cpp | 8 +- sqlitedb.cpp | 21 ++- sqlitedb.h | 1 + 35 files changed, 1992 insertions(+), 270 deletions(-) create mode 100644 Backup.cpp create mode 100644 Backup.h create mode 100644 Backup.ui create mode 100644 CustomFilter.cpp create mode 100644 CustomFilter.h create mode 100644 CustomFilter.ui create mode 100644 ImportConfig.cpp create mode 100644 ImportConfig.h create mode 100644 ImportConfig.ui diff --git a/Backup.cpp b/Backup.cpp new file mode 100644 index 0000000..e02b545 --- /dev/null +++ b/Backup.cpp @@ -0,0 +1,130 @@ +#include "Backup.h" +#include "ui_BackUp.h" +#include +#include + +CBackup::CBackup(QWidget *parent) : + QWidget(parent), + ui(new Ui::CBackup) +{ + ui->setupUi(this); + backup_path = ""; + +} + +CBackup::~CBackup() +{ + delete ui; +} + +void CBackup::on_pushButton_path_clicked() +{ + QString dirpath = QFileDialog::getExistingDirectory(this, QStringLiteral("选择目录"), "./", QFileDialog::ShowDirsOnly); + if(dirpath.isEmpty()) dirpath = QDir::currentPath(); + ui->lineEdit_filepath->setText(dirpath + "/"); + + backup_path = dirpath; +} + + +void CBackup::on_pushButton_confirm_clicked() +{ + + if(ui->lineEdit_filepath->text() == ""){ + QMessageBox::information(this,tr("提示"),tr("请选择导出文件路径!")); + return; + } + backup_path = backup_path + "\\config\\"; + copyDirectory(QCoreApplication::applicationDirPath() + "\\config\\", backup_path); + QFile file(backup_path+"macbackup"); + if (!file.open(QIODevice::ReadWrite)) { + qWarning("Couldn't open file for writing."); + return; + } + QTextStream out(&file); + out << MAC << endl; + file.close(); + QMessageBox::information(this,tr("导出"),tr("导出成功!")); +} + +int CBackup::ExeSqlData(QString& strSql) +{ + QSqlQuery sql_query; + int iRet = -1; + qDebug() << "strSql" << strSql << endl; + if(!sql_query.exec(strSql)) + { + qDebug() << sql_query.lastError(); + } + else + { + while(sql_query.next()) + { + iRet = sql_query.value(0).toInt(); + } + } + return iRet; +} +bool CBackup::copyFile(const QString &sourceFile, const QString &destinationFile) +{ + QFile srcFile(sourceFile); + QFile dstFile(destinationFile); + + if (!srcFile.exists()) { + qDebug() << "Source file does not exist:" << sourceFile; + return false; + } + + if (!srcFile.open(QIODevice::ReadOnly)) { + qDebug() << "Unable to open source file for reading:" << sourceFile; + return false; + } + + if (!dstFile.open(QIODevice::WriteOnly)) { + srcFile.close(); + qDebug() << "Unable to open destination file for writing:" << destinationFile; + return false; + } + + dstFile.write(srcFile.readAll()); + srcFile.close(); + dstFile.close(); + return true; +} +bool CBackup::copyDirectory(const QString &sourceDir, const QString &destinationDir) { + QDir srcDir(sourceDir); + QDir destDir(destinationDir); + + // 如果目标文件夹已存在,则删除它 + if (destDir.exists()) { + destDir.removeRecursively(); + } + + // 创建目标文件夹 + if (!destDir.mkpath(".")) { + qDebug() << "无法创建目标文件夹"; + return false; + } + + // 复制文件 + foreach (const QFileInfo &fileInfo, srcDir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot)) { + QString fileName = fileInfo.fileName(); + QString srcFilePath = srcDir.absoluteFilePath(fileName); + QString destFilePath = destDir.absoluteFilePath(fileName); + + if (fileInfo.isDir()) { + // 递归复制子文件夹 + if (!copyDirectory(srcFilePath, destFilePath)) { + return false; + } + } else { + // 复制文件 + if (!QFile::copy(srcFilePath, destFilePath)) { + qDebug() << "无法复制文件" << srcFilePath << "到" << destFilePath; + return false; + } + } + } + + return true; +} diff --git a/Backup.h b/Backup.h new file mode 100644 index 0000000..9c89957 --- /dev/null +++ b/Backup.h @@ -0,0 +1,36 @@ +#ifndef BACKUP_H +#define BACKUP_H + +#include +#include +#include +#include +#include "global.h" +namespace Ui { +class CBackup; +} + +class CBackup : public QWidget +{ + Q_OBJECT + +public: + explicit CBackup(QWidget *parent = nullptr); + ~CBackup(); + +private slots: + void on_pushButton_path_clicked(); + + void on_pushButton_confirm_clicked(); + +private: + Ui::CBackup *ui; + QString backup_path; + QSqlDatabase database; + int CreateDataBase(); + int ExeSqlData(QString& strSql); + bool copyFile(const QString &sourceFile, const QString &destinationFile); + bool copyDirectory(const QString &sourceDir, const QString &destinationDir); +}; + +#endif // BACKUP_H diff --git a/Backup.ui b/Backup.ui new file mode 100644 index 0000000..d745025 --- /dev/null +++ b/Backup.ui @@ -0,0 +1,150 @@ + + + CBackup + + + + 0 + 0 + 711 + 169 + + + + 配置导出 + + + font: 10pt "黑体"; +color: rgb(27, 30, 35); + + + + + + + + + 请填写导出信息 + + + Qt::AlignCenter + + + + + + + + + + + + + + + + + false + + + + + + + + 96 + 28 + + + + + 96 + 28 + + + + #pushButton_path { border-image: url(:/image/Btn/normal_Btn.png); + color:#1f5188 } +#pushButton_path:hover { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_path:pressed { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_path:checked { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} + + + 导出路径 + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 96 + 28 + + + + + 96 + 28 + + + + #pushButton_confirm { border-image: url(:/image/Btn/normal_Btn.png); + color:#1f5188 } +#pushButton_confirm:hover { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_confirm:pressed { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_confirm:checked { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} + + + 确认 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + diff --git a/BoardSetting.cpp b/BoardSetting.cpp index 2dddfe3..95637d7 100644 --- a/BoardSetting.cpp +++ b/BoardSetting.cpp @@ -327,7 +327,7 @@ void CBoardSetting::PushData() QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ - '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','');").\ + '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','',0);").\ arg("NULL").arg(0).arg("true").arg("ACCELEROMETER").arg("0").arg("Bottom").arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg(0).arg(0).arg("false"). arg(0).arg("false").arg(0).arg("false").arg(0).arg(strChannelID).arg("NONE").arg(strChannelName).arg("false").arg(0).arg("false").arg(0).arg("RMSValue").arg("").arg(0).arg("false").arg(0).arg("CTC-AC102").arg("false").arg(0).arg("false").arg(0).arg("").\ arg("true").arg(strMAC).arg(0).arg(1000).arg(0).arg("Hamming").arg("15000").arg("0.5").arg(30).arg("5000").arg("").arg(0).arg(0).arg("0").arg("60000").arg(0).arg("NONE").arg("").arg("0").arg(1024).arg("").arg("").arg(timeStamp).\ @@ -347,7 +347,7 @@ void CBoardSetting::PushData() QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ - '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','');").\ + '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','',0);").\ arg("NULL").arg(0).arg("true").arg("ACCELEROMETER").arg("0").arg("Bottom").arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg(0).arg(0).arg("false"). arg(0).arg("false").arg(0).arg("false").arg(0).arg(strChannelID).arg("NONE").arg(strChannelName).arg("false").arg(0).arg("false").arg(0).arg("RMSValue").arg("").arg(0).arg("false").arg(0).arg("CTC-AC102").arg("false").arg(0).arg("false").arg(0).arg("").\ arg("true").arg(strMAC).arg(0).arg(1000).arg(0).arg("Hamming").arg("15000").arg("0.5").arg(12).arg("5000").arg("").arg(0).arg(0).arg("0").arg("60000").arg(0).arg("NONE").arg("").arg("0").arg(1024).arg("").arg("").arg(timeStamp).\ @@ -366,7 +366,7 @@ void CBoardSetting::PushData() QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ - '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','');").\ + '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','',0);").\ arg("NULL").arg(0).arg("true").arg("PULSE_CURRENT").arg("0").arg("Bottom").arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg(0).arg(0).arg("false"). arg(0).arg("false").arg(0).arg("false").arg(0).arg(strChannelID).arg("NONE").arg(strChannelName).arg("false").arg(0).arg("false").arg(0).arg("RMSValue").arg("").arg(0).arg("false").arg(0).arg("电流变送器").arg("false").arg(0).arg("false").arg(0).arg("").\ arg("true").arg(MAC).arg(0).arg(1000).arg(0).arg("Hamming").arg("").arg("").arg(20).arg("5000").arg("").arg(0).arg(0).arg("0").arg("60000").arg(0).arg("NONE").arg("").arg("0").arg(1024).arg("").arg("").arg(timeStamp).\ @@ -386,7 +386,7 @@ void CBoardSetting::PushData() QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ - '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','');").\ + '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','',0);").\ arg("NULL").arg(0).arg("true").arg("SLOW_CURRENT").arg("0").arg("Bottom").arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg(0).arg(0).arg("false"). arg(0).arg("false").arg(0).arg("false").arg(0).arg(strChannelID).arg("NONE").arg(strChannelName).arg("false").arg(0).arg("false").arg(0).arg("RMSValue").arg("").arg(0).arg("false").arg(0).arg("电流变送器").arg("false").arg(0).arg("false").arg(0).arg("").\ arg("true").arg(MAC).arg(0).arg(1000).arg(0).arg("Hamming").arg("").arg("").arg(20).arg("5000").arg("").arg(0).arg(0).arg("0").arg("60000").arg(0).arg("NONE").arg("").arg("0").arg(64).arg("").arg("").arg(timeStamp).\ @@ -415,7 +415,7 @@ void CBoardSetting::PushData() QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ - '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',0,0,'','');").\ + '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',0,0,'','',0);").\ arg("NULL").arg(0).arg("false").arg(strchannelType).arg("0").arg("").arg("").arg(0).arg("").arg(0).arg("").arg(0).arg("").arg(0).arg("").arg(0).arg("").arg(0).arg(0).arg(0).arg(""). arg(0).arg("").arg(0).arg("").arg(0).arg(strChannelID).arg("").arg(strChannelName).arg("").arg(0).arg("").arg(0).arg("").arg("").arg(0).arg("").arg(0).arg("").arg("").arg(0).arg("").arg(0).arg("").\ arg("true").arg(MAC).arg(0).arg(1000).arg(0).arg("").arg("").arg("").arg(10).arg("").arg("").arg(0).arg(0).arg("0").arg("").arg(0).arg("").arg("").arg("0").arg(0).arg("").arg("").arg(timeStamp).\ @@ -757,7 +757,7 @@ void CBoardSetting::on_pushButton_Init_clicked() QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ - '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','');").\ + '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','',0);").\ arg("NULL").arg(0).arg("true").arg("ACCELEROMETER").arg("0").arg("Bottom").arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg(0).arg(0).arg("false"). arg(0).arg("false").arg(0).arg("false").arg(0).arg(strChannelID).arg("NONE").arg(strChannelName).arg("false").arg(0).arg("false").arg(0).arg("RMSValue").arg("").arg(0).arg("false").arg(0).arg("CTC-AC102").arg("false").arg(0).arg("false").arg(0).arg("").\ arg("true").arg(strMAC).arg(0).arg(1000).arg(0).arg("Hamming").arg("15000").arg("0.5").arg(10).arg("5000").arg("").arg(1).arg(1).arg("0").arg("60000").arg(0).arg("NONE").arg("").arg("0").arg(1024).arg("").arg("").arg(timeStamp).\ @@ -776,7 +776,7 @@ void CBoardSetting::on_pushButton_Init_clicked() QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ - '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','');").\ + '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','',0);").\ arg("NULL").arg(0).arg("true").arg("PULSE_CURRENT").arg("0").arg("Bottom").arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg(0).arg(0).arg("false"). arg(0).arg("false").arg(0).arg("false").arg(0).arg(strChannelID).arg("NONE").arg(strChannelName).arg("false").arg(0).arg("false").arg(0).arg("RMSValue").arg("").arg(0).arg("false").arg(0).arg("电流变送器").arg("false").arg(0).arg("false").arg(0).arg("").\ arg("true").arg(MAC).arg(0).arg(1000).arg(0).arg("Hamming").arg("").arg("").arg(20).arg("5000").arg("").arg(1).arg(1).arg("0").arg("60000").arg(0).arg("NONE").arg("").arg("0").arg(1024).arg("").arg("").arg(timeStamp).\ @@ -796,7 +796,7 @@ void CBoardSetting::on_pushButton_Init_clicked() QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ - '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','');").\ + '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','',0);").\ arg("NULL").arg(0).arg("true").arg("SLOW_CURRENT").arg("0").arg("Bottom").arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg(0).arg(0).arg("false"). arg(0).arg("false").arg(0).arg("false").arg(0).arg(strChannelID).arg("NONE").arg(strChannelName).arg("false").arg(0).arg("false").arg(0).arg("RMSValue").arg("").arg(0).arg("false").arg(0).arg("电流变送器").arg("false").arg(0).arg("false").arg(0).arg("").\ arg("true").arg(MAC).arg(0).arg(1000).arg(0).arg("Hamming").arg("").arg("").arg(20).arg("5000").arg("").arg(0).arg(0).arg("0").arg("60000").arg(0).arg("NONE").arg("").arg("0").arg(64).arg("").arg("").arg(timeStamp).\ @@ -825,7 +825,7 @@ void CBoardSetting::on_pushButton_Init_clicked() QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ - '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',0,0,'','');").\ + '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',0,0,'','',0);").\ arg("NULL").arg(0).arg("false").arg(strchannelType).arg("0").arg("").arg("").arg(0).arg("").arg(0).arg("").arg(0).arg("").arg(0).arg("").arg(0).arg("").arg(0).arg(0).arg(0).arg(""). arg(0).arg("").arg(0).arg("").arg(0).arg(strChannelID).arg("").arg(strChannelName).arg("").arg(0).arg("").arg(0).arg("").arg("").arg(0).arg("").arg(0).arg("").arg("").arg(0).arg("").arg(0).arg("").\ arg("true").arg(MAC).arg(0).arg(1000).arg(0).arg("").arg("").arg("").arg(10).arg("").arg("").arg(0).arg(0).arg("0").arg("").arg(0).arg("").arg("").arg("0").arg(0).arg("").arg("").arg(timeStamp).\ @@ -947,6 +947,14 @@ void CBoardSetting::on_pushButton_Init_clicked() // g_FtpClient->SetUserInfo("root","@#cidw!@123456"); // g_FtpClient->UpLoadFile(name,"UnitBoardsInfo.json"); customLogMessageHandler(QtDebugMsg,"初始化机组板卡配置信息推送完成!"); + + QJsonObject sendData; + sendData["cmd"] = "111"; + QNetworkRequest req; + QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP); + req.setUrl(sUrl); + g_NetMgr->PostJson(req,sendData); + putJson(); } diff --git a/ChannelList.cpp b/ChannelList.cpp index 2098303..eaf9b24 100644 --- a/ChannelList.cpp +++ b/ChannelList.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "NetMgr.h" CChannelList::CChannelList(QWidget *parent) : @@ -14,6 +15,7 @@ CChannelList::CChannelList(QWidget *parent) : ui(new Ui::CChannelList) { ui->setupUi(this); + ui->comboBox_operate->setView(new QListView()); // this->setWindowTitle("QTableView简单使用"); // //建立模型对象空间并指定父对象 @@ -48,7 +50,7 @@ CChannelList::CChannelList(QWidget *parent) : // this->setColumnCheckable(0, true); // //this->setColumnCheckable(2, true); //--1 初始化 - headerStr = QObject::tr(" ,通道名称,模块编号,通道序号,通道状态,通道类型,采样频率(Hz),灵敏度,工程单位,范围检查,最小值,\ + headerStr = QObject::tr(" ,通道名称,模块编号,通道滤波状态,通道状态,通道类型,采样频率(Hz),灵敏度,工程单位,范围检查,最小值,\ 最大值,1x幅值补偿,1x相位补偿,初始间距,安装角度,安装位置,转向,速度参考,转速比,关联通道,\ 轴承间隙,启动位置,IEPE,耦合性,0值电压,满程电压,自动转速,触发沿,触发次数,Hysteresis(V),\ 触发阈值,热电偶类型,配置时间,滤波器,起始频率,截止频率,备注"); @@ -57,25 +59,26 @@ CChannelList::CChannelList(QWidget *parent) : iniVar(); iniUi(); iniConnect(); - initReadConfig(); + connect(ui->tableView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotRowDoubleClicked(const QModelIndex &))); ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->tableView->setColumnWidth(33, 256); m_nCurRow = -1; - SlowSpeeddialog = new CSlowSpeedChannelSetting(); - connect(SlowSpeeddialog, SIGNAL(sgSetChannelData(ChannelSetting)), this, SLOT(slotSetChannelData(ChannelSetting))); - ChannelSettingdialog = new CChannelSetting(); - connect(ChannelSettingdialog, SIGNAL(sgSetChannelData(ChannelSetting)), this, SLOT(slotSetChannelData(ChannelSetting))); - SlowSpeeddialog = new CSlowSpeedChannelSetting(); - connect(SlowSpeeddialog, SIGNAL(sgSetChannelData(ChannelSetting)), this, SLOT(slotSetChannelData(ChannelSetting))); + ui->comboBox_operate->addItem("通道"); + ui->comboBox_operate->addItem("带通滤波"); //--2 创建表格项 // QStringList workingConditionName; // workingConditionName<tableView->setColumnWidth(i, 200); }else{ - ui->tableView->setColumnWidth(i, 150); + ui->tableView->setColumnWidth(i, 130); } } @@ -164,6 +172,20 @@ void CChannelList::iniConnect() { connect(myHeader, &TableHeaderView::stateChanged, this, &CChannelList::headerStateChangedSlot); connect(model, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(itemChangedSlot(QStandardItem*))); + + connect(g_NetMgr,SIGNAL(sigNetMgr(QString, const QVariant&)), this, SLOT(slotNetMgr(QString,const QVariant&))); + QJsonObject sendData; + sendData["cmd"] = "97"; + QJsonArray chan_list; + for (int i = 0; i < g_channelSetting.size(); i++) { + if(g_channelSetting[i].boardType != "5" && g_channelSetting[i].boardType != "6" ) + chan_list.append(g_channelSetting[i].channelId); + } + sendData["chan_list"] = chan_list; + QNetworkRequest req; + QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP); + req.setUrl(sUrl); + g_NetMgr->PostJson(req,sendData); } void CChannelList::createItem(QStringList filename) @@ -241,9 +263,13 @@ void CChannelList::itemChangedSlot(QStandardItem *item) myHeader->onStateChanged(state); } } - +void CChannelList::slotChannelSettingClose() +{ + on_pushButton_refresh_clicked(); +} void CChannelList::slotSetChannelData(ChannelSetting channelSetting) { + qDebug() << "slotSetChannelData" << endl; int i; for (i = 0;i UpdateDataSql(tableName,strUpdateSql); g_channelSetting = g_SqliteDB->GetDataMultiLine("t_ChannelSetting"); + putJson(); //disconnect(ChannelSettingdialog, SIGNAL(sgSetChannelData(ChannelSetting)), this, SLOT(slotSetChannelData(ChannelSetting))); @@ -514,20 +541,26 @@ void CChannelList::slotRowDoubleClicked(const QModelIndex &index) if(g_channelSetting[m_nCurRow].boardType.toInt() == 1 && g_channelSetting[i].channelId == g_channelSetting[m_nCurRow].channelId){//开入开出板卡 - SlowSpeeddialog->channelSetting = g_channelSetting[i]; - SlowSpeeddialog->setWindowModality(Qt::ApplicationModal); - SlowSpeeddialog->displayChannelSetting(); - SlowSpeeddialog->show(); + SlowSpeeddialog = new CSlowSpeedChannelSetting(); + connect(SlowSpeeddialog, SIGNAL(sgSetChannelData(ChannelSetting)), this, SLOT(slotSetChannelData(ChannelSetting))); + SlowSpeeddialog->channelSetting = g_channelSetting[i]; + SlowSpeeddialog->setWindowModality(Qt::ApplicationModal); + SlowSpeeddialog->displayChannelSetting(); + SlowSpeeddialog->show(); } else if(g_channelSetting[m_nCurRow].boardType.toInt() > 1 && g_channelSetting[m_nCurRow].boardType.toInt() < 5 && g_channelSetting[i].channelId == g_channelSetting[m_nCurRow].channelId){//高速板卡 qDebug() << g_channelSetting[m_nCurRow].boardType << g_channelSetting[i].channelId << g_channelSetting[m_nCurRow].channelId<< endl; - + ChannelSettingdialog = new CChannelSetting(); + connect(ChannelSettingdialog, SIGNAL(sgSetChannelData(ChannelSetting)), this, SLOT(slotSetChannelData(ChannelSetting))); + connect(ChannelSettingdialog, SIGNAL(ChannelSettingClose_sg()), this, SLOT(slotChannelSettingClose())); ChannelSettingdialog->channelSetting = g_channelSetting[i]; ChannelSettingdialog->setWindowModality(Qt::ApplicationModal); ChannelSettingdialog->displayChannelSetting(); ChannelSettingdialog->show(); }else if((g_channelSetting[m_nCurRow].boardType.toInt() == 5) && g_channelSetting[i].channelId == g_channelSetting[m_nCurRow].channelId){//低速板卡 + SlowSpeeddialog = new CSlowSpeedChannelSetting(); + connect(SlowSpeeddialog, SIGNAL(sgSetChannelData(ChannelSetting)), this, SLOT(slotSetChannelData(ChannelSetting))); SlowSpeeddialog->channelSetting = g_channelSetting[i]; SlowSpeeddialog->setWindowModality(Qt::ApplicationModal); SlowSpeeddialog->displayChannelSetting(); @@ -583,47 +616,85 @@ void CChannelList::on_columnSectionClicked(int column, bool checked) void CChannelList::on_pushButton_open_clicked() { - for (int i = 0; i < model->rowCount(); i++) { - QModelIndex indexCheck = model->index(i,0); - bool check = model->data(indexCheck, Qt::UserRole).toBool(); - if(check){ -// QLabel *pLabel = new QLabel(this); -// pLabel->setText("启用"); -// QPalette palette; -// palette.setColor(QPalette::Background, QColor(Qt::green)); -// //palette.setColor(QPalette::WindowText,Qt::white); -// //pLabel->setAutoFillBackground(true); -// pLabel->setPalette(palette); -// ui->tableView->setIndexWidget(model->index(i,4),pLabel); - //model->setData(model->index(i,4),QBrush(Qt::red), Qt::BackgroundRole); - model->setItem(i,4,new QStandardItem("启用")); - QString strChannelID = model->data(model->index(i,38)).toString(); - QString strUpdateSql = QString(" set isEnable = %1 , isWork = %2 where channelId = '%3' ").arg(1).arg(1).arg(g_channelSetting[i].channelId); - QString tableName = "t_ChannelSetting "; - g_SqliteDB->UpdateDataSql(tableName,strUpdateSql); - g_channelSetting = g_SqliteDB->GetDataMultiLine("t_ChannelSetting"); + if(ui->comboBox_operate->currentText() == "通道"){ + for (int i = 0; i < model->rowCount(); i++) { + QModelIndex indexCheck = model->index(i,0); + bool check = model->data(indexCheck, Qt::UserRole).toBool(); + if(check){ + // QLabel *pLabel = new QLabel(this); + // pLabel->setText("启用"); + // QPalette palette; + // palette.setColor(QPalette::Background, QColor(Qt::green)); + // //palette.setColor(QPalette::WindowText,Qt::white); + // //pLabel->setAutoFillBackground(true); + // pLabel->setPalette(palette); + // ui->tableView->setIndexWidget(model->index(i,4),pLabel); + //model->setData(model->index(i,4),QBrush(Qt::red), Qt::BackgroundRole); + model->setItem(i,4,new QStandardItem("启用")); + QString strChannelID = model->data(model->index(i,38)).toString(); + QString strUpdateSql = QString(" set isEnable = %1 , isWork = %2 where channelId = '%3' ").arg(1).arg(1).arg(g_channelSetting[i].channelId); + QString tableName = "t_ChannelSetting "; + g_SqliteDB->UpdateDataSql(tableName,strUpdateSql); + g_channelSetting = g_SqliteDB->GetDataMultiLine("t_ChannelSetting"); + } } - } - putJson(); + putJson(); + }else if(ui->comboBox_operate->currentText() == "带通滤波"){ + QJsonArray channleList; + for (int i = 0; i < model->rowCount(); i++) { + QModelIndex indexCheck = model->index(i,0); + bool check = model->data(indexCheck, Qt::UserRole).toBool(); + if(check){ + model->setItem(i,3,new QStandardItem("启用")); + QString strChannelID = model->data(model->index(i,38)).toString(); + QString strUpdateSql = QString(" set filterStatus = %1 where channelId = '%2' ").arg(1).arg(g_channelSetting[i].channelId); + QString tableName = "t_ChannelSetting "; + g_SqliteDB->UpdateDataSql(tableName,strUpdateSql); + g_channelSetting = g_SqliteDB->GetDataMultiLine("t_ChannelSetting"); + channleList.append(g_channelSetting[i].channelId); + } + } + operateChannelFilter(true,channleList); + } } void CChannelList::on_pushButton_close_clicked() { - for (int i = 0; i < model->rowCount(); i++) { - QModelIndex indexCheck = model->index(i,0); - bool check = model->data(indexCheck, Qt::UserRole).toBool(); - if(check){ - model->setItem(i,4,new QStandardItem("关闭")); - QString strChannelID = model->data(model->index(i,39)).toString(); - QString strUpdateSql = QString(" set isEnable = %1, isWork = %2 where channelId = '%3' ").arg(0).arg(0).arg(g_channelSetting[i].channelId); - QString tableName = "t_ChannelSetting "; - g_SqliteDB->UpdateDataSql(tableName,strUpdateSql); - g_channelSetting = g_SqliteDB->GetDataMultiLine("t_ChannelSetting"); + + if(ui->comboBox_operate->currentText() == "通道"){ + for (int i = 0; i < model->rowCount(); i++) { + QModelIndex indexCheck = model->index(i,0); + bool check = model->data(indexCheck, Qt::UserRole).toBool(); + if(check){ + model->setItem(i,4,new QStandardItem("关闭")); + QString strChannelID = model->data(model->index(i,39)).toString(); + QString strUpdateSql = QString(" set isEnable = %1, isWork = %2 where channelId = '%3' ").arg(0).arg(0).arg(g_channelSetting[i].channelId); + QString tableName = "t_ChannelSetting "; + g_SqliteDB->UpdateDataSql(tableName,strUpdateSql); + g_channelSetting = g_SqliteDB->GetDataMultiLine("t_ChannelSetting"); + } } + putJson(); + }else if(ui->comboBox_operate->currentText() == "带通滤波"){ + QJsonArray channleList; + for (int i = 0; i < model->rowCount(); i++) { + QModelIndex indexCheck = model->index(i,0); + bool check = model->data(indexCheck, Qt::UserRole).toBool(); + if(check){ + model->setItem(i,3,new QStandardItem("关闭")); + QString strChannelID = model->data(model->index(i,38)).toString(); + QString strUpdateSql = QString(" set filterStatus = %1 where channelId = '%2' ").arg(0).arg(g_channelSetting[i].channelId); + QString tableName = "t_ChannelSetting "; + g_SqliteDB->UpdateDataSql(tableName,strUpdateSql); + g_channelSetting = g_SqliteDB->GetDataMultiLine("t_ChannelSetting"); + channleList.append(g_channelSetting[i].channelId); + } + + } + operateChannelFilter(false,channleList); } - putJson(); } @@ -631,7 +702,21 @@ void CChannelList::on_pushButton_refresh_clicked() { model->removeRows(0, model->rowCount()); g_channelSetting = g_SqliteDB->GetDataMultiLine("t_ChannelSetting"); + connect(g_NetMgr,SIGNAL(sigNetMgr(QString, const QVariant&)), this, SLOT(slotNetMgr(QString,const QVariant&))); + QJsonObject sendData; + sendData["cmd"] = "97"; + QJsonArray chan_list; + for (int i = 0; i < g_channelSetting.size(); i++) { + chan_list.append(g_channelSetting[i].channelId); + } + sendData["chan_list"] = chan_list; + QNetworkRequest req; + QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP); + req.setUrl(sUrl); + g_NetMgr->PostJson(req,sendData); +#ifdef QT_DEBUG initReadConfig(); +#endif } void CChannelList::slotNetMgr(QString sAddr, const QVariant &msg) @@ -641,14 +726,30 @@ void CChannelList::slotNetMgr(QString sAddr, const QVariant &msg) { QJsonValue arrays_value = objec.take("cmd"); //qDebug()<<"cmd ="<PostJson(req,sendData); +} diff --git a/ChannelList.h b/ChannelList.h index c8fd449..f537efb 100644 --- a/ChannelList.h +++ b/ChannelList.h @@ -29,6 +29,7 @@ public slots: void on_columnSectionClicked(int column, bool checked); void slotSetChannelData(ChannelSetting channelSetting); + void slotChannelSettingClose(); private: Ui::CChannelList *ui; QStandardItemModel *m_pModel; //数据模型对象指针 @@ -55,6 +56,8 @@ private: int m_nCurRow; CSlowSpeedChannelSetting *SlowSpeeddialog; CChannelSetting *ChannelSettingdialog; + + void operateChannelFilter(bool type,QJsonArray& channleList); private slots: void headerStateChangedSlot(int state); void itemChangedSlot(QStandardItem* item); diff --git a/ChannelSetting.cpp b/ChannelSetting.cpp index 1eb0a05..f12b694 100644 --- a/ChannelSetting.cpp +++ b/ChannelSetting.cpp @@ -5,7 +5,8 @@ #include #include "CopyChannelSetting.h" #include "NetMgr.h" - +#include "CustomFilter.h" +#include CChannelSetting::CChannelSetting(QWidget *parent) : QWidget(parent), @@ -18,6 +19,8 @@ CChannelSetting::CChannelSetting(QWidget *parent) : ui->RPMComBox->setView(new QListView()); ui->pairChannelComBox->setView(new QListView()); ui->channelTypeCombox->setView(new QListView()); + ui->comboBox_sensorICP_2->setView(new QListView()); + ui->comboBox_sensorType->setView(new QListView()); ui->tabWidget->tabBar()->hide(); QRegExp exp("[0-9\\.-]+$"); @@ -34,8 +37,8 @@ CChannelSetting::CChannelSetting(QWidget *parent) : ui->lineEdit_analyseRate->setValidator(Validator); ui->lineEdit_RateRatio->setValidator(Validator); - ui->lineEdit_envelopeLowpassband->setValidator(Validator); - ui->lineEdit_envelopeHighpassband->setValidator(Validator); + //ui->lineEdit_envelopeLowpassband->setValidator(Validator); + //ui->lineEdit_envelopeHighpassband->setValidator(Validator); ui->lineEdit_sensorLocationInDegree->setValidator(Validator); ui->lineEdit_sensor1xPhaseRunout->setValidator(Validator); ui->lineEdit_sensor1xAmplitudeRunout->setValidator(Validator); @@ -82,10 +85,14 @@ CChannelSetting::CChannelSetting(QWidget *parent) : ui->comboBox_tachAutoTach->addItems(m_itemList); ui->comboBox_samplingRate_2->addItems(strListFs); ui->comboBox_sensorRangeCheck_2->addItems(m_itemList); + setAttribute(Qt::WA_DeleteOnClose);//使能析构函数调用 + } CChannelSetting::~CChannelSetting() { + qDebug() << "~CChannelSetting" << endl; + emit ChannelSettingClose_sg(); delete ui; } @@ -237,9 +244,9 @@ void CChannelSetting::displayChannelSetting() // ui->comboBox_samplingRate->setCurrentText("16kHz"); QString envelopeLowpassband = QString("%1").arg(channelSetting.envelopeLowpassband); - ui->lineEdit_envelopeLowpassband->setText(envelopeLowpassband); + //ui->lineEdit_envelopeLowpassband->setText(envelopeLowpassband); QString envelopeHighpassband = QString("%1").arg(channelSetting.envelopeHighpassband); - ui->lineEdit_envelopeHighpassband->setText(envelopeHighpassband); + //ui->lineEdit_envelopeHighpassband->setText(envelopeHighpassband); QString sensorLocationInDegree = QString("%1").arg(channelSetting.sensorLocationInDegree); ui->lineEdit_sensorLocationInDegree->setText(sensorLocationInDegree); @@ -458,8 +465,8 @@ void CChannelSetting::PushData() channelSetting.sensor1xPhaseRunout = ui->lineEdit_sensor1xPhaseRunout->text(); channelSetting.sensor1xAmplitudeRunout = ui->lineEdit_sensor1xAmplitudeRunout->text(); - channelSetting.envelopeHighpassband = ui->lineEdit_envelopeHighpassband->text().toDouble(); - channelSetting.envelopeLowpassband = ui->lineEdit_envelopeLowpassband->text().toDouble(); + //channelSetting.envelopeHighpassband = ui->lineEdit_envelopeHighpassband->text().toDouble(); + //channelSetting.envelopeLowpassband = ui->lineEdit_envelopeLowpassband->text().toDouble(); channelSetting.sensorTypes = ui->comboBox_sensorType->currentText(); if(ui->comboBox_bearingStartPosition->currentText() == "下"){ @@ -570,8 +577,8 @@ void CChannelSetting::on_channelTypeCombox_currentTextChanged(const QString &arg // ui->comboBox_coupling->clear(); // ui->comboBox_coupling->addItem("AC"); // ui->comboBox_coupling->addItem("DC"); - ui->lineEdit_envelopeLowpassband->setText("10"); - ui->lineEdit_envelopeHighpassband->setText("3500"); + //ui->lineEdit_envelopeLowpassband->setText("10"); + //ui->lineEdit_envelopeHighpassband->setText("3500"); ui->lineEdit_sensorRange->setText("2032"); }else if(arg1 == "速度"){ @@ -595,8 +602,8 @@ void CChannelSetting::on_channelTypeCombox_currentTextChanged(const QString &arg ui->comboBox_coupling->clear(); ui->comboBox_coupling->addItem("AC"); ui->comboBox_coupling->addItem("DC"); - ui->lineEdit_envelopeLowpassband->setText("4.5"); - ui->lineEdit_envelopeHighpassband->setText("5000"); + //ui->lineEdit_envelopeLowpassband->setText("4.5"); + //ui->lineEdit_envelopeHighpassband->setText("5000"); ui->pairChannelComBox->setCurrentText("- -"); ui->RPMComBox->setCurrentText("- -"); ui->lineEdit_sensorRange->setText("2054"); @@ -622,8 +629,8 @@ void CChannelSetting::on_channelTypeCombox_currentTextChanged(const QString &arg ui->comboBox_coupling->clear(); ui->comboBox_coupling->addItem("AC"); ui->comboBox_coupling->addItem("DC"); - ui->lineEdit_envelopeLowpassband->setText("350"); - ui->lineEdit_envelopeHighpassband->setText("12000"); + //ui->lineEdit_envelopeLowpassband->setText("350"); + //ui->lineEdit_envelopeHighpassband->setText("12000"); ui->pairChannelComBox->setCurrentText("- -"); ui->RPMComBox->setCurrentText("- -"); ui->lineEdit_sensorRange->setText("2000"); @@ -650,8 +657,8 @@ void CChannelSetting::on_channelTypeCombox_currentTextChanged(const QString &arg ui->comboBox_coupling->clear(); ui->comboBox_coupling->addItem("DC"); ui->comboBox_coupling->addItem("AC"); - ui->lineEdit_envelopeLowpassband->setText("1"); - ui->lineEdit_envelopeHighpassband->setText("4000"); + //ui->lineEdit_envelopeLowpassband->setText("1"); + //ui->lineEdit_envelopeHighpassband->setText("4000"); ui->pairChannelComBox->setCurrentText("- -"); ui->RPMComBox->setCurrentText("- -"); ui->lineEdit_sensorRange->setText("2000"); @@ -679,8 +686,8 @@ void CChannelSetting::on_channelTypeCombox_currentTextChanged(const QString &arg ui->comboBox_coupling->clear(); ui->comboBox_coupling->addItem("DC"); ui->comboBox_coupling->addItem("AC"); - ui->lineEdit_envelopeLowpassband->setText("1"); - ui->lineEdit_envelopeHighpassband->setText("4000"); + //ui->lineEdit_envelopeLowpassband->setText("1"); + //ui->lineEdit_envelopeHighpassband->setText("4000"); ui->pairChannelComBox->setCurrentText("- -"); ui->RPMComBox->setCurrentText("- -"); ui->lineEdit_sensorRange->setText("2"); @@ -705,8 +712,8 @@ void CChannelSetting::on_channelTypeCombox_currentTextChanged(const QString &arg ui->comboBox_coupling->clear(); ui->comboBox_coupling->addItem("DC"); ui->comboBox_coupling->addItem("AC"); - ui->lineEdit_envelopeLowpassband->setText("0"); - ui->lineEdit_envelopeHighpassband->setText("5000"); + //ui->lineEdit_envelopeLowpassband->setText("0"); + //ui->lineEdit_envelopeHighpassband->setText("5000"); ui->pairChannelComBox->setCurrentText("- -"); ui->RPMComBox->setCurrentText("- -"); ui->lineEdit_sensorRange->setText("2000"); @@ -832,3 +839,18 @@ void CChannelSetting::on_lineEdit_engineeringUnit_editingFinished() ui->label_unit2->setText(str); } + +void CChannelSetting::on_pushButton_CustomFilter_clicked() +{ + + CustomFilter *pCustomFilter = new CustomFilter(); + pCustomFilter->channel_ID = channelSetting.channelId; + if(ui->channelTypeCombox->currentText()=="径向振动位移") + pCustomFilter->vibrate_channel = 1; + else + pCustomFilter->vibrate_channel = 0; + pCustomFilter->setWindowModality(Qt::ApplicationModal); + pCustomFilter->show(); + pCustomFilter->getfilterInfo(); +} + diff --git a/ChannelSetting.h b/ChannelSetting.h index 8bb6473..eedab47 100644 --- a/ChannelSetting.h +++ b/ChannelSetting.h @@ -40,6 +40,8 @@ private slots: void on_lineEdit_engineeringUnit_editingFinished(); + void on_pushButton_CustomFilter_clicked(); + public slots: void slotSetChannelData(QStringList&); private: @@ -50,7 +52,7 @@ private: signals: void sgSetChannelData(ChannelSetting); - + void ChannelSettingClose_sg(); }; #endif // CHANNELSETTING_H diff --git a/CharacteristicList.cpp b/CharacteristicList.cpp index f707473..e294df8 100644 --- a/CharacteristicList.cpp +++ b/CharacteristicList.cpp @@ -30,7 +30,7 @@ void CCharacteristicList::timerEvent(QTimerEvent *ev) } void CCharacteristicList::InitTable() { - headerStr = QObject::tr("通道名称,单位,通频值,峰峰值,平均工作位置,间隙,安装角度,状态"); + headerStr = QObject::tr("通道名称,单位,通频值,峰峰值,反时限危险值,反时限报警值,平均工作位置,间隙,安装角度,状态"); ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); model = new QStandardItemModel(ui->tableView); ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows); //选中行 @@ -41,7 +41,9 @@ void CCharacteristicList::InitTable() ui->tableView->setAlternatingRowColors(true); ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->tableView->setColumnWidth(0, 300); - ui->tableView->setColumnWidth(4, 200); + ui->tableView->setColumnWidth(4, 160); + ui->tableView->setColumnWidth(5, 160); + ui->tableView->setColumnWidth(6, 200); // for (int i = 0;i < g_ChannelView.size(); i++) // { @@ -83,10 +85,12 @@ void CCharacteristicList::DisPlayCharacteristic() model->setData(model->index(j,2,QModelIndex()),QString::number(g_Charateristic[j].DCValues,'f',g_Charateristic[j].ChUnitDot)); } model->setData(model->index(j,3,QModelIndex()),QString::number(g_Charateristic[j].DiagnosisPk2Pk,'f',g_Charateristic[j].ChUnitDot)); - model->setData(model->index(j,4,QModelIndex()),g_Charateristic[j].xFullScalePosition); - model->setData(model->index(j,5,QModelIndex()),QString::number(g_Charateristic[j].Gap,'f',g_Charateristic[j].ChUnitDot)); - model->setData(model->index(j,6,QModelIndex()),g_Charateristic[j].ZeroScalePosition); - model->setData(model->index(j,7,QModelIndex()),g_Charateristic[j].SensorStatus); + model->setData(model->index(j,4,QModelIndex()),g_Charateristic[j].InvertDanger); + model->setData(model->index(j,5,QModelIndex()),g_Charateristic[j].InvertAlarm); + model->setData(model->index(j,6,QModelIndex()),g_Charateristic[j].xFullScalePosition); + model->setData(model->index(j,7,QModelIndex()),QString::number(g_Charateristic[j].Gap,'f',g_Charateristic[j].ChUnitDot)); + model->setData(model->index(j,8,QModelIndex()),g_Charateristic[j].ZeroScalePosition); + model->setData(model->index(j,9,QModelIndex()),g_Charateristic[j].SensorStatus); } } } diff --git a/Configuration.cpp b/Configuration.cpp index 4f7dc6a..d511f47 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -153,6 +153,10 @@ void CConfiguration::Init() strStaticData = "峰值"; else if(strList[0] == "MonitorPk2Pk") strStaticData = "监测保护峰峰值"; + else if(strList[0] == "InvertDanger") + strStaticData = "反时限危险值"; + else if(strList[0] == "InvertAlarm") + strStaticData = "反时限警报值"; if(xAlertOverEnabled == 1){ item = new QStandardItem(QString(channelName + "-" + strStaticData + "-" + "高于警报值")); @@ -246,6 +250,10 @@ void CConfiguration::slotDeleteItem() }else{ QStandardItem* parantitem = item->parent(); + if(parantitem == NULL){ + model_Relay->removeRow(curIndex.row(),curIndex.parent()); + return; + } QString paranNodeText = parantitem->text(); if(paranNodeText.contains("logicAND")){ @@ -455,6 +463,7 @@ QJsonObject CConfiguration::SelectChannel(int channelNo) ConfiguraitonsObj["ChannelId"] = g_ChannelBaseInfo[i].channelID; ConfiguraitonsObj["ChannelName"] = g_ChannelBaseInfo[i].channelName; ConfiguraitonsObj["ChannelNoInBoard"] = g_ChannelBaseInfo[i].channelNoInBoard; + ConfiguraitonsObj["DelaySeconds"] = ui->lineEdit_delay->text(); ConfiguraitonsObj["ChannelOperate"] = -1; } } @@ -888,6 +897,7 @@ void CConfiguration::ViewRelay(int ChannelNoInBoard) ui->lineEdit_2->setText(strSecondDelaySeconds); for (int j = 0;j < tempArray.size() ;j++ ) { if(tempArray.at(j)["ChannelNoInBoard"] == ChannelNoInBoard){ + ui->lineEdit_delay->setText(tempArray.at(j)["DelaySeconds"].toString()); QJsonArray tempArray2 = tempArray.at(j)["logicExpress"].toArray(); for (int k = 0; k < tempArray2.size(); k++) { QJsonObject tempObj2 = tempArray2[k].toObject(); @@ -1091,6 +1101,7 @@ void CConfiguration::on_radioButton_1_clicked() { m_curentRLY = 3; + ui->label_3->setText(ui->radioButton_1->text()+":"); ViewRelay(3); } @@ -1098,6 +1109,7 @@ void CConfiguration::on_radioButton_1_clicked() void CConfiguration::on_radioButton_2_clicked() { m_curentRLY = 4; + ui->label_3->setText(ui->radioButton_2->text()+":"); ViewRelay(4); } @@ -1105,6 +1117,7 @@ void CConfiguration::on_radioButton_2_clicked() void CConfiguration::on_radioButton_3_clicked() { m_curentRLY = 5; + ui->label_3->setText(ui->radioButton_3->text()+":"); ViewRelay(5); } @@ -1112,6 +1125,7 @@ void CConfiguration::on_radioButton_3_clicked() void CConfiguration::on_radioButton_4_clicked() { m_curentRLY = 6; + ui->label_3->setText(ui->radioButton_4->text()+":"); ViewRelay(6); } @@ -1119,6 +1133,7 @@ void CConfiguration::on_radioButton_4_clicked() void CConfiguration::on_radioButton_5_clicked() { m_curentRLY = 7; + ui->label_3->setText(ui->radioButton_5->text()+":"); ViewRelay(7); } @@ -1126,6 +1141,7 @@ void CConfiguration::on_radioButton_5_clicked() void CConfiguration::on_radioButton_6_clicked() { m_curentRLY = 8; + ui->label_3->setText(ui->radioButton_6->text()+":"); ViewRelay(8); } @@ -1133,6 +1149,7 @@ void CConfiguration::on_radioButton_6_clicked() void CConfiguration::on_radioButton_8_clicked() { m_curentRLY = 10; + ui->label_3->setText(ui->radioButton_8->text()+":"); ViewRelay(10); } @@ -1140,6 +1157,7 @@ void CConfiguration::on_radioButton_8_clicked() void CConfiguration::on_radioButton_7_clicked() { m_curentRLY = 9; + ui->label_3->setText(ui->radioButton_7->text()+":"); ViewRelay(9); } @@ -1147,6 +1165,7 @@ void CConfiguration::on_radioButton_7_clicked() void CConfiguration::on_radioButton_9_clicked() { m_curentRLY = 11; + ui->label_3->setText(ui->radioButton_9->text()+":"); ViewRelay(11); } @@ -1154,6 +1173,7 @@ void CConfiguration::on_radioButton_9_clicked() void CConfiguration::on_radioButton_10_clicked() { m_curentRLY = 12; + ui->label_3->setText(ui->radioButton_10->text()+":"); ViewRelay(12); } diff --git a/Configuration.ui b/Configuration.ui index c97caa2..0f8d184 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -392,7 +392,7 @@ color: rgb(27, 30, 35); - 第二层延时: + 工况延时: @@ -437,6 +437,45 @@ color: rgb(27, 30, 35); + + + + + 70 + 0 + + + + - - + + + + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + 0 + + + + + + + S + + + diff --git a/CustomFilter.cpp b/CustomFilter.cpp new file mode 100644 index 0000000..1212707 --- /dev/null +++ b/CustomFilter.cpp @@ -0,0 +1,206 @@ +#include "CustomFilter.h" +#include "ui_CustomFilter.h" +#include +#include "QMyTableViewBtnDelegate.h" +#include "NetMgr.h" +#include + +CustomFilter::CustomFilter(QWidget *parent) : + QWidget(parent), + ui(new Ui::CustomFilter) +{ + ui->setupUi(this); + + headerStr = QObject::tr("频率(Hz),衰减位移量(um)"); + + model = new QStandardItemModel(ui->tableView); + ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows); //选中行 + QStringList headerList = headerStr.split(","); + model->setHorizontalHeaderLabels(headerList); + model->setColumnCount(headerList.size()); + ui->tableView->setModel(model); + ui->tableView->setAlternatingRowColors(true); + ui->tableView->setColumnWidth(1, 150); + + ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); + + + + ui->comboBox_open->setView(new QListView()); + ui->comboBox_open->addItem("否"); + ui->comboBox_open->addItem("是"); + connect(g_NetMgr,SIGNAL(sigNetMgr(QString, const QVariant&)), this, SLOT(slotNetMgr(QString,const QVariant&))); + connect(ui->comboBox_open,SIGNAL(currentIndexChanged(const QString &)),this,SLOT(comboBox_open_currentTextChanged(const QString&))); + setAttribute(Qt::WA_DeleteOnClose); +} + +CustomFilter::~CustomFilter() +{ + qDebug() << "~CustomFilter()" << endl; + disconnect(g_NetMgr,SIGNAL(sigNetMgr(QString, const QVariant&)), this, SLOT(slotNetMgr(QString,const QVariant&))); + delete ui; +} + +void CustomFilter::on_pushButton_Add_clicked() +{ + int rowCount = model->rowCount(); + model->setRowCount(rowCount+1); + model->setData(model->index(rowCount,0,QModelIndex()),""); + model->setData(model->index(rowCount,1,QModelIndex()),""); +} + + +void CustomFilter::on_pushButton_Del_clicked() +{ + int rowCount = model->rowCount(); + int row = ui->tableView->currentIndex().row();//获得当前行索引 + if(rowCount < 1 || row == -1){ + QMessageBox::warning(this, QStringLiteral("提示"), QStringLiteral("请先选择一条记录!")); + return; + } + model->removeRow(row); +} + + +void CustomFilter::on_pushButton_Submit_clicked() +{ + int rowCount = model->rowCount(); + QJsonObject sendData; + sendData["cmd"] = "99"; + sendData["chan_id"] = channel_ID; + sendData["num"] = rowCount; + QJsonArray range; + for(int i = 0; i < rowCount;i++){ + QModelIndex index = model->index(i,0); + QString strData = model->data(index).toString(); + range.append(strData.toInt()); + index = model->index(i,1); + strData = model->data(index).toString(); + range.append(strData.toInt()); + } + sendData["range"] = range; + QNetworkRequest req; + QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP); + req.setUrl(sUrl); + g_NetMgr->PostJson(req,sendData); + + bool type ; + if(ui->comboBox_open->currentText() == "是"){ + type = true; + } + if(ui->comboBox_open->currentText() == "否"){ + type = false; + } + + if(ui->doubleSpinBox_start->text().toDouble() >= ui->doubleSpinBox_stop->text().toDouble()){ + QMessageBox::warning(this, QStringLiteral("提示"), QStringLiteral("频率下限设置错误!")); + return; + } + QJsonObject sendData2; + sendData2["cmd"] = "95"; + sendData2["chan_id"] = channel_ID; + sendData2["open"] = type; + sendData2["start"] = ui->doubleSpinBox_start->text().toDouble(); + sendData2["stop"] = ui->doubleSpinBox_stop->text().toDouble(); + req.setUrl(sUrl); + g_NetMgr->PostJson(req,sendData2); + this->close(); +} + +void CustomFilter::slotNetMgr(QString sAddr, const QVariant &msg) +{ + QJsonObject objec = msg.value(); + if(objec.contains("cmd")) + { + QJsonValue arrays_value = objec.take("cmd"); + qDebug() << "arrays_value" << arrays_value << endl; + bool Status = objec.take("success").toBool(); + QString strMessage = objec.take("message").toString(); + if(!Status){ + QMessageBox::information(NULL, QStringLiteral("提示"), strMessage); + return; + } + if(arrays_value.toString() == "94"){ + + int Statusfilter = objec.take("status").toInt(); + ui->doubleSpinBox_start->setValue(objec.take("start").toDouble()); + ui->doubleSpinBox_stop->setValue(objec.take("stop").toDouble()); + + if(Statusfilter){ + ui->comboBox_open->setCurrentText("是"); + }else if(!Statusfilter){ + ui->comboBox_open->setCurrentText("否"); + ui->doubleSpinBox_start->setEnabled(false); + ui->doubleSpinBox_stop->setEnabled(false); + } + QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("获取成功!")); + }else if(arrays_value.toString() == "98"){ + int num = objec["num"].toInt(); + int j = 0; + model->setRowCount(num); + QJsonArray range = objec["range"].toArray(); + for (int i = 0; i < num; i++) { + model->setData(model->index(i,0,QModelIndex()),range[j].toInt()); + j++; + model->setData(model->index(i,1,QModelIndex()),range[j].toInt()); + j++; + } + QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("获取成功!")); + }else if(arrays_value.toString() == "112"){ + int Statusfilter = objec.take("status").toInt(); + ui->doubleSpinBox_start->setValue(objec.take("start").toDouble()); + ui->doubleSpinBox_stop->setValue(objec.take("stop").toDouble()); + + if(Statusfilter){ + ui->comboBox_open->setCurrentText("是"); + }else if(!Statusfilter){ + ui->comboBox_open->setCurrentText("否"); + ui->doubleSpinBox_start->setEnabled(false); + ui->doubleSpinBox_stop->setEnabled(false); + } + int num = objec["num"].toInt(); + int j = 0; + model->setRowCount(num); + QJsonArray range = objec["range"].toArray(); + for (int i = 0; i < num; i++) { + model->setData(model->index(i,0,QModelIndex()),range[j].toInt()); + j++; + model->setData(model->index(i,1,QModelIndex()),range[j].toInt()); + j++; + } + QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("获取成功!")); + }else if(arrays_value.toString() == "95" || arrays_value.toString() == "99"){ + QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("设置成功!")); + } + } + if(!vibrate_channel){ + ui->comboBox_open->setEnabled(false); + ui->doubleSpinBox_start->setEnabled(false); + ui->doubleSpinBox_stop->setEnabled(false); + } + +} + +void CustomFilter::getfilterInfo() +{ + + QJsonObject sendData; + sendData["cmd"] = "112"; + sendData["chan_id"] = channel_ID; + QNetworkRequest req; + QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP); + req.setUrl(sUrl); + g_NetMgr->PostJson(req,sendData); + +} + +void CustomFilter::comboBox_open_currentTextChanged(const QString &str) +{ + if(str == "否"){ + ui->doubleSpinBox_start->setEnabled(false); + ui->doubleSpinBox_stop->setEnabled(false); + }else if(str == "是"){ + ui->doubleSpinBox_start->setEnabled(true); + ui->doubleSpinBox_stop->setEnabled(true); + } +} diff --git a/CustomFilter.h b/CustomFilter.h new file mode 100644 index 0000000..09ebe83 --- /dev/null +++ b/CustomFilter.h @@ -0,0 +1,39 @@ +#ifndef CUSTOMFILTER_H +#define CUSTOMFILTER_H + +#include +#include //数据模型类 +#include "TableHeaderView.h" +#include "global.h" + +namespace Ui { +class CustomFilter; +} + +class CustomFilter : public QWidget +{ + Q_OBJECT + +public: + explicit CustomFilter(QWidget *parent = nullptr); + ~CustomFilter(); + QString channel_ID; + int vibrate_channel; + + void getfilterInfo(); +private slots: + void on_pushButton_Add_clicked(); + + void on_pushButton_Del_clicked(); + + void on_pushButton_Submit_clicked(); + void slotNetMgr(QString sAddr,const QVariant& msg); + void comboBox_open_currentTextChanged(const QString &str); +private: + Ui::CustomFilter *ui; + TableHeaderView *myHeader; + QStandardItemModel *model; + QString headerStr ; +}; + +#endif // CUSTOMFILTER_H diff --git a/CustomFilter.ui b/CustomFilter.ui new file mode 100644 index 0000000..90acac7 --- /dev/null +++ b/CustomFilter.ui @@ -0,0 +1,328 @@ + + + CustomFilter + + + + 0 + 0 + 716 + 480 + + + + 滤波配置 + + + font: 10pt "黑体"; +color: rgb(27, 30, 35); + + + + + + + 0 + 100 + + + + + 16777215 + 100 + + + + + + + 带通滤波 + + + + + + + + Qt::Horizontal + + + + 32 + 33 + + + + + + + + 是否开启 + + + + + + + + 50 + 0 + + + + + + + + Qt::Horizontal + + + + 32 + 33 + + + + + + + + + + 频率下限 + + + + + + + 999999.989999999990687 + + + + + + + + + Hz + + + + + + + Qt::Horizontal + + + + 32 + 33 + + + + + + + + + + 频率上限 + + + + + + + 2 + + + 0.000000000000000 + + + 999999.989999999990687 + + + + + + + + + Hz + + + + + + + Qt::Horizontal + + + + 32 + 33 + + + + + + + + + + + + + + + + + + + 自定义滤波设置 + + + + + + + + + false + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 136 + 20 + + + + + + + + + 96 + 28 + + + + + 96 + 28 + + + + #pushButton_Add { border-image: url(:/image/Btn/normal_Btn.png); + color:#1f5188 } +#pushButton_Add:hover { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_Add:pressed { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_Add:checked { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} + + + 新增 + + + + + + + + 96 + 28 + + + + + 96 + 28 + + + + #pushButton_Del { border-image: url(:/image/Btn/normal_Btn.png); + color:#1f5188 } +#pushButton_Del:hover { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_Del:pressed { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_Del:checked { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} + + + 删除 + + + + + + + + 96 + 28 + + + + + 96 + 28 + + + + #pushButton_Submit { border-image: url(:/image/Btn/normal_Btn.png); + color:#1f5188 } +#pushButton_Submit:hover { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_Submit:pressed { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_Submit:checked { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} + + + 提交 + + + + + + + Qt::Horizontal + + + + 136 + 20 + + + + + + + + + + + + diff --git a/DataWatch3500_GUI.pro b/DataWatch3500_GUI.pro index 26c89ed..2370239 100644 --- a/DataWatch3500_GUI.pro +++ b/DataWatch3500_GUI.pro @@ -29,14 +29,17 @@ CONFIG += c++11 SOURCES += \ AddChannel.cpp \ AlarmDetails.cpp \ + Backup.cpp \ CharacteristicList.cpp \ Configuration.cpp \ CopyChannelSetting.cpp \ CopyDatFile.cpp \ + CustomFilter.cpp \ DIO_Board.cpp \ DataGraphView.cpp \ FileServerConfig.cpp \ HistoryAlarm.cpp \ + ImportConfig.cpp \ Mqttclient.cpp \ MyTreeView.cpp \ NTPServerConfig.cpp \ @@ -79,14 +82,17 @@ SOURCES += \ HEADERS += \ AddChannel.h \ AlarmDetails.h \ + Backup.h \ CharacteristicList.h \ Configuration.h \ CopyChannelSetting.h \ CopyDatFile.h \ + CustomFilter.h \ DIO_Board.h \ DataGraphView.h \ FileServerConfig.h \ HistoryAlarm.h \ + ImportConfig.h \ Mqttclient.h \ MyTreeView.h \ NTPServerConfig.h \ @@ -129,14 +135,18 @@ HEADERS += \ FORMS += \ AddChannel.ui \ AlarmDetails.ui \ + BackUp.ui \ + Backup.ui \ CharacteristicList.ui \ Configuration.ui \ CopyChannelSetting.ui \ CopyDatFile.ui \ + CustomFilter.ui \ DIO_Board.ui \ DataGraphView.ui \ FileServerConfig.ui \ HistoryAlarm.ui \ + ImportConfig.ui \ NTPServerConfig.ui \ OtherConfig.ui \ PSConfig.ui \ diff --git a/ImportConfig.cpp b/ImportConfig.cpp new file mode 100644 index 0000000..f945cc5 --- /dev/null +++ b/ImportConfig.cpp @@ -0,0 +1,246 @@ +#include "ImportConfig.h" +#include "ui_ImportConfig.h" +#include +#include +#include "sqlitedb.h" + +CImportConfig::CImportConfig(QWidget *parent) : + QWidget(parent), + ui(new Ui::CImportConfig) +{ + ui->setupUi(this); +} + +CImportConfig::~CImportConfig() +{ + delete ui; +} + +void CImportConfig::on_pushButton_importpath_clicked() +{ + QString dirpath = QFileDialog::getExistingDirectory(this, QStringLiteral("选择目录"), "./", QFileDialog::ShowDirsOnly); + if(dirpath.isEmpty()) dirpath = QDir::currentPath(); + ui->lineEdit_filepath->setText(dirpath + "/"); + import_path = dirpath; +} + + +void CImportConfig::on_pushButton_confirm_clicked() +{ + if(ui->lineEdit_filepath->text() == ""){ + QMessageBox::warning(this,tr("提示"),tr("请选择导入文件路径!")); + return; + } + QString copy_path = QCoreApplication::applicationDirPath() + "\\config\\copy\\"; + QDir copyDir(copy_path); + + // 创建目标文件夹 + if (!copyDir.mkpath(".")) { + qDebug() << "无法创建目标文件夹"; + return; + } + copyDirectory(import_path, copy_path); + + QFile fileMAC(copy_path+"macbackup"); + if (!fileMAC.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug() << "无法打开文件"; + return; + } + QTextStream in(&fileMAC); + QString oldMAC= ""; + while (!in.atEnd()) { + oldMAC = in.readLine(); + qDebug() << oldMAC; + } + fileMAC.close(); + + QFile sourceFile(copy_path + "config.db"); +// if (!sourceFile.copy(copy_path + "\\config.db")) { +// QMessageBox::question(NULL, "提示", "导入数据库失败!"); +// return; +// } + qDebug() << QSqlDatabase::drivers() << "\r\n"; + QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); + + db.setDatabaseName(copy_path + "config.db"); + if (!db.open()) + { + qDebug() << "Error: Failed to connect database." << database.lastError(); + return ; + } + + QString strSql = QString("update t_ChannelSetting SET channelId = '%1' || SUBSTR(channelId, 13),dataWatchNo='%2';").arg(MAC).arg(MAC); + ExeSqlData(strSql); + strSql = QString("update t_ChannelSetting SET pairChannelId = '%1' || SUBSTR(channelId, 13) where pairChannelId <> '' AND pairChannelId <> 'NONE' ;").arg(MAC); + ExeSqlData(strSql); + strSql = QString("update t_ChannelSetting SET speedRefChannelId = '%1' || SUBSTR(channelId, 13) where speedRefChannelId <> '' AND pairChannelId <> 'NONE';").arg(MAC); + ExeSqlData(strSql); + strSql = QString("update t_DeviceInfo SET MAC = '%1' ;").arg(MAC); + ExeSqlData(strSql); + strSql = QString("update t_TriggerConfig SET ChannelID = '%1' || SUBSTR(ChannelID, 13) ;").arg(MAC); + ExeSqlData(strSql); + strSql = QString("update t_WorkConditionChannels SET ChannelId = '%1' || SUBSTR(ChannelId, 13) where ChannelId <> '';").arg(MAC); + ExeSqlData(strSql); + strSql = QString("update t_WorkConditionRules SET ChannelId = '%1' || SUBSTR(ChannelId, 13) ;").arg(MAC); + ExeSqlData(strSql); + strSql = QString("update t_UnitConfiguration SET ChannelId = '%1' || SUBSTR(ChannelId, 13) ;").arg(MAC); + ExeSqlData(strSql); + + db.close(); + + QString fileName = copy_path + "Graph1.json"; + QString value; + QFile file(fileName); + file.open(QIODevice::ReadWrite | QIODevice::Text); + value = file.readAll(); + file.resize(0); + file.write(value.toUtf8()); + value.replace(oldMAC,MAC); + value = file.readAll(); + file.close(); + + + + QString fileName2 = copy_path + "Graph2.json"; + QFile file2(fileName2); + file2.open(QIODevice::ReadWrite | QIODevice::Text); + value = file2.readAll(); + file2.resize(0); + value.replace(oldMAC,MAC); + file2.write(value.toUtf8()); + file2.close(); + + QString ChannelSettings = copy_path + "ChannelSettings.json"; + QFile fileChannelSettings(ChannelSettings); + fileChannelSettings.open(QIODevice::ReadWrite | QIODevice::Text); + value = fileChannelSettings.readAll(); + fileChannelSettings.resize(0); + value.replace(oldMAC,MAC); + fileChannelSettings.write(value.toUtf8()); + fileChannelSettings.close(); + + QString UnitConfigurations = copy_path + "UnitConfigurations.json"; + QFile fileUnitConfigurations(UnitConfigurations); + fileUnitConfigurations.open(QIODevice::ReadWrite | QIODevice::Text); + value = fileUnitConfigurations.readAll(); + fileUnitConfigurations.resize(0); + value.replace(oldMAC,MAC); + fileUnitConfigurations.write(value.toUtf8()); + fileUnitConfigurations.close(); + + + QString TriggerSettings = copy_path + "TriggerSettings.json"; + QFile fileTriggerSettings(TriggerSettings); + fileTriggerSettings.open(QIODevice::ReadWrite | QIODevice::Text); + value = fileTriggerSettings.readAll(); + fileTriggerSettings.resize(0); + value.replace(oldMAC,MAC); + fileTriggerSettings.write(value.toUtf8()); + fileTriggerSettings.close(); + + + copyFile(QCoreApplication::applicationDirPath() + "\\config\\" + "UnitWorkConditionsInfo.json", copy_path + "UnitWorkConditionsInfo.json"); + copyFile(QCoreApplication::applicationDirPath() + "\\config\\" + "UnitParameters.json", copy_path + "UnitParameters.json"); + copyFile(QCoreApplication::applicationDirPath() + "\\config\\" + "ServerConfig.json", copy_path + "ServerConfig.json"); + copyFile(QCoreApplication::applicationDirPath() + "\\config\\" + "NetWorkConfig.json", copy_path + "NetWorkConfig.json"); + copyFile(QCoreApplication::applicationDirPath() + "\\config\\" + "ModbusConfig.json", copy_path + "ModbusConfig.json"); + copyFile(QCoreApplication::applicationDirPath() + "\\config\\" + "TcpConfig.json", copy_path + "TcpConfig.json"); + copyFile(QCoreApplication::applicationDirPath() + "\\config\\" + "UnitBoardsInfo.json", copy_path + "UnitBoardsInfo.json"); + copyFile(QCoreApplication::applicationDirPath() + "\\config\\" + "ZeroDrift.json", copy_path + "ZeroDrift.json"); + copyFile(QCoreApplication::applicationDirPath() + "\\config\\" + "UnitBoardsInfo.json", copy_path + "UnitBoardsInfo.json"); + copyFile(QCoreApplication::applicationDirPath() + "\\config\\" + "ConfidenceDegree.json", copy_path + "ConfidenceDegree.json"); + copyFile(QCoreApplication::applicationDirPath() + "\\config\\" + "TriggerConfig.json", copy_path + "TriggerConfig.json"); + copyFile(QCoreApplication::applicationDirPath() + "\\config\\" + "config.ini", copy_path + "config.ini"); + + qApp->exit(0); + g_SqliteDB->CloseDataBase(); + copyDirectory(copy_path, QCoreApplication::applicationDirPath() + "\\config\\"); + QMessageBox::information(this,tr("导入"),tr("导入成功")); + // 如果目标文件夹已存在,则删除它 + QDir copyDir2(copy_path); + if (copyDir2.exists()) { + copyDir2.removeRecursively(); + } + + QProcess::startDetached(qApp->applicationFilePath(), QStringList()); +} + +int CImportConfig::ExeSqlData(QString& strSql) +{ + QSqlQuery sql_query; + int iRet = -1; + qDebug() << "strSql" << strSql << endl; + if(!sql_query.exec(strSql)) + { + qDebug() << sql_query.lastError(); + } + else + { + while(sql_query.next()) + { + iRet = sql_query.value(0).toInt(); + } + } + return iRet; +} + +bool CImportConfig::copyFile(const QString &sourceFile, const QString &destinationFile) +{ + QFile srcFile(sourceFile); + QFile dstFile(destinationFile); + + if (!srcFile.exists()) { + qDebug() << "Source file does not exist:" << sourceFile; + return false; + } + + if (!srcFile.open(QIODevice::ReadOnly)) { + qDebug() << "Unable to open source file for reading:" << sourceFile; + return false; + } + + if (!dstFile.open(QIODevice::WriteOnly)) { + srcFile.close(); + qDebug() << "Unable to open destination file for writing:" << destinationFile; + return false; + } + + dstFile.write(srcFile.readAll()); + srcFile.close(); + dstFile.close(); + return true; +} + +bool CImportConfig::copyDirectory(const QString &sourceDir, const QString &destinationDir) { + QDir srcDir(sourceDir); + QDir destDir(destinationDir); + + // 复制文件 + foreach (const QFileInfo &fileInfo, srcDir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot)) { + QString fileName = fileInfo.fileName(); + QString srcFilePath = srcDir.absoluteFilePath(fileName); + QString destFilePath = destDir.absoluteFilePath(fileName); + + if (fileInfo.isDir()) { + // 递归复制子文件夹 + if (!copyDirectory(srcFilePath, destFilePath)) { + return false; + } + } else { + // 复制文件 + QFile dest(destFilePath); + if (dest.exists()) { + bool re = dest.remove(); // 如果目标文件存在,先删除它 + if(!re){ + qDebug() << "删除失败 "< +#include +#include +#include +#include "global.h" +namespace Ui { +class CImportConfig; +} + +class CImportConfig : public QWidget +{ + Q_OBJECT + +public: + explicit CImportConfig(QWidget *parent = nullptr); + ~CImportConfig(); + +private slots: + void on_pushButton_importpath_clicked(); + + void on_pushButton_confirm_clicked(); + +private: + Ui::CImportConfig *ui; + QString import_path; + QSqlDatabase database; + int ExeSqlData(QString& strSql); + bool copyFile(const QString &sourceFile, const QString &destinationFile); + bool copyDirectory(const QString &sourceDir, const QString &destinationDir); +}; + +#endif // IMPORTCONFIG_H diff --git a/ImportConfig.ui b/ImportConfig.ui new file mode 100644 index 0000000..a04dd74 --- /dev/null +++ b/ImportConfig.ui @@ -0,0 +1,150 @@ + + + CImportConfig + + + + 0 + 0 + 713 + 168 + + + + 配置导入 + + + font: 10pt "黑体"; +color: rgb(27, 30, 35); + + + + + + + + + 请填写导入信息 + + + Qt::AlignCenter + + + + + + + + + + + + + + + + + false + + + + + + + + 96 + 28 + + + + + 96 + 28 + + + + #pushButton_importpath { border-image: url(:/image/Btn/normal_Btn.png); + color:#1f5188 } +#pushButton_importpath:hover { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_importpath:pressed { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_importpath:checked { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} + + + 导入路径 + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 96 + 28 + + + + + 96 + 28 + + + + #pushButton_confirm { border-image: url(:/image/Btn/normal_Btn.png); + color:#1f5188 } +#pushButton_confirm:hover { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_confirm:pressed { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_confirm:checked { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} + + + 确认 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + diff --git a/TerminalInfo.cpp b/TerminalInfo.cpp index 3be50d8..8a34d10 100644 --- a/TerminalInfo.cpp +++ b/TerminalInfo.cpp @@ -4,6 +4,8 @@ #include #include "ftpclient.h" #include "CopyDatFile.h" +#include "Backup.h" +#include "ImportConfig.h" CTerminalInfo::CTerminalInfo(QWidget *parent) : QWidget(parent), @@ -209,7 +211,7 @@ void CTerminalInfo::slotNetMgr(QString sAddr, const QVariant &msg) ui->label_Version->setText(sysObj["softVersion"].toString()); ui->label_Type->setText(sysObj["deviceType"].toString()); ui->label_SerialNo->setText(sysObj["serialNumber"].toString()); - ui->label_Address->setText(sysObj["dataWatchIpAddress"].toString()); + //ui->label_Address->setText(sysObj["dataWatchIpAddress"].toString()); } } } @@ -305,3 +307,22 @@ void CTerminalInfo::on_pushButtonCopy_clicked() copyDatDialog->show(); } +void CTerminalInfo::on_pushButton_export_clicked() +{ + CBackup *BackupDialog = new CBackup(); + BackupDialog->setWindowModality(Qt::ApplicationModal); + BackupDialog->setAttribute(Qt::WA_DeleteOnClose); + BackupDialog->setWindowFlags(BackupDialog->windowFlags() &~ Qt::WindowMaximizeButtonHint); + BackupDialog->show(); +} + + +void CTerminalInfo::on_pushButton_import_clicked() +{ + CImportConfig *ImportConfigDialog = new CImportConfig(); + ImportConfigDialog->setWindowModality(Qt::ApplicationModal); + ImportConfigDialog->setAttribute(Qt::WA_DeleteOnClose); + ImportConfigDialog->setWindowFlags(ImportConfigDialog->windowFlags() &~ Qt::WindowMaximizeButtonHint); + ImportConfigDialog->show(); +} + diff --git a/TerminalInfo.h b/TerminalInfo.h index 64ca4ae..5d8222b 100644 --- a/TerminalInfo.h +++ b/TerminalInfo.h @@ -34,6 +34,10 @@ private slots: void on_pushButtonCopy_clicked(); + void on_pushButton_export_clicked(); + + void on_pushButton_import_clicked(); + private: Ui::CTerminalInfo *ui; diff --git a/TerminalInfo.ui b/TerminalInfo.ui index ed5fa58..0a590d4 100644 --- a/TerminalInfo.ui +++ b/TerminalInfo.ui @@ -524,7 +524,7 @@ - 终端地址: + 数据配置: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -532,12 +532,76 @@ - + + + + 96 + 28 + + + + + 96 + 28 + + + + #pushButton_import { border-image: url(:/image/Btn/normal_Btn.png); + color:#1f5188 } +#pushButton_import:hover { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_import:pressed { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_import:checked { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} + - - - + 导入 + + + + + 96 + 28 + + + + + 96 + 28 + + + + #pushButton_export { border-image: url(:/image/Btn/normal_Btn.png); + color:#1f5188 } +#pushButton_export:hover { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_export:pressed { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_export:checked { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} + + + 导出 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + diff --git a/TriggerConfig.cpp b/TriggerConfig.cpp index 767d683..f84d8ff 100644 --- a/TriggerConfig.cpp +++ b/TriggerConfig.cpp @@ -260,8 +260,8 @@ void CTriggerConfig::on_comboBox_channelConfig_currentTextChanged(const QString }else if(g_ChannelBaseInfo[ii].channelType == "ACCELEROMETER"){ LoadTriggerConfig(g_ChannelBaseInfo[ii].channelID); if(m_vecTriggerConfig.size() < 1){ - model->setRowCount(4); - for (int i = 0; i < 4; i++) { + model->setRowCount(6); + for (int i = 0; i < 6; i++) { model->setItem(i, 2, add_checkBox_model(0)); model->setItem(i, 3, add_checkBox_model(0)); model->setItem(i, 4, add_checkBox_model(0)); @@ -275,6 +275,8 @@ void CTriggerConfig::on_comboBox_channelConfig_currentTextChanged(const QString model->setData(model->index(1,1,QModelIndex()),"峰值"); model->setData(model->index(2,1,QModelIndex()),"速度峰值"); model->setData(model->index(3,1,QModelIndex()),"速度有效值"); + model->setData(model->index(4,1,QModelIndex()),"反时限报警值"); + model->setData(model->index(5,1,QModelIndex()),"反时限危险值"); } @@ -283,8 +285,8 @@ void CTriggerConfig::on_comboBox_channelConfig_currentTextChanged(const QString { LoadTriggerConfig(g_ChannelBaseInfo[ii].channelID); if(m_vecTriggerConfig.size() < 1){ - model->setRowCount(4); - for (int i = 0; i < 4; i++) { + model->setRowCount(6); + for (int i = 0; i < 6; i++) { model->setItem(i, 2, add_checkBox_model()); model->setItem(i, 3, add_checkBox_model()); model->setItem(i, 4, add_checkBox_model()); @@ -298,6 +300,8 @@ void CTriggerConfig::on_comboBox_channelConfig_currentTextChanged(const QString model->setData(model->index(1,1,QModelIndex()),"偏置电压/Gap"); model->setData(model->index(2,1,QModelIndex()),"监测保护峰峰值"); model->setData(model->index(3,1,QModelIndex()),"有效值"); + model->setData(model->index(4,1,QModelIndex()),"反时限报警值"); + model->setData(model->index(5,1,QModelIndex()),"反时限危险值"); } @@ -320,8 +324,8 @@ void CTriggerConfig::on_comboBox_channelConfig_currentTextChanged(const QString { LoadTriggerConfig(g_ChannelBaseInfo[ii].channelID); if(m_vecTriggerConfig.size() < 1){ - model->setRowCount(4); - for (int i = 0; i < 4; i++) { + model->setRowCount(6); + for (int i = 0; i < 6; i++) { model->setItem(i, 2, add_checkBox_model()); model->setItem(i, 3, add_checkBox_model()); model->setItem(i, 4, add_checkBox_model()); @@ -335,6 +339,8 @@ void CTriggerConfig::on_comboBox_channelConfig_currentTextChanged(const QString model->setData(model->index(1,1,QModelIndex()),"峰值"); model->setData(model->index(2,1,QModelIndex()),"位移峰值"); model->setData(model->index(3,1,QModelIndex()),"位移有效值"); + model->setData(model->index(4,1,QModelIndex()),"反时限报警值"); + model->setData(model->index(5,1,QModelIndex()),"反时限危险值"); } @@ -357,8 +363,8 @@ void CTriggerConfig::on_comboBox_channelConfig_currentTextChanged(const QString LoadTriggerConfig(g_ChannelBaseInfo[ii].channelID); if(m_vecTriggerConfig.size() < 1){ - model->setRowCount(3); - for (int i = 0; i < 3; i++){ + model->setRowCount(5); + for (int i = 0; i < 5; i++){ model->setItem(i, 2, add_checkBox_model()); model->setItem(i, 3, add_checkBox_model()); model->setItem(i, 4, add_checkBox_model()); @@ -371,6 +377,8 @@ void CTriggerConfig::on_comboBox_channelConfig_currentTextChanged(const QString model->setData(model->index(0,1,QModelIndex()),"平均值"); model->setData(model->index(1,1,QModelIndex()),"最小值"); model->setData(model->index(2,1,QModelIndex()),"最大值"); + model->setData(model->index(3,1,QModelIndex()),"反时限报警值"); + model->setData(model->index(4,1,QModelIndex()),"反时限危险值"); } } @@ -480,7 +488,8 @@ void CTriggerConfig::on_pushButton_submit_clicked() QString strCol = "count(*)"; int count = g_SqliteDB->QueryData(strTableName,strCol,strWhere); if(count < 1){ - if(rowList[2] == "1" || rowList[4] == "1" || rowList[6] == "1"||rowList[8] == "1"){ + if(rowList[2] == "1" || rowList[4] == "1" || rowList[6] == "1"||rowList[8] == "1") + { QString strSql = QString(" values('%1','%2',%3,'%4','%5',%6,'%7',%8,'%9',%10,'%11',%12,'%13','%14','%15','%16','%17','%18',0) ;").\ arg(ChannelID).arg(ChannelName).arg(WorkConditonSN).arg("").arg(rowList[1]).arg(rowList[2]).arg(rowList[3]).arg(rowList[4]).arg(rowList[5]).arg(rowList[6]).\ arg(rowList[7]).arg(rowList[8]).arg(rowList[9]).arg(rowList[10]).arg(rowList[11]).arg(rowList[12]).arg(rowList[13]).arg(rowList[14]); @@ -496,7 +505,8 @@ void CTriggerConfig::on_pushButton_submit_clicked() int count = g_SqliteDB->QueryData(strTableName,strCol,strWhere); qDebug() << "count " << count << endl; if(count == 0){ - if(rowList[2] == "1" || rowList[4] == "1" || rowList[6] == "1"||rowList[8] == "1"){ + if(rowList[2] == "1" || rowList[4] == "1" || rowList[6] == "1"||rowList[8] == "1") + { QString strSql = QString(" set AlertOver = %1,AlertOverSetpoint = '%2',DangerOver = %3,DangerOverSetpoint = '%4',AlertUnder = %5,AlertUnderSetpoint = '%6',DangerUnder = %7,\ DangerUnderSetpoint = '%8',AlertTriggerStatus = '%9',DangerTriggerStatus = '%10',AlertTriggerDelay = '%11',DangerTriggerDelay = '%12',TriggerType = '%13', operate = 2 where ChannelID = '%14' and WorkConditionID = %15 and Characteristic = '%16' and operate <> 3; ").arg(rowList[2]).arg(rowList[3]).arg(rowList[4]).arg(rowList[5]).arg(rowList[6]).\ arg(rowList[7]).arg(rowList[8]).arg(rowList[9]).arg(rowList[10]).arg(rowList[11]).arg(rowList[12]).arg(rowList[13]).arg(rowList[14]).arg(ChannelID).arg(WorkConditonSN.toInt()).arg(rowList[1]); @@ -663,6 +673,10 @@ void CTriggerConfig::PushData() rowObj["triggerFeatureName"] = "DiagnosisPeak"; else if(triggerConfig[j].Characteristic == "监测保护峰峰值") rowObj["triggerFeatureName"] = "MonitorPk2Pk"; + else if(triggerConfig[j].Characteristic == "反时限危险值") + rowObj["triggerFeatureName"] = "InvertDanger"; + else if(triggerConfig[j].Characteristic == "反时限报警值") + rowObj["triggerFeatureName"] = "InvertAlarm"; QString triggerEventName = QString("%1-%2-%3").arg(rowObj["triggerFeatureName"].toString()).arg(triggerConfig[j].TriggerType).arg(triggerConfig[j].ChannelID); @@ -743,6 +757,10 @@ void CTriggerConfig::PushData() rowObj["triggerFeatureName"] = "DiagnosisPeak"; else if(triggerConfig[j].Characteristic == "监测保护峰峰值") rowObj["triggerFeatureName"] = "MonitorPk2Pk"; + else if(triggerConfig[j].Characteristic == "反时限危险值") + rowObj["triggerFeatureName"] = "InvertDanger"; + else if(triggerConfig[j].Characteristic == "反时限报警值") + rowObj["triggerFeatureName"] = "InvertAlarm"; QString triggerEventName = QString("%1-%2-%3").arg(rowObj["triggerFeatureName"].toString()).arg(triggerConfig[j].TriggerType).arg(triggerConfig[j].ChannelID); diff --git a/UnitSetting.ui b/UnitSetting.ui index f9d8fdf..04f9172 100644 --- a/UnitSetting.ui +++ b/UnitSetting.ui @@ -130,6 +130,9 @@ color: rgb(27, 30, 35); 电厂名称 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -157,6 +160,9 @@ color: rgb(27, 30, 35); 机组名称 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -184,6 +190,9 @@ color: rgb(27, 30, 35); 电厂编号 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -211,6 +220,9 @@ color: rgb(27, 30, 35); 机组编号 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -238,6 +250,9 @@ color: rgb(27, 30, 35); 水轮机制造厂家 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -265,6 +280,9 @@ color: rgb(27, 30, 35); 发电机制造厂家 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -292,6 +310,9 @@ color: rgb(27, 30, 35); 机组类型 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -319,6 +340,9 @@ color: rgb(27, 30, 35); 流量系数 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -346,6 +370,9 @@ color: rgb(27, 30, 35); 额定励磁电流(A) + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -380,6 +407,9 @@ color: rgb(27, 30, 35); 压力脉冲显示 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -407,6 +437,9 @@ color: rgb(27, 30, 35); 额定转速(r/min) + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -471,6 +504,9 @@ color: rgb(27, 30, 35); 额定功率(MW) + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -498,6 +534,9 @@ color: rgb(27, 30, 35); 最大水头(m) + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -525,6 +564,9 @@ color: rgb(27, 30, 35); 最小水头(m) + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -552,6 +594,9 @@ color: rgb(27, 30, 35); 设计水头(m) + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -579,6 +624,9 @@ color: rgb(27, 30, 35); 叶片数 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -606,6 +654,9 @@ color: rgb(27, 30, 35); 导叶数 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -633,6 +684,9 @@ color: rgb(27, 30, 35); 上导瓦数 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -660,6 +714,9 @@ color: rgb(27, 30, 35); 下导瓦数 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -687,6 +744,9 @@ color: rgb(27, 30, 35); 水导瓦数 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -714,6 +774,9 @@ color: rgb(27, 30, 35); 推力瓦数 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -744,6 +807,9 @@ color: rgb(27, 30, 35); 发电机转子磁极个数 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + diff --git a/WaveDisplay.cpp b/WaveDisplay.cpp index c610b5b..21d033d 100644 --- a/WaveDisplay.cpp +++ b/WaveDisplay.cpp @@ -19,7 +19,7 @@ CWaveDisPlay::CWaveDisPlay(QWidget *parent) : ui->widget->setProperty("flag", "Title"); ui->widget_4->setProperty("flag", "normal"); ui->widget_wave->plotLayout()->insertRow(0); - QString strTitle = QString("1倍频频率 %1Hz,1倍频幅值 %2,相位角 %3").arg(0).arg(0).arg(0); + QString strTitle = QString("主频频率 %1 Hz,主频幅值 %2,相位角 %3").arg(0).arg(0).arg(0); customLogMessageHandler(QtDebugMsg,strTitle); m_title = new QCPTextElement(ui->widget_wave, strTitle); ui->widget_wave->plotLayout()->addElement(0, 0, m_title); @@ -208,6 +208,7 @@ void CWaveDisPlay::ParseDataTimeWave(QJsonObject & objContent) bFlag = true; m_ListWaveData = m_WaveData.split(","); ui->widget_wave->xAxis->setLabel("Time(s)"); + ui->widget_wave->yAxis->setLabel(m_ChannelUnit); QString str = QString("wave size = %1").arg(m_ListWaveData.size()); customLogMessageHandler(QtDebugMsg,str); double gap = 0.0; @@ -287,7 +288,7 @@ void CWaveDisPlay::ParseDataFsWave(QJsonObject & objContent) //qDebug() << m_ListWaveData << endl; ui->widget_wave->xAxis->setRange(0, 1); ui->widget_wave->xAxis->setLabel("Fs(Hz)"); - //ui->widget_wave->yAxis->setLabel("um"); + ui->widget_wave->yAxis->setLabel(m_ChannelUnit); QVector x,y; QCPGraph* graph = ui->widget_wave->addGraph(ui->widget_wave->xAxis, ui->widget_wave->yAxis); @@ -320,8 +321,9 @@ void CWaveDisPlay::ParseDataKeyPhase(QJsonObject& objContent) double freq1x = objContent["1xfreq"].toDouble(); m_ListKeyPhaseData = data.split(","); qDebug() << "m_ListKeyPhaseData" << m_ListKeyPhaseData << endl; - - QString strTitle = QString("1倍频频率 %1Hz,1倍频幅值 %2,相位角 %3").arg(freq1x).arg(amp1x).arg(PhaseAngle); + QString strAmp1x = QString::number(amp1x, 'f', 2); // 保留两位小数 + QString strPhaseAngle = QString::number(PhaseAngle, 'f', 1); + QString strTitle = QString("主频频率 %1 Hz,主频幅值 %2,相位角 %3").arg(freq1x).arg(strAmp1x).arg(strPhaseAngle); customLogMessageHandler(QtDebugMsg,strTitle); m_title = new QCPTextElement(ui->widget_wave, strTitle); ui->widget_wave->plotLayout()->addElement(0, 0, m_title); @@ -518,7 +520,7 @@ void CWaveDisPlay::on_comboBox_channel_2_currentTextChanged(const QString &arg1) m_ChannelID = g_ChannelBaseInfo[i].channelID; m_ChannelType = g_ChannelBaseInfo[i].channelType; m_speedRefChannelId = g_ChannelBaseInfo[i].speedRefChannelId; - + m_ChannelUnit = g_ChannelBaseInfo[i].sensorEngineeringUnit; if(ui->Btn_Timewave->isChecked()) { diff --git a/WaveDisplay.h b/WaveDisplay.h index b85998e..f4817d8 100644 --- a/WaveDisplay.h +++ b/WaveDisplay.h @@ -49,6 +49,7 @@ private: Ui::CWaveDisPlay *ui; NetMgr *m_pNetMgr; //HTTP消息类对象 QString m_ChannelID; + QString m_ChannelUnit; QString m_ChannelType; QString m_speedRefChannelId; QString m_WaveData; diff --git a/WorkingCondition.ui b/WorkingCondition.ui index 3c58786..a7babd2 100644 --- a/WorkingCondition.ui +++ b/WorkingCondition.ui @@ -178,7 +178,7 @@ color: rgb(27, 30, 35); - 240 + 150 16777215 @@ -208,7 +208,7 @@ color: rgb(27, 30, 35); - 240 + 150 16777215 @@ -238,7 +238,7 @@ color: rgb(27, 30, 35); - 240 + 150 16777215 @@ -268,7 +268,7 @@ color: rgb(27, 30, 35); - 240 + 150 16777215 @@ -298,7 +298,7 @@ color: rgb(27, 30, 35); - 240 + 150 16777215 @@ -328,7 +328,7 @@ color: rgb(27, 30, 35); - 240 + 150 16777215 @@ -358,7 +358,7 @@ color: rgb(27, 30, 35); - 240 + 150 16777215 @@ -371,7 +371,7 @@ color: rgb(27, 30, 35); - 蜗壳差压通道: + 蜗壳差压: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -388,7 +388,7 @@ color: rgb(27, 30, 35); - 240 + 150 16777215 @@ -401,7 +401,7 @@ color: rgb(27, 30, 35); - 机组效率通道: + 机组效率: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -418,7 +418,7 @@ color: rgb(27, 30, 35); - 240 + 150 16777215 @@ -431,7 +431,7 @@ color: rgb(27, 30, 35); - 发电机出口开关通道: + 发电机出口开关: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -448,7 +448,7 @@ color: rgb(27, 30, 35); - 240 + 150 16777215 @@ -461,7 +461,7 @@ color: rgb(27, 30, 35); - 励磁开关通道: + 励磁开关: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -478,7 +478,7 @@ color: rgb(27, 30, 35); - 240 + 150 16777215 @@ -491,7 +491,7 @@ color: rgb(27, 30, 35); - 发电/抽水工况通道: + 发电/抽水工况: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -508,7 +508,7 @@ color: rgb(27, 30, 35); - 240 + 150 16777215 @@ -521,7 +521,7 @@ color: rgb(27, 30, 35); - 蜗壳进口压力通道: + 蜗壳进口压力: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -538,7 +538,7 @@ color: rgb(27, 30, 35); - 240 + 150 16777215 @@ -551,7 +551,7 @@ color: rgb(27, 30, 35); - 尾水出口压力通道: + 尾水出口压力: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -568,7 +568,7 @@ color: rgb(27, 30, 35); - 280 + 150 16777215 @@ -598,7 +598,7 @@ color: rgb(27, 30, 35); - 240 + 150 16777215 diff --git a/channellist.ui b/channellist.ui index 72da1eb..08a5158 100644 --- a/channellist.ui +++ b/channellist.ui @@ -73,6 +73,16 @@ QTableView::item { + + + + + 100 + 0 + + + + diff --git a/channelsetting.ui b/channelsetting.ui index ffbed75..755fe55 100644 --- a/channelsetting.ui +++ b/channelsetting.ui @@ -7,7 +7,7 @@ 0 0 812 - 718 + 754 @@ -15,8 +15,7 @@ font: 10pt "黑体"; -color: rgb(27, 30, 35); - +color: rgb(27, 30, 35); @@ -251,7 +250,7 @@ color: rgb(27, 30, 35); 通道信息 - + @@ -462,12 +461,9 @@ color: rgb(27, 30, 35); - + - - 1 - @@ -494,7 +490,7 @@ color: rgb(27, 30, 35); - 150 + 0 0 @@ -514,7 +510,7 @@ color: rgb(27, 30, 35); - 110 + 100 16777215 @@ -530,7 +526,7 @@ color: rgb(27, 30, 35); - 120 + 0 0 @@ -543,7 +539,7 @@ color: rgb(27, 30, 35); - 3 + 0 0 @@ -555,7 +551,7 @@ color: rgb(27, 30, 35); - + @@ -566,7 +562,7 @@ color: rgb(27, 30, 35); - 110 + 100 16777215 @@ -582,7 +578,7 @@ color: rgb(27, 30, 35); - 150 + 0 0 @@ -635,7 +631,7 @@ color: rgb(27, 30, 35); - 1 + 0 @@ -662,7 +658,7 @@ color: rgb(27, 30, 35); 0 - 120 + 135 @@ -676,7 +672,7 @@ color: rgb(27, 30, 35); 0 - 0 + 10 0 @@ -1258,7 +1254,7 @@ color: rgb(27, 30, 35); 采样设置 - + @@ -1393,24 +1389,8 @@ color: rgb(27, 30, 35); - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - 1 - @@ -1495,96 +1475,13 @@ color: rgb(27, 30, 35); - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 95 - 0 - - - - 低通频率: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - 10 - - - - - - - - - - - - 95 - 0 - - - - 高通频率: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - 3500 - - - - - - 95 + 100 0 @@ -1619,6 +1516,48 @@ color: rgb(27, 30, 35); + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 96 + 28 + + + + + 96 + 28 + + + + #pushButton_CustomFilter { border-image: url(:/image/Btn/normal_Btn.png); + color:#1f5188 } +#pushButton_CustomFilter:hover { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_CustomFilter:pressed { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} +#pushButton_CustomFilter:checked { border-image: url(:/image/Btn/normal_Btn_p.png); + color:#ffffff} + + + 滤波设置 + + + @@ -2627,6 +2566,19 @@ color: rgb(27, 30, 35); + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -2696,6 +2648,9 @@ color: rgb(27, 30, 35); 备注 + + 10 + @@ -2706,13 +2661,13 @@ color: rgb(27, 30, 35); - 80 + 85 0 - 80 + 85 16777215 diff --git a/global.h b/global.h index e1e1915..25b9fae 100644 --- a/global.h +++ b/global.h @@ -16,6 +16,7 @@ extern QString g_LocalFile ; extern QString g_strVersion ; extern QString g_strProject ; extern QString g_strFre ; + typedef struct ChannelSetting{ double ChUnitCoeff; int ChUnitDot; @@ -123,6 +124,7 @@ typedef struct ChannelSetting{ int sectionNum; QString EngineeringUnit; QString firstPoleNum; + int filterStatus; ChannelSetting(){ speedRefChannelId = ""; xZeroScalePosition = ""; @@ -308,6 +310,9 @@ typedef struct _Charateristic{ double speedRPM; int ChUnitDot; QString channelType; + double InvertAlarm; + double InvertDanger; + } Charateristic_t; typedef struct tag_WAVE_DATA{ QString channelId; diff --git a/main.cpp b/main.cpp index b48f94e..38d9d3d 100644 --- a/main.cpp +++ b/main.cpp @@ -1,9 +1,11 @@ #include "mainwindow.h" #include + int main(int argc, char *argv[]) { QApplication a(argc, argv); + MainWindow w; w.show(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 6ef89d9..a2150cc 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -21,7 +21,7 @@ MainWindow::MainWindow(QWidget *parent) : //读取ini QSettings settingsread(QCoreApplication::applicationDirPath() + "\\config\\config.ini",QSettings::IniFormat); - g_strVersion = settingsread.value("main/Version").toString(); + g_strVersion = "SJ90C V1.1"; g_strProject = settingsread.value("main/Project").toString(); g_strFre = settingsread.value("main/Fre").toString(); @@ -375,15 +375,6 @@ void MainWindow::leftConfigClick3() delete pTriggerConfig; pTriggerConfig = NULL; } -// if(pUnitConfiguration){ -// delete pUnitConfiguration; -// pUnitConfiguration = NULL; -// } - -// if(pTestForm){ -// delete pTestForm; -// pTestForm = NULL; -// } }else if(name == "工况配置"){ if(pWorkCondition == NULL) diff --git a/qss/blacksoft.css b/qss/blacksoft.css index c8cf672..6731921 100644 --- a/qss/blacksoft.css +++ b/qss/blacksoft.css @@ -6,7 +6,7 @@ qproperty-backgroundBrush:#f2f4f7; } QWidget[form="true"],QLabel[frameShape="1"]{ -border:1px solid #242424; +border:1px solid #f2f4f7; border-radius:0px; } @@ -20,7 +20,7 @@ border:1px solid #f2f4f7; QWidget[form="bottom"] QLabel,QWidget[form="title"] QLabel{ border-radius:0px; -color:#f2f4f7; +color:#484848; background:none; border-style:none; } @@ -108,9 +108,25 @@ background:none; selection-background-color:#AAAAAA; selection-color:#ffffff; } +QComboBox,QTextEdit,QLineEdit,QTimeEdit{ + color:#666666; + font-size:14px; + padding: 1px 15px 1px 3px; + border:1px solid rgba(228,228,228,1); + border-radius:5px 5px 0px 0px; + height:20px; +} +QComboBox:disabled,QTextEdit:disabled,QLineEdit:disabled,QTimeEdit:disabled{ + color:#666666; + font-size:14px; + padding: 1px 15px 1px 3px; + border:1px solid rgba(228,228,228,1); + border-radius:5px 5px 0px 0px; + height:20px; +} QLineEdit:focus,QTextEdit:focus,QPlainTextEdit:focus,QSpinBox:focus,QDoubleSpinBox:focus,QComboBox:focus,QDateEdit:focus,QTimeEdit:focus,QDateTimeEdit:focus,QLineEdit:hover,QTextEdit:hover,QPlainTextEdit:hover,QSpinBox:hover,QDoubleSpinBox:hover,QComboBox:hover,QDateEdit:hover,QTimeEdit:hover,QDateTimeEdit:hover{ -border:1px solid #242424; +border:1px solid #245d9b; } QLineEdit[echoMode="2"]{ @@ -123,9 +139,15 @@ border-radius:3px; } .QGroupBox{ -border:1px solid #242424; +/*border:1px solid #242424; border-radius:5px; -margin-top:9px; +margin-top:9px;*/ +color:#666666; +font-size:14px; +padding: 1px 15px 1px 3px; +border:1px solid rgba(228,228,228,1); +border-radius:5px 5px 0px 0px; +height:20px; } .QGroupBox::title{ @@ -297,7 +319,7 @@ border-left-width:0px; border-left-style:solid; border-top-right-radius:3px; border-bottom-right-radius:3px; -border-left-color:#242424; +border-left-color:#409CE1; } QComboBox::drop-down:on{ diff --git a/realtimeform.cpp b/realtimeform.cpp index 5aed8f0..39c4d2f 100644 --- a/realtimeform.cpp +++ b/realtimeform.cpp @@ -87,13 +87,13 @@ CRealTimeForm::CRealTimeForm(QWidget *parent) : connect(m_pSocket, &QTcpSocket::readyRead, this, &CRealTimeForm::slotRecieve); connect(m_pSocket, &QTcpSocket::disconnected, this, &CRealTimeForm::disConnect); -#ifdef QT_NO_DEBUG +//#ifdef QT_NO_DEBUG id1 = startTimer(2000); //参数1 间隔 单位 毫秒 //定时器第二种方式 QTimer * timer = new QTimer(this); //启动定时器 timer->start(500); -#endif +//#endif } CRealTimeForm::~CRealTimeForm() @@ -1279,6 +1279,10 @@ void CRealTimeForm::ParseCharacteristic(QJsonArray& arrayValue) tempCharateristic.speedRPM = arrayValue.at(i)["SpeedProfileSpeed"].toDouble(); tempCharateristic.ChUnitDot = arrayValue.at(i)["ChUnitDot"].toInt(); tempCharateristic.channelType = arrayValue.at(i)["ChannelType"].toString(); + tempCharateristic.ChUnitDot = arrayValue.at(i)["ChUnitDot"].toInt(); + tempCharateristic.channelType = arrayValue.at(i)["ChannelType"].toString(); + tempCharateristic.InvertAlarm = arrayValue.at(i)["InvertAlarm"].toDouble(); + tempCharateristic.InvertDanger = arrayValue.at(i)["InvertDanger"].toDouble(); m_vecCharateristic.push_back(tempCharateristic); g_Charateristic.push_back(tempCharateristic); diff --git a/sqlitedb.cpp b/sqlitedb.cpp index 23ce1a9..ed3fa94 100644 --- a/sqlitedb.cpp +++ b/sqlitedb.cpp @@ -1,6 +1,7 @@ #include "sqlitedb.h" SqliteDB* g_SqliteDB = NULL; +QSqlDatabase db; SqliteDB::SqliteDB() { @@ -20,7 +21,7 @@ int SqliteDB::OpenDataBase() qDebug() << QSqlDatabase::drivers() << "\r\n"; - QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); + db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(QCoreApplication::applicationDirPath() + "\\config\\config.db"); if (!db.open()) @@ -69,12 +70,24 @@ int SqliteDB::initTable() .arg("sqlite_master").arg("t_TriggerConfig").arg("operate"); iRet = ExeSqlData(strSql); if(iRet == 0){ - strSql = "ALTER TABLE t_TriggerConfig ADD COLUMN 'operate' integer"; + strSql = "ALTER TABLE t_TriggerConfig ADD COLUMN 'operate' integer DEFAULT 1"; + ExeSqlData(strSql); + } + + strSql = QString("select count(*) from %1 where name = '%2' and sql LIKE '%%3%' ")\ + .arg("sqlite_master").arg("t_ChannelSetting").arg("filterStatus"); + iRet = ExeSqlData(strSql); + if(iRet == 0){ + strSql = "ALTER TABLE t_ChannelSetting ADD COLUMN 'filterStatus' integer"; ExeSqlData(strSql); } CreateDataBase(); } +int SqliteDB::CloseDataBase() +{ + db.close(); +} int SqliteDB::CreateDataBase() { QString strCreateSQL = QString("create table if not exists t_UnitConfiguration(WorkConditionID,ChannelID,BoardNo,ChannelNoInBoard,Input,Operate);"); @@ -261,6 +274,7 @@ QVector SqliteDB::GetDataMultiLine(QString tablename, QString co tempchannel.sectionNum = sql_query.value(97).toInt(); tempchannel.EngineeringUnit = sql_query.value(98).toString(); tempchannel.firstPoleNum = sql_query.value(99).toString(); + tempchannel.filterStatus = sql_query.value(100).toInt(); vecResult.append(tempchannel); } } @@ -546,9 +560,10 @@ int SqliteDB::InsertData(QString& tablename,QString& sql) QSqlQuery sql_query; QString strSql = "INSERT INTO "; strSql = strSql + tablename + sql; - qDebug() << "strSql" <