优化功能

This commit is contained in:
CHINAMI-TV221UM\Administrator 2024-03-14 09:35:39 +08:00
parent 7913e4f261
commit 5623d4844b
20 changed files with 575 additions and 201 deletions

View File

@ -101,6 +101,7 @@ void CAddChannel::on_comboBox_channel_currentTextChanged(const QString &arg1)
ui->comboBox_charac->addItem("平均值");
}else if(g_ChannelBaseInfo[i].channelType == "THRUST"){
ui->comboBox_charac->addItem("平均值");
ui->comboBox_charac->addItem("有效值");
}else if(g_ChannelBaseInfo[i].channelType == "FAST_VOLTAGE"){
ui->comboBox_charac->addItem("平均值");
ui->comboBox_charac->addItem("有效值");

View File

@ -35,7 +35,7 @@ CHistoryAlarm::CHistoryAlarm(QWidget *parent) :
QDateTime curDateTime=QDateTime::currentDateTime();//通过QDateTime的currentDateTime获得当前的日期时间并赋值给curDateTime
ui->dateTimeEdit_start->setDateTime(curDateTime.addDays(-7));
ui->dateTimeEdit_end->setDateTime(curDateTime);
ui->dateTimeEdit_end->setDateTime(curDateTime.addSecs(300));
ui->comboBox_channel->setView(new QListView());

View File

@ -39,12 +39,24 @@ void CNTPServerConfig::slotNetMgr(QString sAddr, const QVariant &msg)
QJsonValue arrays_value = objec.take("cmd");
if(arrays_value.toString() == "02")
{
bool Status = objec.take("success").toBool();
QString strMessage = objec.take("message").toString();
if(Status){
QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("保存成功!"));
}else{
QMessageBox::information(this, QStringLiteral("提示"), strMessage);
QJsonObject cmdBodyObj = objec["cmdBody"].toObject();
QJsonValue arrays_value = cmdBodyObj.take("type");
if(arrays_value == "SET"){
bool Status = objec.take("success").toBool();
QString strMessage = objec.take("message").toString();
if(Status){
QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("保存成功!"));
}else{
QMessageBox::information(this, QStringLiteral("提示"), strMessage);
}
}else if(arrays_value == "GET"){
int timestamp_value = cmdBodyObj.take("timeStamp").toInt();
QDateTime dateTime;
dateTime.setSecsSinceEpoch(timestamp_value);
QString strTime = dateTime.toString("yyyy-MM-dd hh:mm:ss");
ui->label_time->setText(strTime);
}
}
}
@ -164,3 +176,20 @@ void CNTPServerConfig::on_radioButton_switch_clicked()
g_FtpClient->UpLoadFile(fileName,"ServerConfig.json",4);
}
void CNTPServerConfig::on_pushButton_get_clicked()
{
QJsonObject allObj,cmdBody;
allObj.insert("cmd", "02");
cmdBody.insert("type","GET");
long timeStamp = QDateTime::currentDateTime().toTime_t();
QString str = QString("%1").arg(timeStamp);
cmdBody["timeStamp"] = str.toInt();
allObj["cmdBody"] = cmdBody;
QNetworkRequest req;
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
req.setUrl(sUrl);
g_NetMgr->PostJson(req,allObj);
connect(g_NetMgr,SIGNAL(sigNetMgr(QString, const QVariant&)), this, SLOT(slotNetMgr(QString,const QVariant&)));
}

View File

@ -30,6 +30,8 @@ private slots:
void slotReplyStatus(int );
void on_pushButton_get_clicked();
private:
Ui::CNTPServerConfig *ui;

View File

@ -200,8 +200,8 @@
<widget class="QPushButton" name="pushButton_manual">
<property name="geometry">
<rect>
<x>60</x>
<y>60</y>
<x>160</x>
<y>140</y>
<width>96</width>
<height>28</height>
</rect>
@ -232,6 +232,54 @@
<string>手动对时</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_get">
<property name="geometry">
<rect>
<x>40</x>
<y>140</y>
<width>96</width>
<height>28</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>96</width>
<height>28</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>96</width>
<height>28</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">#pushButton_get { border-image: url(:/image/Btn/normal_Btn.png);
color:#1f5188 }
#pushButton_get:hover { border-image: url(:/image/Btn/normal_Btn_p.png);
color:#ffffff}
#pushButton_get:pressed { border-image: url(:/image/Btn/normal_Btn_p.png);
color:#ffffff}
#pushButton_get:checked { border-image: url(:/image/Btn/normal_Btn_p.png);
color:#ffffff}</string>
</property>
<property name="text">
<string>获取设备时间</string>
</property>
</widget>
<widget class="QLabel" name="label_time">
<property name="geometry">
<rect>
<x>50</x>
<y>50</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</widget>
</item>
</layout>

View File

@ -434,6 +434,11 @@ void CRealTimeAlarm::OpenDatFile(QString& strFileName)
QTime stopTime = QTime::currentTime();
qDebug() << "Time: " << startTime.msecsTo(stopTime) << "ms" <<endl;
if(m_iRealCount < 1){
QMessageBox::information(this, "提示", QString("未读取到数据!"));
return;
}
delete progressDialog;
DateViewdialog = new CDataGraphView();
connect(DateViewdialog, SIGNAL(ItemCheckStateSignal(QString, bool)), this, SLOT(ItemCheckStateSlot(QString, bool)));

View File

@ -101,7 +101,7 @@ void CTriggerConfig::LoadTriggerConfig(QString& strChannelID)
return;
}
QString strChanneName = ui->comboBox_channelConfig->currentText();
QString strWhere = QString(" WorkConditionID = %1 and ChannelID = '%2' ").arg(m_WorkCondition[ii].SN).arg(strChannelID);
QString strWhere = QString(" WorkConditionID = %1 and ChannelID = '%2' and operate <> 3 ").arg(m_WorkCondition[ii].SN).arg(strChannelID);
m_vecTriggerConfig.clear();
QVector<TriggerConfig_t>().swap(m_vecTriggerConfig);
m_vecTriggerConfig = g_SqliteDB->GetTriggerConfig("t_TriggerConfig",strWhere);
@ -383,9 +383,12 @@ void CTriggerConfig::on_pushButton_submit_clicked()
qDebug() << "rowCount" << model->rowCount() <<endl;
QString WorkConditonSN = "" ;
QString ChannelID = "", ChannelName = "";
for (int i = 0; i < m_WorkCondition.size() ; i++) {
if(ui->comboBox_workCondition->currentText() == m_WorkCondition[i].WorkConditionName)
int i = 0;
for (i = 0; i < m_WorkCondition.size() ; i++) {
if(ui->comboBox_workCondition->currentText() == m_WorkCondition[i].WorkConditionName){
WorkConditonSN = m_WorkCondition[i].SN;
break;
}
}
for (int i = 0; i < g_ChannelBaseInfo.size() ; i++) {
if(ui->comboBox_channelConfig->currentText() == g_ChannelBaseInfo[i].channelName){
@ -408,7 +411,7 @@ void CTriggerConfig::on_pushButton_submit_clicked()
rowList << strData;
}
if(j == 2){
if(j == 2){
QStandardItem *item = model->itemFromIndex(index);
if(item->checkState() == Qt::Unchecked)
rowList << "0";
@ -478,18 +481,37 @@ void CTriggerConfig::on_pushButton_submit_clicked()
int count = g_SqliteDB->QueryData(strTableName,strCol,strWhere);
if(count < 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') ;").\
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]);
g_SqliteDB->InsertData(strTableName,strSql);
}
}else{
if(rowList[2] == "1" || rowList[4] == "1" || rowList[6] == "1"||rowList[8] == "1"){
QString strWhere = QString(" AlertOver = %1 and AlertOverSetpoint = '%2' and DangerOver = %3 and DangerOverSetpoint = '%4' and AlertUnder = %5 and AlertUnderSetpoint = '%6' and DangerUnder = %7 and \
DangerUnderSetpoint = '%8' and AlertTriggerStatus = '%9' and DangerTriggerStatus = '%10' and AlertTriggerDelay = '%11' and DangerTriggerDelay = '%12' and TriggerType = '%13' 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]);
QString strCol = "count(*)";
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"){
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]);
g_SqliteDB->UpdateDataSql(strTableName,strSql);
}
}else{
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' where ChannelID = '%14' and WorkConditionID = %15 and Characteristic = '%16' ; ").arg(rowList[2]).arg(rowList[3]).arg(rowList[4]).arg(rowList[5]).arg(rowList[6]).\
DangerUnderSetpoint = '%8',AlertTriggerStatus = '%9',DangerTriggerStatus = '%10',AlertTriggerDelay = '%11',DangerTriggerDelay = '%12',TriggerType = '%13', operate = 1 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]);
g_SqliteDB->UpdateDataSql(strTableName,strSql);
}
}
m_isConfirm = 1;
@ -556,13 +578,20 @@ void CTriggerConfig::dialogReleased()
on_comboBox_WorkCondition_currentTextChanged(ui->comboBox_workCondition->currentText());
}
void CTriggerConfig::on_deleteTriggerEvent()
{
QString str = ui->comboBox_channelConfig->currentText();
on_comboBox_channelConfig_currentTextChanged(str);
}
void CTriggerConfig::on_pushButton_view_clicked()
{
ViewTriggerConfig *dialog = new ViewTriggerConfig();
//connect(dialog,SIGNAL(reject()),this,SLOT(dialogReleased()));
dialog->setWindowModality(Qt::ApplicationModal);
dialog->show();
connect(dialog,SIGNAL(deleteTriggerEvent_sg()),this,SLOT(on_deleteTriggerEvent()));
}
void CTriggerConfig::slotNetMgr(QString sAddr, const QVariant &msg)
@ -602,7 +631,7 @@ void CTriggerConfig::PushData()
}
for (int i = 0; i< m_WorkCondition.size(); i++) {
QJsonArray arraytriggerSettings;
QString strWhere = QString(" WorkConditionID = %1").arg(m_WorkCondition[i].SN);
QString strWhere = QString(" WorkConditionID = %1 and operate <> 3 ").arg(m_WorkCondition[i].SN);
QVector<TriggerConfig_t> triggerConfig = g_SqliteDB->GetTriggerConfig("t_TriggerConfig",strWhere);
for (int ii = 0; ii < g_ChannelBaseInfo.size(); ii++) {
@ -678,16 +707,119 @@ void CTriggerConfig::PushData()
file.write(jsonDoc.toJson());
file.close();
QJsonArray m_channeltriggerArray2;
QJsonObject triggerConfigObj2;
for (int i = 0; i< m_WorkCondition.size(); i++) {
QJsonArray arraytriggerSettings;
QString strWhere = QString(" WorkConditionID = %1 ").arg(m_WorkCondition[i].SN);
QVector<TriggerConfig_t> triggerConfig = g_SqliteDB->GetTriggerConfig("t_TriggerConfig",strWhere);
for (int ii = 0; ii < g_ChannelBaseInfo.size(); ii++) {
int operate = -1;
QJsonArray triggerArray;
if(triggerConfig.size() > 0){
for (int j = 0; j < triggerConfig.size(); j++) {
if(g_ChannelBaseInfo[ii].channelID == triggerConfig[j].ChannelID){
QJsonObject rowObj;
if(triggerConfig[j].Characteristic == "最小值")
rowObj["triggerFeatureName"] = "MinValues";
else if(triggerConfig[j].Characteristic == "最大值")
rowObj["triggerFeatureName"] = "MaxValues";
else if( triggerConfig[j].Characteristic == "偏置电压/Gap")
rowObj["triggerFeatureName"] = "DCValues";
else if(triggerConfig[j].Characteristic == "平均值" || triggerConfig[j].Characteristic == "有效值")
rowObj["triggerFeatureName"] = "RMSValues";
else if(triggerConfig[j].Characteristic == "诊断峰峰值")
rowObj["triggerFeatureName"] = "DiagnosisPk2Pk";
else if(triggerConfig[j].Characteristic == "速度有效值" || triggerConfig[j].Characteristic == "位移有效值")//积分
rowObj["triggerFeatureName"] = "IntegratRMS";
else if(triggerConfig[j].Characteristic == "积分峰峰值")
rowObj["triggerFeatureName"] = "IntegratPk2Pk";
else if(triggerConfig[j].Characteristic == "转速")
rowObj["triggerFeatureName"] = "SpeedProfileSpeed";
else if(triggerConfig[j].Characteristic == "速度峰值" || triggerConfig[j].Characteristic == "位移峰值")//积分
rowObj["triggerFeatureName"] = "IntegratPk2Pk/2";
else if(triggerConfig[j].Characteristic == "峰值")
rowObj["triggerFeatureName"] = "DiagnosisPeak";
else if(triggerConfig[j].Characteristic == "监测保护峰峰值")
rowObj["triggerFeatureName"] = "MonitorPk2Pk";
QString triggerEventName = QString("%1-%2-%3").arg(rowObj["triggerFeatureName"].toString()).arg(triggerConfig[j].TriggerType).arg(triggerConfig[j].ChannelID);
rowObj["triggerEventName"] = triggerEventName;
rowObj["xAlertOverEnabled"] = triggerConfig[j].AlertOver;
rowObj["xAlertOverSetpoint"] = triggerConfig[j].AlertOverSetpoint.toDouble();
rowObj["xAlertTriggerDelay"] = triggerConfig[j].AlertTriggerDelay.toInt();
rowObj["xAlertTriggerStatus"] = triggerConfig[j].AlertTriggerStatus;
rowObj["xAlertUnderEnabled"] = triggerConfig[j].AlertUnder;
rowObj["xAlertUnderSetpoint"] = triggerConfig[j].AlertUnderSetpoint.toDouble();
rowObj["xDangerOverEnabled"] = triggerConfig[j].DangerOver;
rowObj["xDangerOverSetpoint"] = triggerConfig[j].DangerOverSetpoint.toDouble();
rowObj["xDangerTriggerDelay"] = triggerConfig[j].DangerTriggerDelay.toInt();
rowObj["xDangerTriggerStatus"] = triggerConfig[j].DangerTriggerStatus;
rowObj["xDangerUnderEnabled"] = triggerConfig[j].DangerUnder;
rowObj["xDangerUnderSetpoint"] = triggerConfig[j].DangerUnderSetpoint.toDouble();
operate = triggerConfig[j].operate;
triggerArray.append(rowObj);
}
}
}
QJsonObject tempObj;
tempObj["triggerConfig"] = triggerArray;
tempObj["channelId"] = g_ChannelBaseInfo[ii].channelID;
tempObj["channelName"] = g_ChannelBaseInfo[ii].channelName;
tempObj["channelOperate"] = operate;
arraytriggerSettings.append(tempObj);
}
triggerConfigObj2["triggerSettings"] = arraytriggerSettings;
triggerConfigObj2["workConditionSN"] = m_WorkCondition[i].SN.toInt();
triggerConfigObj2["workConditionName"] = m_WorkCondition[i].WorkConditionName;
m_channeltriggerArray2.append(triggerConfigObj2);
}
QJsonDocument jsonDoc2;
jsonDoc2.setArray(m_channeltriggerArray2);
QString fileName2 = QCoreApplication::applicationDirPath() + "\\config\\TriggerSettings2.json";
QFile file2(fileName2);
file2.open(QIODevice::WriteOnly);
file2.write(jsonDoc2.toJson());
file2.close();
QVector<WorkCondition_t>().swap(m_WorkCondition);
QString wherecon = "";
wherecon = QString("Enable = \"1\" ");
m_WorkCondition = g_SqliteDB->GetWorkCondition("t_WorkCondition",wherecon);
QString tableName = " t_TriggerConfig ";
QString strWhere = QString(" operate = 3 ");
g_SqliteDB->DeleteDataW(tableName,strWhere);
QString strSql = QString(" set operate = 1 where operate = 0 ");
g_SqliteDB->UpdateDataSql(tableName,strSql);
strSql = QString(" set operate = 1 where operate = 2 ");
g_SqliteDB->UpdateDataSql(tableName,strSql);
g_SqliteDB->GetTriggerConfig("t_TriggerConfig","");
QString str = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("TriggerSettings.json");
g_FtpClient->SetServerInfo(str);
g_FtpClient->SetUserInfo("root","@#cidw!@123456");
g_FtpClient->UpLoadFile(fileName,"TriggerSettings.json");
QString str2 = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("TriggerSettings2.json");
g_FtpClient->SetServerInfo(str2);
g_FtpClient->SetUserInfo("root","@#cidw!@123456");
g_FtpClient->UpLoadFile(fileName2,"TriggerSettings2.json");
disconnect(g_NetMgr,SIGNAL(sigNetMgr(QString, const QVariant&)), this, SLOT(slotNetMgr(QString,const QVariant&)));
}

View File

@ -9,6 +9,7 @@
#include <QStandardItemModel>
#include <QComboBox>
#include <QRadioButton>
#include <QCloseEvent>
#include "sqlitedb.h"
#include "NetMgr.h"
@ -35,7 +36,7 @@ private slots:
void on_pushButton_view_clicked();
void dialogReleased();
void slotNetMgr(QString sAddr,const QVariant& msg);
void on_deleteTriggerEvent();
private:
Ui::CTriggerConfig *ui;
QString headerStr ;

View File

@ -78,7 +78,7 @@ void ViewTriggerConfig::LoadTriggerConfig(const QString& strWorkCondition)
QMessageBox::warning(this, QStringLiteral("警告"), QStringLiteral("工况信息加载失败!"));
return;
}
QString strWhere = QString(" WorkConditionID = %1 ").arg(m_WorkCondition[ii].SN);
QString strWhere = QString(" WorkConditionID = %1 and operate <> 3 ").arg(m_WorkCondition[ii].SN);
m_vecTriggerConfig.clear();
QVector<TriggerConfig_t>().swap(m_vecTriggerConfig);
m_vecTriggerConfig = g_SqliteDB->GetTriggerConfig("t_TriggerConfig",strWhere);
@ -155,21 +155,26 @@ void ViewTriggerConfig::on_pushButton_del_clicked()
QModelIndex indexCheck = model->index(i,0);
bool check = model->data(indexCheck, Qt::UserRole).toBool();
if(check){
QString strChannelName = model->data(model->index(i,1)).toString();
QString strWorkConditionID = model->data(model->index(i,14)).toString();
QString strCharacteristic = model->data(model->index(i,2)).toString();
QString strWhere = QString(" ChannelName = '%1' and WorkConditionID = %2 and Characteristic = '%3' ").arg(strChannelName).arg(m_WorkCondition[ii].SN).arg(strCharacteristic);
QString strWhere = QString("where ChannelName = '%1' and WorkConditionID = %2 and Characteristic = '%3' ").arg(strChannelName).arg(m_WorkCondition[ii].SN).arg(strCharacteristic);
QString tableName = "t_TriggerConfig ";
iRet = g_SqliteDB->DeleteDataW(tableName,strWhere);
QString strSql = QString(" set operate = 3 ");
strSql = strSql + strWhere;
iRet = g_SqliteDB->UpdateDataSql(tableName,strSql);
//iRet = g_SqliteDB->DeleteDataW(tableName,strWhere);
if(iRet != 0)
break;
}
}
if(iRet == 0)
if(iRet == 0){
QMessageBox::warning(this, QStringLiteral("警告"), QStringLiteral("删除成功!"));
else
emit deleteTriggerEvent_sg();
}
else{
QMessageBox::warning(this, QStringLiteral("警告"), QStringLiteral("删除失败!"));
}
LoadTriggerConfig(m_strWorkCondition);
}

View File

@ -18,7 +18,8 @@ private slots:
void on_pushButton_del_clicked();
void on_comboBox_workCondition_currentTextChanged(const QString &arg1);
signals:
void deleteTriggerEvent_sg();
public:
explicit ViewTriggerConfig(QWidget *parent = nullptr);
~ViewTriggerConfig();

View File

@ -534,11 +534,7 @@ void CWaveDisPlay::on_comboBox_channel_2_currentTextChanged(const QString &arg1)
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
req.setUrl(sUrl);
m_pNetMgr->PostJson(req,allObj);
// id1 = startTimer(1000); //参数1 间隔 单位 毫秒
// //定时器第二种方式
// QTimer * timer = new QTimer(this);
// //启动定时器
// timer->start(500);
}else if(ui->pushButton_1S->isChecked()){
OneSecond = true;
QJsonObject allObj,cmdBody;
@ -590,6 +586,39 @@ void CWaveDisPlay::timerEvent(QTimerEvent *ev)
m_Times = 0;
}
}
if(ev->timerId() == id2){
m_PackgNum = 1;
bFlag = false;
ui->widget_wave->clearGraphs();
ui->widget_wave->clearPlottables();
ui->widget_wave->replot();
m_WaveData = "";
m_ListWaveData.clear();
if(ui->Btn_Timewave->isChecked()){
OneSecond = true;
QJsonObject allObj,cmdBody;
allObj.insert("cmd", "30");
cmdBody.insert("package",0);
cmdBody.insert("channelId",m_ChannelID);
allObj["cmdBody"] = cmdBody;
QNetworkRequest req;
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
req.setUrl(sUrl);
m_pNetMgr->PostJson(req,allObj);
}else if(ui->Btn_Fswave->isChecked())
{
QJsonObject allObj,cmdBody;
allObj.insert("cmd", "32");
cmdBody.insert("package",0);
cmdBody.insert("channelId",m_ChannelID);
allObj["cmdBody"] = cmdBody;
QNetworkRequest req;
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
req.setUrl(sUrl);
m_pNetMgr->PostJson(req,allObj);
}
}
}
@ -623,3 +652,41 @@ void CWaveDisPlay::on_pushButton_4S_clicked()
}
}
void CWaveDisPlay::on_pushButton_refreshauto_clicked()
{
if(ui->comboBox_channel_2->count() < 1)
return;
m_PackgNum = 1;
bFlag = false;
ui->widget_wave->clearGraphs();
ui->widget_wave->clearPlottables();
ui->widget_wave->replot();
m_WaveData = "";
m_ListWaveData.clear();
QString strChannelName = ui->comboBox_channel_2->currentText();
if(strChannelName == "请选择通道..."){
return;
}
if(ui->pushButton_4S->isChecked()){
QMessageBox::information(this, QStringLiteral("提示"), "请切换到1秒时域图");
ui->pushButton_refreshauto->setChecked(false);
return;
}
if(ui->pushButton_refreshauto->isChecked()){
ui->pushButton_refreshauto->setText("关闭");
id2 = startTimer(2000); //参数1 间隔 单位 毫秒
//定时器第二种方式
QTimer * timer = new QTimer(this);
//启动定时器
timer->start(500);
}
if(!ui->pushButton_refreshauto->isChecked() && ui->pushButton_1S->isChecked()){
ui->pushButton_refreshauto->setText("自动刷新");
killTimer(id2);
return;
}
}

View File

@ -40,6 +40,8 @@ private slots:
void on_pushButton_4S_clicked();
void on_pushButton_refreshauto_clicked();
public slots:
void mouseMoveEvent(QMouseEvent *event);
@ -59,6 +61,7 @@ private:
QCPItemText *tracerLabel; //游标标签
int id1; //定时器1的唯一标示
int id2;
int m_Times;
int m_Count;
bool OneSecond;

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>914</width>
<width>1170</width>
<height>525</height>
</rect>
</property>
@ -426,6 +426,38 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_refreshauto">
<property name="minimumSize">
<size>
<width>96</width>
<height>28</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>96</width>
<height>28</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">#pushButton_refreshauto { border-image: url(:/image/Btn/normal_Btn.png);
color:#1f5188 }
#pushButton_refreshauto:hover { border-image: url(:/image/Btn/normal_Btn_p.png);
color:#ffffff}
#pushButton_refreshauto:pressed { border-image: url(:/image/Btn/normal_Btn_p.png);
color:#ffffff}
#pushButton_refreshauto:checked { border-image: url(:/image/Btn/normal_Btn_p.png);
color:#ffffff}</string>
</property>
<property name="text">
<string>自动刷新</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">

View File

@ -7,6 +7,7 @@ channelCount_t g_channelCount;
QVector<_Charateristic> g_Charateristic;
QMap<QString,QString> g_MapChannelType;
QMap<QString,QVariantList> g_MapTableList;
QMap<QString,TriggerConfig_t> g_mapTriggerEvent;
QString IP ;
QString MAC ;
QString g_LocalFile ;

View File

@ -228,6 +228,7 @@ typedef struct _TriggerConfig{
QString AlertTriggerDelay;
QString DangerTriggerDelay;
QString TriggerType;
int operate;
} TriggerConfig_t;
typedef struct _TriggerEvent{
@ -412,4 +413,5 @@ extern channelCount_t g_channelCount;
extern QVector<_Charateristic> g_Charateristic;
extern QMap<QString,QString> g_MapChannelType;
extern QMap<QString,QVariantList> g_MapTableList;
extern QMap<QString,TriggerConfig_t> g_mapTriggerEvent;
#endif // GLOBAL_H

View File

@ -83,8 +83,13 @@ MainWindow::MainWindow(QWidget *parent) :
//启动定时器
timer->start(500);
LoadTrigerConfig();
}
void MainWindow::LoadTrigerConfig()
{
g_SqliteDB->GetTriggerConfig("t_TriggerConfig","");
}

View File

@ -95,6 +95,7 @@ private:
virtual void timerEvent(QTimerEvent *);
int id1; //定时器1的唯一标示
void LoadTrigerConfig();
};
#endif // MAINWINDOW_H

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>678</width>
<height>732</height>
<height>737</height>
</rect>
</property>
<property name="windowTitle">
@ -1549,132 +1549,126 @@ background-image: url(:/image/bj.jpg);
<height>16777215</height>
</size>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>82</width>
<height>571</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QToolButton" name="serverConfigBtn">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>网络配置</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="NTPConfigBtn">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>时间配置</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="systemSelfinspectionBtn">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>系统自检</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="terminalDetailsBtn">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>终端详情</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="channelCalibrationBtn">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>通道标定</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="otherConfigBtn">
<property name="minimumSize">
<size>
<width>80</width>
<height>85</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>85</height>
</size>
</property>
<property name="text">
<string>其他配置</string>
</property>
</widget>
</item>
</layout>
</widget>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QToolButton" name="serverConfigBtn">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>网络配置</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="NTPConfigBtn">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>时间配置</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="systemSelfinspectionBtn">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>系统自检</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="terminalDetailsBtn">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>终端详情</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="channelCalibrationBtn">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>通道标定</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="otherConfigBtn">
<property name="minimumSize">
<size>
<width>80</width>
<height>85</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>85</height>
</size>
</property>
<property name="text">
<string>其他配置</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>

View File

@ -253,7 +253,7 @@ void CRealTimeForm::on_addchannel(channelBaseInfo channelbaseInfo,QString str)
pen.setWidth(1);
CMyCustomGraphicsItem* pItemGroup = new CMyCustomGraphicsItem();
QGraphicsRectItem* pRect = new QGraphicsRectItem(0, 0, 280, 30);
QGraphicsRectItem* pRect = new QGraphicsRectItem(0, 0, 290, 30);
pRect->setBrush(QBrush(QColor(255, 255, 255)));
pRect->setPen(pen);
pRect->setPos(0, 0);
@ -334,18 +334,18 @@ void CRealTimeForm::on_addchannel(channelBaseInfo channelbaseInfo,QString str)
pTextValue->setData(4,str);
QFont font;
font.setPixelSize(12);
QFont font2 ( "黑体", 14, 50);
font.setPixelSize(16);
QFont font2 ( "黑体", 18, 50);
font.setFamily(QStringLiteral("黑体"));
pTextUnits->setFont(font);
pTextUnits->setDefaultTextColor(QColor(27, 30, 35));
pTextChannel->setFont(font);
pTextValue->setFont(font2);
pTextValue->setPos(150,3);
pTextValue->setPos(150,0);
pTextValue->setDefaultTextColor(QColor(31, 81, 136));
pTextChannel->setPos(0,5);
pTextChannel->setPos(0,2);
pTextChannel->setDefaultTextColor(QColor(27, 30, 35));
pTextUnits->setPos(240,6);
pTextUnits->setPos(240,5);
// 设置可移动、可选择
@ -929,7 +929,7 @@ void CRealTimeForm::LoadGraphicsConfig(int type)
QGraphicsRectItem *pRect = new QGraphicsRectItem(
0,
0,
280, 30);
290, 30);
pRect->setPos(key["x"].toDouble(), key["y"].toDouble());
if(type == 1)
pRect->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
@ -954,8 +954,8 @@ void CRealTimeForm::LoadGraphicsConfig(int type)
pText->setTextInteractionFlags(Qt::TextEditorInteraction);
}
QFont font;
QFont font2 ( "黑体", 14, 50);
font.setPixelSize(12);
QFont font2 ( "黑体", 18, 50);
font.setPixelSize(16);
font.setFamily(QStringLiteral("黑体"));
pText->setFont(font);
if(key["data"].toString() == "units"){
@ -1105,8 +1105,33 @@ void CRealTimeForm::UpdateCharacteristic(QVector<_Charateristic>& m_vecCharateri
}else{
str = QString("%1").arg(QString::number(m_vecCharateristic[i].DCValues, 'f', m_vecCharateristic[i].ChUnitDot));
}
if(itemData2 == "平均值" && "THRUST" == m_vecCharateristic[i].channelType){
str = QString("%1").arg(QString::number(m_vecCharateristic[i].RMSValues, 'f', m_vecCharateristic[i].ChUnitDot));
int flag = -1;
if((g_mapTriggerEvent[strChannelID].DangerOver == 1 || g_mapTriggerEvent[strChannelID].DangerUnder == 1) \
&& itemData2 == g_mapTriggerEvent[strChannelID].Characteristic){
if((str.toFloat() < g_mapTriggerEvent[strChannelID].DangerUnderSetpoint.toFloat() && g_mapTriggerEvent[strChannelID].DangerUnder == 1) ||
(str.toFloat() > g_mapTriggerEvent[strChannelID].DangerOverSetpoint.toFloat() && g_mapTriggerEvent[strChannelID].DangerOver == 1)){
pGraphicTextItem->setDefaultTextColor(QColor(255, 0, 0));
flag = 1;
}
else{
pGraphicTextItem->setDefaultTextColor(QColor(31, 81, 136));
}
}
if((g_mapTriggerEvent[strChannelID].AlertOver == 1 || g_mapTriggerEvent[strChannelID].AlertUnder == 1) \
&& itemData2 == g_mapTriggerEvent[strChannelID].Characteristic && flag == -1){
QString strLog = "警报" + str + "," + g_mapTriggerEvent[strChannelID].AlertUnderSetpoint + "," + g_mapTriggerEvent[strChannelID].AlertOverSetpoint;
if((str.toFloat() < g_mapTriggerEvent[strChannelID].AlertUnderSetpoint.toFloat() && g_mapTriggerEvent[strChannelID].AlertUnder == 1 \
&& g_mapTriggerEvent[strChannelID].DangerUnder == 1 && str.toFloat() > g_mapTriggerEvent[strChannelID].DangerUnderSetpoint.toFloat()) ||\
(str.toFloat() > g_mapTriggerEvent[strChannelID].AlertOverSetpoint.toFloat() && g_mapTriggerEvent[strChannelID].AlertOver == 1 \
&& g_mapTriggerEvent[strChannelID].DangerOver == 0 ) ||\
(str.toFloat() > g_mapTriggerEvent[strChannelID].AlertOverSetpoint.toFloat() && g_mapTriggerEvent[strChannelID].AlertOver == 1 \
&& g_mapTriggerEvent[strChannelID].DangerOver == 1 && str.toFloat() < g_mapTriggerEvent[strChannelID].DangerOverSetpoint.toFloat())){
pGraphicTextItem->setDefaultTextColor(QColor(255, 165, 0));
}
else{
pGraphicTextItem->setDefaultTextColor(QColor(31, 81, 136));
}
}
sigRPM(RPM);
pGraphicTextItem->setPlainText(str);
@ -1138,41 +1163,44 @@ void CRealTimeForm::ParseCharacteristic(QJsonArray& arrayValue)
QVector<Charateristic_t>().swap(g_Charateristic);
_Charateristic tempCharateristic;
for (int i = 0; i < arrayValue.size(); i++) {
tempCharateristic.Amp1x = arrayValue.at(i)["1xAmp"].toDouble();
tempCharateristic.Phase1x = arrayValue.at(i)["1xPhase"].toDouble();
tempCharateristic.ChannelID = arrayValue.at(i)["ChannelId"].toString();
tempCharateristic.ChannelName = arrayValue.at(i)["ChannelName"].toString();
tempCharateristic.CrestFactor = arrayValue.at(i)["CrestFactor"].toDouble();
tempCharateristic.DCValues = arrayValue.at(i)["DCValues"].toDouble();
tempCharateristic.DerivedPeak = arrayValue.at(i)["DerivedPeak"].toDouble();
tempCharateristic.DiagnosisPeak = arrayValue.at(i)["DiagnosisPeak"].toDouble();
tempCharateristic.DiagnosisPk2Pk = arrayValue.at(i)["DiagnosisPk2Pk"].toDouble();
int enable = arrayValue.at(i)["isEnable"].toDouble();
if(enable == 1){
tempCharateristic.Amp1x = arrayValue.at(i)["1xAmp"].toDouble();
tempCharateristic.Phase1x = arrayValue.at(i)["1xPhase"].toDouble();
tempCharateristic.ChannelID = arrayValue.at(i)["ChannelId"].toString();
tempCharateristic.ChannelName = arrayValue.at(i)["ChannelName"].toString();
tempCharateristic.CrestFactor = arrayValue.at(i)["CrestFactor"].toDouble();
tempCharateristic.DCValues = arrayValue.at(i)["DCValues"].toDouble();
tempCharateristic.DerivedPeak = arrayValue.at(i)["DerivedPeak"].toDouble();
tempCharateristic.DiagnosisPeak = arrayValue.at(i)["DiagnosisPeak"].toDouble();
tempCharateristic.DiagnosisPk2Pk = arrayValue.at(i)["DiagnosisPk2Pk"].toDouble();
tempCharateristic.DirectPK = arrayValue.at(i)["DirectPK"].toDouble();
tempCharateristic.FullScalePosition = arrayValue.at(i)["FullScalePosition"].toDouble();
tempCharateristic.Gap = arrayValue.at(i)["Gap"].toDouble();
tempCharateristic.IntegratPk2Pk2 = arrayValue.at(i)["IntegratPk2Pk/2"].toDouble();
tempCharateristic.IntegratRMS = arrayValue.at(i)["IntegratRMS"].toDouble();
tempCharateristic.MaxValues = arrayValue.at(i)["MaxValues"].toDouble();
tempCharateristic.MinValues = arrayValue.at(i)["MinValues"].toDouble();
tempCharateristic.DirectPK = arrayValue.at(i)["DirectPK"].toDouble();
tempCharateristic.FullScalePosition = arrayValue.at(i)["FullScalePosition"].toDouble();
tempCharateristic.Gap = arrayValue.at(i)["Gap"].toDouble();
tempCharateristic.IntegratPk2Pk2 = arrayValue.at(i)["IntegratPk2Pk/2"].toDouble();
tempCharateristic.IntegratRMS = arrayValue.at(i)["IntegratRMS"].toDouble();
tempCharateristic.MaxValues = arrayValue.at(i)["MaxValues"].toDouble();
tempCharateristic.MinValues = arrayValue.at(i)["MinValues"].toDouble();
tempCharateristic.MonitorPk2Pk = arrayValue.at(i)["MonitorPk2Pk"].toDouble();
tempCharateristic.Position = arrayValue.at(i)["Position"].toDouble();
tempCharateristic.RmsPkPk2Pk = arrayValue.at(i)["RmsPkPk2Pk"].toDouble();
tempCharateristic.SensorEngineeringUnit = arrayValue.at(i)["SensorEngineeringUnit"].toString();
tempCharateristic.SensorStatus = arrayValue.at(i)["SensorStatus"].toDouble();
tempCharateristic.MonitorPk2Pk = arrayValue.at(i)["MonitorPk2Pk"].toDouble();
tempCharateristic.Position = arrayValue.at(i)["Position"].toDouble();
tempCharateristic.RmsPkPk2Pk = arrayValue.at(i)["RmsPkPk2Pk"].toDouble();
tempCharateristic.SensorEngineeringUnit = arrayValue.at(i)["SensorEngineeringUnit"].toString();
tempCharateristic.SensorStatus = arrayValue.at(i)["SensorStatus"].toDouble();
tempCharateristic.ZeroScalePosition = arrayValue.at(i)["ZeroScalePosition"].toDouble();
tempCharateristic.xFullScalePosition = arrayValue.at(i)["xFullScalePosition"].toDouble();
tempCharateristic.xProcessVariableName = arrayValue.at(i)["xProcessVariableName"].toString();
tempCharateristic.xZeroScalePosition = arrayValue.at(i)["xZeroScalePosition"].toDouble();
tempCharateristic.RMSValues = arrayValue.at(i)["RMSValues"].toDouble();
tempCharateristic.speedRPM = arrayValue.at(i)["SpeedProfileSpeed"].toDouble();
tempCharateristic.ChUnitDot = arrayValue.at(i)["ChUnitDot"].toInt();
tempCharateristic.channelType = arrayValue.at(i)["ChannelType"].toString();
tempCharateristic.ZeroScalePosition = arrayValue.at(i)["ZeroScalePosition"].toDouble();
tempCharateristic.xFullScalePosition = arrayValue.at(i)["xFullScalePosition"].toDouble();
tempCharateristic.xProcessVariableName = arrayValue.at(i)["xProcessVariableName"].toString();
tempCharateristic.xZeroScalePosition = arrayValue.at(i)["xZeroScalePosition"].toDouble();
tempCharateristic.RMSValues = arrayValue.at(i)["RMSValues"].toDouble();
tempCharateristic.speedRPM = arrayValue.at(i)["SpeedProfileSpeed"].toDouble();
tempCharateristic.ChUnitDot = arrayValue.at(i)["ChUnitDot"].toInt();
tempCharateristic.channelType = arrayValue.at(i)["ChannelType"].toString();
m_vecCharateristic.push_back(tempCharateristic);
g_Charateristic.push_back(tempCharateristic);
m_vecCharateristic.push_back(tempCharateristic);
g_Charateristic.push_back(tempCharateristic);
}
}
UpdateCharacteristic(m_vecCharateristic);
}

View File

@ -58,6 +58,21 @@ int SqliteDB::OpenDataBase()
strSql = "ALTER TABLE t_ChannelSetting ADD COLUMN 'firstPoleNum' text";
ExeSqlData(strSql);
}
strSql = QString("select count(*) from %1 where name = '%2' and sql LIKE '%%3%' ")\
.arg("sqlite_master").arg("t_TriggerConfig").arg("operate");
iRet = ExeSqlData(strSql);
if(iRet == 0){
strSql = "ALTER TABLE t_TriggerConfig ADD COLUMN 'operate' integer";
ExeSqlData(strSql);
}
// strSql = QString("select count(*) from %1 where name = '%2' and sql LIKE '%%3%' ")\
// .arg("sqlite_master").arg("t_WorkCondition").arg("operate");
// iRet = ExeSqlData(strSql);
// if(iRet == 0){
// strSql = "ALTER TABLE t_WorkCondition ADD COLUMN 'operate' integer";
// ExeSqlData(strSql);
// }
return 0;
}
}
@ -408,7 +423,9 @@ SqliteDB::GetTriggerConfig(QString tablename,QString whereCon)
tempTriggerConfig.AlertTriggerDelay = sql_query.value(15).toString();
tempTriggerConfig.DangerTriggerDelay = sql_query.value(16).toString();
tempTriggerConfig.TriggerType = sql_query.value(17).toString();
tempTriggerConfig.operate = sql_query.value(18).toInt();
vecResult.append(tempTriggerConfig);
g_mapTriggerEvent[tempTriggerConfig.ChannelID] = tempTriggerConfig;
}
}
return vecResult;