优化bug

This commit is contained in:
Zhang0626 2022-08-05 19:46:35 +08:00
parent a25359713e
commit 9ac105367f
6 changed files with 572 additions and 282 deletions

View File

@ -422,6 +422,51 @@ double Calculation::Phase(QVector<double> & vecData)
return Phase2 - Phase1; return Phase2 - Phase1;
} }
void Calculation::_Integration(QVector<double> & vecData,QVector<double>& retData,double& RMS)
{
QVector<double> realshiftfft;
QVector<double> imageshiftfft;
QVector<double> realvalue,imagevalue;
_FFT(vecData,realshiftfft,imageshiftfft);
for (int i = 0; i < 10; i++) {
realshiftfft[i] = 0;
imageshiftfft[i] = 0;
}
for (int i = 1000; i < realshiftfft.size(); i++) {
realshiftfft[i] = 0;
imageshiftfft[i] = 0;
}
qDebug()<< realshiftfft.size() << endl;
qDebug()<< imageshiftfft.size() << endl;
for(int k = 1; k < realshiftfft.size()+1;k++){
realvalue.push_back((realshiftfft.at(k-1)/(k*2*3.14))*1000 * 2);//单位转换mm/s,*1000 *2 精度损失
imagevalue.push_back((imageshiftfft.at(k-1)/(k*2*3.14))*1000 * 2);//单位转换mm/s,*1000
}
_iFFT(realvalue,imagevalue,retData);
float Sum = 0.0;
for(int j = 0; j < retData.size();j++){
float fData = retData[j]*retData[j];
Sum += fData;
}
RMS = sqrt(Sum/(float)retData.size()); //有效值
}
void Calculation::_Differentiation(QVector<double> & vecData,QVector<double>& retData)
{
retData.push_back(vecData[0]);
for(int j = 1; j < vecData.size()-3;j++)
{
retData.push_back((vecData.at(j+1)-vecData.at(j-1))/(double)(2*1/(double)vecData.size()));
}
retData.push_back(vecData.at(vecData.size()-1));
}
QVector<double> Calculation::ComputeDenCoeffs(int FilterOrder, double Lcutoff, double Ucutoff) QVector<double> Calculation::ComputeDenCoeffs(int FilterOrder, double Lcutoff, double Ucutoff)
{ {
int k; // loop variables int k; // loop variables

View File

@ -71,7 +71,10 @@ public:
void _fft(QVector<double> & vecData, QVector<double> & vecFFTrealData,QVector<double> & vecFFTimageData); void _fft(QVector<double> & vecData, QVector<double> & vecFFTrealData,QVector<double> & vecFFTimageData);
void _iFFT(QVector<double> & vecData, QVector<double> & vecFFTSpecData,QVector<double> & veciFFTData); void _iFFT(QVector<double> & vecData, QVector<double> & vecFFTSpecData,QVector<double> & veciFFTData);
//积分
void _Integration(QVector<double> & vecData,QVector<double>& retData,double& RMS);
//微分
void _Differentiation(QVector<double> & vecData,QVector<double>& retData);
//包络图谱数据 //包络图谱数据
void envSpec(QVector<double> & vecData, QVector<double> & vecEnvSpecData,int StartFrequency,int EndFrequency,bool PolarPlot=false); void envSpec(QVector<double> & vecData, QVector<double> & vecEnvSpecData,int StartFrequency,int EndFrequency,bool PolarPlot=false);

File diff suppressed because it is too large Load Diff

View File

@ -102,6 +102,7 @@ public:
void CalculateDifferentiation(bool isDoubleDifferentiation = false); void CalculateDifferentiation(bool isDoubleDifferentiation = false);
void EnableBtn(); void EnableBtn();
void UpdateDiffMenu(); void UpdateDiffMenu();
void InitIntegration();
QVector<WAVE_DATA> childWave; QVector<WAVE_DATA> childWave;
QVector<WAVE_DATA> OrbitXWave,OrbitYWave; QVector<WAVE_DATA> OrbitXWave,OrbitYWave;
QVector<KeyPhasor> vecKeyPhasor; QVector<KeyPhasor> vecKeyPhasor;
@ -180,7 +181,7 @@ private:
QAction *Rad; QAction *Rad;
QCPAxis *yAxis3; QCPAxis *yAxis3;
QList<QCPAxis*> axes; QList<QCPAxis*> Axis;
QCPItemTracer *tracer; //游标 QCPItemTracer *tracer; //游标
QCPItemTracer *tracer2; //游标 QCPItemTracer *tracer2; //游标

View File

@ -683,7 +683,11 @@ void MainWidget::addChildItem(QTreeWidgetItem *pDataItem,QTreeWidgetItem *pNoIte
filename = datpath + sfileName; filename = datpath + sfileName;
QFileInfo file(filename); QFileInfo file(filename);
if(file.exists()){ if(file.exists()){
qDebug() << datpath << endl;
QIcon icon(":/images/images/imgTreeIcon/remove6.png");
pNewItem->setIcon(0, icon);
pNewItem->setData(0,FILE_ROLE,0);
pSizeItem->addChild(pNewItem);
}else{ }else{
QIcon icon(":/images/images/imgTreeIcon/remove2.png"); QIcon icon(":/images/images/imgTreeIcon/remove2.png");
pNewItem->setIcon(0, icon); pNewItem->setIcon(0, icon);
@ -698,7 +702,10 @@ void MainWidget::addChildItem(QTreeWidgetItem *pDataItem,QTreeWidgetItem *pNoIte
filename = datpath + sfileName; filename = datpath + sfileName;
QFileInfo file(filename); QFileInfo file(filename);
if(file.exists()){ if(file.exists()){
QIcon icon(":/images/images/imgTreeIcon/remove6.png");
pNewItem->setIcon(0, icon);
pNewItem->setData(0,FILE_ROLE,0);
pSizeItem->addChild(pNewItem);
}else{ }else{
QIcon icon(":/images/images/imgTreeIcon/remove2.png"); QIcon icon(":/images/images/imgTreeIcon/remove2.png");
pNewItem->setIcon(0, icon); pNewItem->setIcon(0, icon);
@ -713,6 +720,9 @@ void MainWidget::addChildItem(QTreeWidgetItem *pDataItem,QTreeWidgetItem *pNoIte
filename = datpath + sfileName; filename = datpath + sfileName;
QFileInfo file(filename); QFileInfo file(filename);
if(file.exists()){ if(file.exists()){
QIcon icon(":/images/images/imgTreeIcon/remove6.png");
pNewItem->setIcon(0, icon);
pNewItem->setData(0,FILE_ROLE,0);
pSizeItem->addChild(pNewItem); pSizeItem->addChild(pNewItem);
}else{ }else{
QIcon icon(":/images/images/imgTreeIcon/remove2.png"); QIcon icon(":/images/images/imgTreeIcon/remove2.png");
@ -1183,9 +1193,6 @@ void MainWidget::ItemCheckStateSlot(QString strID, bool bChecked)
QString strChannelType = iter.value().at(0).sensorType; QString strChannelType = iter.value().at(0).sensorType;
if(strChannelType != "PROXIMETER") if(strChannelType != "PROXIMETER")
return; return;
qDebug() << "speedChannelID" << speedChannelID << endl;
qDebug() << "ChannelID" << ChannelID << endl;
qDebug() << "size" << mapWaveData[ChannelID].size() << endl;
if(speedChannelID == "NONE" || speedChannelID == ""){ if(speedChannelID == "NONE" || speedChannelID == ""){
MyMsgBox(QMessageBox::Warning,"警告","当前文件中没有转速通道数据"); MyMsgBox(QMessageBox::Warning,"警告","当前文件中没有转速通道数据");
return; return;
@ -1249,7 +1256,7 @@ void MainWidget::ItemCheckStateSlot(QString strID, bool bChecked)
if((iter.key() == strChannelID)){ if((iter.key() == strChannelID)){
QString ChannelID = iter.value().at(0).pairChannelID; QString ChannelID = iter.value().at(0).pairChannelID;
QString ChannelType = iter.value().at(0).sensorType; QString ChannelType = iter.value().at(0).sensorType;
if((ChannelType != "PROXIMETER") && (ChannelID == "NONE" || ChannelID == "")){ if((ChannelType != "PROXIMETER") /*&& (ChannelID == "NONE" || ChannelID == "")*/){
MyMsgBox(QMessageBox::Warning,"警告","请选择径向位移通道"); MyMsgBox(QMessageBox::Warning,"警告","请选择径向位移通道");
return; return;
} }
@ -1765,6 +1772,10 @@ void MainWidget::View3D()
} }
void MainWidget::Dat2Csv() void MainWidget::Dat2Csv()
{ {
if(mapWaveData.size() < 1){
MyMsgBox(QMessageBox::Warning,"警告","请先打开数据文件!");
return;
}
QString dirpath = QFileDialog::getExistingDirectory(this, QStringLiteral("选择目录"), "./", QFileDialog::ShowDirsOnly); QString dirpath = QFileDialog::getExistingDirectory(this, QStringLiteral("选择目录"), "./", QFileDialog::ShowDirsOnly);
if(dirpath.isEmpty()) return; if(dirpath.isEmpty()) return;
@ -2220,7 +2231,7 @@ void MainWidget::ReadDatData(QString strPath,QString strFileName,QString strIP)
for (int i = 0; i < waveSize; i++) { for (int i = 0; i < waveSize; i++) {
file.read((char *)&f, sizeof(f)); file.read((char *)&f, sizeof(f));
m_WaveChnData[j].channelId = buf; m_WaveChnData[j].channelId = buf;
m_WaveChnData[j].waveData.push_back(f); m_WaveChnData[j].waveData.push_back((double)f);
m_WaveChnData[j].Second = Count; m_WaveChnData[j].Second = Count;
} }
@ -2256,13 +2267,13 @@ void MainWidget::ReadDatData(QString strPath,QString strFileName,QString strIP)
if(iter->channelId.left(15) == m_WaveChnData[i].channelId.left(15)){ if(iter->channelId.left(15) == m_WaveChnData[i].channelId.left(15)){
wave.waveData = m_WaveChnData[i].waveData; wave.waveData = m_WaveChnData[i].waveData;
float sum = 0.0; double sum = 0.0;
if(iter->sensorType == "ACCELEROMETER" || iter->sensorType == "MICROPHONE" || if(iter->sensorType == "ACCELEROMETER" || iter->sensorType == "MICROPHONE" ||
iter->sensorType == "PROXIMETER" || iter->sensorType == "VELOCITY" || iter->sensorType == "PROXIMETER" || iter->sensorType == "VELOCITY" ||
iter->sensorType == "TACHOMETER" || iter->sensorType == "THRUST" || iter->sensorType == "TACHOMETER" || iter->sensorType == "THRUST" ||
iter->sensorType == "FAST_VOLTAGE"){ iter->sensorType == "FAST_VOLTAGE"){
sum = std::accumulate(std::begin(wave.waveData), std::end(wave.waveData), 0.0); sum = std::accumulate(std::begin(wave.waveData), std::end(wave.waveData), 0.0);
float size = m_WaveChnData[i].waveData.size(); double size = m_WaveChnData[i].waveData.size();
wave.mean = sum/size; wave.mean = sum/size;
}else{ }else{

View File

@ -22,7 +22,7 @@ typedef struct tag_WAVE_DATA{
int channelNo; int channelNo;
int Time; int Time;
QString pairChannelID; QString pairChannelID;
QVector<float> waveData; QVector<double> waveData;
QVector<double> waveDataRealTime; QVector<double> waveDataRealTime;
QColor linColor; QColor linColor;
QVector<double> SpeedProfileSpeed; QVector<double> SpeedProfileSpeed;
@ -63,7 +63,7 @@ typedef struct {
typedef struct { typedef struct {
int Second; int Second;
QString channelId; QString channelId;
QVector<float> waveData; QVector<double> waveData;
QVector<double> TimeStamp; QVector<double> TimeStamp;
} WAVE_CHNDATA; } WAVE_CHNDATA;
@ -89,12 +89,13 @@ typedef struct {
QVector<double> wavedata; //原始数据 QVector<double> wavedata; //原始数据
QVector<double> wavedataEnv;//包络数据 QVector<double> wavedataEnv;//包络数据
QVector<double> wavedata_DC; QVector<double> wavedata_DC;
QVector<double> wavedataFre;//频域数据
QVector<double> TimeStamp; QVector<double> TimeStamp;
QColor linColor; QColor linColor;
QString channelType; QString channelType;
QString sensorEngineeringUnit; QString sensorEngineeringUnit;
int SamleRate; int SamleRate;
float mean; double mean;
double meanRpm; double meanRpm;
QString channleName; QString channleName;
int iTrigger; int iTrigger;
@ -102,6 +103,7 @@ typedef struct {
float iTriggerValue; float iTriggerValue;
float iHysteresis; float iHysteresis;
bool tachAutoTach; bool tachAutoTach;
double RMS;
} WAVE_DISPALYDATA; } WAVE_DISPALYDATA;
typedef struct{ typedef struct{