Merge branch 'master' into Dev

# Conflicts:
#	ChaosDataPlayer/ChildForm.cpp
This commit is contained in:
Zhang0626 2022-08-05 19:50:05 +08:00
commit a1250befa0
4 changed files with 486 additions and 198 deletions

View File

@ -189,6 +189,9 @@ ChildForm::ChildForm(FormType iType,QString m_strName,DEVICE_INFO* DeviceInfo,QW
ui->widget->yAxis2->setVisible(false);
ui->widget->yAxis2->setTickLabels(true);
ui->widget->yAxis2->grid()->setVisible(true);
yAxis3 = ui->widget->axisRect()->addAxis(QCPAxis::atRight);
yAxis3->setTickLabelColor(Qt::white);
@ -196,10 +199,11 @@ ChildForm::ChildForm(FormType iType,QString m_strName,DEVICE_INFO* DeviceInfo,QW
yAxis3->setLabelColor(Qt::white);
yAxis3->setTickLabels(true);
yAxis3->setVisible(false);
yAxis3->grid()->setVisible(true);
axes.append(ui->widget->yAxis);
axes.append(ui->widget->yAxis2);
axes.append(yAxis3);
Axis.append(ui->widget->yAxis);
Axis.append(ui->widget->yAxis2);
Axis.append(yAxis3);
//ui->widget->setInteractions(QCP::iSelectPlottables);
//鼠标点击
@ -240,6 +244,55 @@ ChildForm::~ChildForm()
}
void ChildForm::InitDisPaly()
{
// QMap<QString,QMap<QString,QCPAxis*>>::Iterator itermultiGraph = mapMultiGraph.begin();
// for(int i = 0; i < listChannelID.size();i++){
// for(;itermultiGraph != mapMultiGraph.end();itermultiGraph++){
// int flag = 0;
// QMap<QString,QCPAxis*>::Iterator iterGraph = itermultiGraph.value().begin();
// for(iterGraph = itermultiGraph.value().begin();iterGraph != itermultiGraph.value().end();iterGraph++){
// if(iterGraph.key() == listChannelID[i]){
// if(mapMultiGraph[itermultiGraph.key()].size() == 1){
// iterGraph.value()->setVisible(false);
// }
// mapMultiGraph[itermultiGraph.key()].erase(iterGraph);
// }
// if(mapMultiGraph[itermultiGraph.key()].size() == 0){
// flag = 1;
// break;
// }
// }
// if(flag ==1){
// mapMultiGraph.erase(itermultiGraph);
// }
// if(mapMultiGraph.size() == 0)
// break;
// }
// QMap<QString,QCPGraph*>::Iterator iter = waveGraph.begin();
// for(iter = waveGraph.begin();iter != waveGraph.end();iter++)
// {
// if(listChannelID[i] == iter.key()){
// qDebug() << listChannelID[i] << endl;
// ui->widget->removeGraph(iter.value());
// line --;
// qDebug() << "line" << line << endl;
// int graphCount = ui->widget->graphCount();
// qDebug() << "graphCount" << graphCount<< endl;
// waveGraph.erase(iter);
// }
// if(waveGraph.size() == 0){
// m_bRealTime = false;
// ui->realTimeDataBtn->setChecked(false);
// EnableBtn();
// break;
// }
// }
// }
// QMap<QString,QVector<WAVE_DISPALYDATA>>::Iterator iter = mapWaveDisplayData.begin();
// for(iter = mapWaveDisplayData.begin();iter !=mapWaveDisplayData.end();iter++){
// for (int i = 0;iter.value().size() ;i ++ ) {
@ -502,29 +555,29 @@ QCPGraph* ChildForm::MultiyAxis(QString strID,QString sensorType,QString sensorE
qDebug() << "contains" << endl;
if(mapMultiGraph.size() == 0){
qDebug() << "mapMultiGraph1" << endl;
graph = ui->widget->addGraph(ui->widget->xAxis, axes[0]);
ui->widget->yAxis->setLabel(sensorType + "(" + sensorEngineeringUnit+")");
axes[0]->setVisible(true);
mapGraph.insert(strID,axes[0]);
qDebug() << "mapMultiGraph1" << sensorEngineeringUnit << endl;
graph = ui->widget->addGraph(ui->widget->xAxis, Axis[0]);
ui->widget->yAxis->setLabel( sensorEngineeringUnit);
Axis[0]->setVisible(true);
mapGraph.insert(strID,Axis[0]);
}
else if(mapMultiGraph.size() == 2 || mapMultiGraph.size() == 1){
qDebug() << "mapMultiGraph3" << endl;
QList<QCPAxis*> tmpaxes;
for(int i = 0 ; i < axes.size();i++){
QList<QCPAxis*> tmpAxis;
for(int i = 0 ; i < Axis.size();i++){
QMap<QString,QMap<QString,QCPAxis*>>::iterator iter = mapMultiGraph.begin();
for(;iter != mapMultiGraph.end();iter ++){
QMap<QString,QCPAxis*>::iterator iterGraph = iter.value().begin();
if(axes[i] == iterGraph.value()){
tmpaxes.push_back(axes[i]);
if(Axis[i] == iterGraph.value()){
tmpAxis.push_back(Axis[i]);
}
}
if(i == axes.size()-1){
if(i == Axis.size()-1){
int eql1 = 0;
for(int k = 0 ; k < axes.size();k++){
for(int j = 0; j < tmpaxes.size();j++){
if(axes[k] == tmpaxes[j]){
for(int k = 0 ; k < Axis.size();k++){
for(int j = 0; j < tmpAxis.size();j++){
if(Axis[k] == tmpAxis[j]){
eql1 = 1;
break;
}else{
@ -534,10 +587,10 @@ QCPGraph* ChildForm::MultiyAxis(QString strID,QString sensorType,QString sensorE
if(eql1 == 1){
continue;
}
graph = ui->widget->addGraph(ui->widget->xAxis, axes[k]);
axes[k]->setLabel(sensorType + "(" + sensorEngineeringUnit+")");
axes[k]->setVisible(true);
mapGraph.insert(strID,axes[k]);
graph = ui->widget->addGraph(ui->widget->xAxis, Axis[k]);
Axis[k]->setLabel(sensorEngineeringUnit);
Axis[k]->setVisible(true);
mapGraph.insert(strID,Axis[k]);
break;
}
}
@ -551,6 +604,7 @@ QCPGraph* ChildForm::MultiyAxis(QString strID,QString sensorType,QString sensorE
QMap<QString,QCPAxis*>::iterator iterGraph = iter.value().begin();
graph = ui->widget->addGraph(ui->widget->xAxis, iterGraph.value());
iterGraph.value()->setLabel(sensorEngineeringUnit);
mapGraph.insert(strID,iterGraph.value());
qDebug() << "strID1" << strID << endl;
}
@ -600,6 +654,7 @@ void ChildForm::SecondData(const QString& strID,WAVE_DATA& waveData,WAVE_DISPALY
waveShowData.Key.push_back(f);
waveShowData.wavedata_DC.push_back(waveData.waveDataRealTime.at(j));
}
<<<<<<< HEAD
if(m_bIntegration){
QVector<double> retValue;
double RMS = 0.0;
@ -608,6 +663,9 @@ void ChildForm::SecondData(const QString& strID,WAVE_DATA& waveData,WAVE_DISPALY
waveShowData.wavedata = retValue;
waveShowData.RMS = RMS;
}
=======
>>>>>>> master
qDebug() << "waveShowData.wavedata_DC" << waveShowData.wavedata_DC.size()<< endl;
}else{
QVector<double> vecOutData;
@ -624,7 +682,68 @@ void ChildForm::SecondData(const QString& strID,WAVE_DATA& waveData,WAVE_DISPALY
waveShowData.wavedata = vecOutData;
}
}
if(m_bIntegration){
QVector<double> retValue;
double RMS = 0.0;
f = 0.0;
pCalculation->_Integration(waveShowData.wavedata,retValue,RMS);
QVector<double>().swap(waveShowData.wavedata);
QVector<double>().swap(waveShowData.Key);
waveShowData.wavedata = retValue;
for(int ii = 0; ii < retValue.size();ii++){
f += gap;
waveShowData.Key.push_back(f);
}
waveShowData.RMS = RMS;
}
if(m_bDoubleIntegration){
QVector<double> retValue,retValue2;
double RMS = 0.0;
f = 0.0;
pCalculation->_Integration(waveShowData.wavedata,retValue,RMS);
pCalculation->_Integration(retValue,retValue2,RMS);
QVector<double>().swap(waveShowData.wavedata);
QVector<double>().swap(waveShowData.Key);
waveShowData.wavedata = retValue2;
waveShowData.RMS = RMS;
for(int ii = 0; ii < retValue2.size();ii++){
f += gap;
waveShowData.Key.push_back(f);
}
}
if(m_bDifferentiation){
QVector<double> diffValue,yValue;
pCalculation->_Differentiation(waveShowData.wavedata,diffValue);
QVector<double>().swap(waveShowData.wavedata);
QVector<double>().swap(waveShowData.Key);
f = 0.0;
for(int ii = 0; ii < diffValue.size();ii++){
yValue.push_back(diffValue[ii]/(double)10000);
f += gap;
waveShowData.Key.push_back(f);
}
waveShowData.wavedata = yValue;
}
if(m_bDoubleDifferentiation){
QVector<double> diffValue,yValue,diffValue2,yValue2;
pCalculation->_Differentiation(waveShowData.wavedata,diffValue);
QVector<double>().swap(waveShowData.wavedata);
QVector<double>().swap(waveShowData.Key);
for(int ii = 0; ii < diffValue.size();ii++){
yValue.push_back(diffValue[ii]/(double)10000);
}
f = 0.0;
pCalculation->_Differentiation(yValue,diffValue2);
for(int i = 0 ; i < diffValue2.size();i++){
yValue2.push_back(diffValue2[i]/(double)10000);
f += gap;
waveShowData.Key.push_back(f);
}
waveShowData.wavedata = yValue2;
}
waveShowData.linColor = waveData.linColor;
waveShowData.channelType = waveData.sensorType;
waveShowData.sensorEngineeringUnit = waveData.sensorEngineeringUnit;
@ -659,8 +778,10 @@ void ChildForm::SecondData(const QString& strID,WAVE_DATA& waveData,WAVE_DISPALY
for(int jj = 0 ; jj < vecFFTSpecData.size();jj++){
waveShowData.Key.push_back(jj);
}
waveShowData.wavedata = vecFFTSpecData;
waveShowData.SamleRate = waveData.SamleRate;
waveShowData.mean = waveData.mean;
waveShowData.wavedata = waveData.waveData;
waveShowData.wavedataFre = vecFFTSpecData;
waveShowData.linColor = waveData.linColor;
waveShowData.channelType = waveData.sensorType;
waveShowData.sensorEngineeringUnit = waveData.sensorEngineeringUnit;
@ -699,8 +820,10 @@ void ChildForm::SecondData(const QString& strID,WAVE_DATA& waveData,WAVE_DISPALY
mapWaveDisplayData.insert(strID,waveShowData);
}
}
void ChildForm::UpdateDiffMenu()
{
if(m_iFormType == TimeDomainPlot || m_iFormType == FrequencyDomainPlot){
if(mapMultiGraph.contains("VELOCITY") && mapMultiGraph.contains("ACCELEROMETER")){
Integration->setEnabled(true);
doubleIntegration->setEnabled(false);
@ -747,6 +870,16 @@ void ChildForm::UpdateDiffMenu()
doubleDifferentiation->setEnabled(false);
}
if(mapMultiGraph.contains("TACHOMETER") && !mapMultiGraph.contains("THRUST")
&& !mapMultiGraph.contains("PROXIMETER") && !mapMultiGraph.contains("ACCELEROMETER")
&& !mapMultiGraph.contains("SLOW_CURRENT") && !mapMultiGraph.contains("FAST_VOLTAGE")
&& !mapMultiGraph.contains("VELOCITY") && !mapMultiGraph.contains("SLOW_CURRENT")
&& !mapMultiGraph.contains("MICROPHONE")){
Rad->setEnabled(true);
}else{
Rad->setEnabled(false);
}
}
}
void ChildForm::AddSeries(QString strID, QVector<WAVE_DATA>& waveData)
{
@ -758,27 +891,45 @@ void ChildForm::AddSeries(QString strID, QVector<WAVE_DATA>& waveData)
if(m_iFormType == TimeDomainPlot)//时域图
{
WAVE_DISPALYDATA waveShowData;
SecondData( strID,waveData[0], waveShowData);
SecondData( strID,waveData[m_position], waveShowData);
if(waveData[0].sensorType == "TACHOMETER"){
Rad->setEnabled(true);
}else{
Rad->setEnabled(false);
}
mapWaveDisplayData.insert(strID,waveShowData);
QCPGraph* graph = MultiyAxis(strID,waveShowData.channelType,waveShowData.sensorEngineeringUnit);
QString stryLabel = waveShowData.channelType + "(" + waveShowData.sensorEngineeringUnit +")";
if(m_bIntegration){
if(waveShowData.channelType =="VELOCITY"){
stryLabel = "PROXIMETER(um)";
}else if(waveShowData.channelType =="ACCELEROMETER"){
stryLabel = "Velocity(mm/s)";
}
}else if(m_bDoubleIntegration){
if(waveShowData.channelType =="ACCELEROMETER"){
stryLabel = "PROXIMETER(um)";
}
}else if(m_bDifferentiation){
if(waveShowData.channelType == "VELOCITY")
stryLabel = "ACCELEROMETER(m/s^2)";
else if(waveShowData.channelType == "THRUST" ||
waveShowData.channelType == "PROXIMETER")
stryLabel = "Velocity(mm/s)";
}else if(m_bDoubleDifferentiation){
stryLabel = "ACCELEROMETER(m/s^2)";
}
QCPGraph* graph = MultiyAxis(strID,waveShowData.channelType,stryLabel);
if(graph == NULL)
return;
if(waveData[0].sensorType == "ACCELEROMETER" || waveData[0].sensorType == "VELOCITY" ||
waveData[0].sensorType == "MICROPHONE"){
// if(waveData[m_position].sensorType == "ACCELEROMETER" || waveData[m_position].sensorType == "VELOCITY" ||
// waveData[m_position].sensorType == "MICROPHONE"){
ui->Btn_AC_DC->setEnabled(false);
}else{
ui->Btn_AC_DC->setEnabled(true);
}
// ui->Btn_AC_DC->setEnabled(false);
// }else{
// ui->Btn_AC_DC->setEnabled(true);
// }
if(!m_bDC)
{
@ -786,7 +937,7 @@ void ChildForm::AddSeries(QString strID, QVector<WAVE_DATA>& waveData)
}else{
ui->widget->graph(line)->setData(waveShowData.Key, waveShowData.wavedata_DC);
}
ui->widget->graph(line)->setName(waveData[0].channelName);
ui->widget->graph(line)->setName(waveData[m_position].channelName);
ui->widget->xAxis->setRange(0, 1);
UpdateDiffMenu();
@ -810,50 +961,68 @@ void ChildForm::AddSeries(QString strID, QVector<WAVE_DATA>& waveData)
ui->widget->xAxis->setRange(0, Time);
ui->widget->xAxis->setLabel("Time(s)");
waveTrendData.insert(strID,wavetempTrendData);
QCPGraph* graph = MultiyAxis(strID,waveData[0].sensorType,waveData[0].sensorEngineeringUnit);
QString stryLabel = waveData[m_position].sensorType + "(" + waveData[m_position].sensorEngineeringUnit +")";
QCPGraph* graph = MultiyAxis(strID,waveData[0].sensorType,stryLabel);
if(graph == NULL)
return;
if(waveData[0].sensorType == "TACHOMETER"){
ui->widget->graph(line)->setData(x, waveData[0].SpeedProfileSpeed);
ui->widget->graph(line)->setData(x, waveData[m_position].SpeedProfileSpeed);
}else{
ui->widget->graph(line)->setData(x, waveData[0].RMSValue);
ui->widget->graph(line)->setData(x, waveData[m_position].RMSValue);
}
ui->widget->graph(line)->setName(waveData[0].channelName);
ui->widget->replot(QCustomPlot::rpQueuedReplot);//刷新图表
}else if(m_iFormType == FrequencyDomainPlot){//频域图
if(waveData[0].sensorType == "ACCELEROMETER" || waveData[0].sensorType == "VELOCITY"){
Integration->setEnabled(true);
}else{
Integration->setEnabled(false);
}
WAVE_DISPALYDATA vecWaveDisplay;
SecondData( strID,waveData[0], vecWaveDisplay);
SecondData( strID,waveData[m_position], vecWaveDisplay);
mapWaveDisplayData.insert(strID,vecWaveDisplay);
ui->widget->xAxis->setRange(0, 1000);
QCPGraph* graph = MultiyAxis(strID,vecWaveDisplay.channelType,vecWaveDisplay.sensorEngineeringUnit);
QString stryLabel = vecWaveDisplay.channelType + "(" + vecWaveDisplay.sensorEngineeringUnit +")";
if(m_bIntegration){
if(vecWaveDisplay.channelType =="VELOCITY"){
stryLabel = "PROXIMETER(um)";
}else if(vecWaveDisplay.channelType =="ACCELEROMETER"){
stryLabel = "Velocity(mm/s)";
}
}else if(m_bDoubleIntegration){
if(vecWaveDisplay.channelType =="ACCELEROMETER"){
stryLabel = "PROXIMETER(um)";
}
}else if(m_bDifferentiation){
if(vecWaveDisplay.channelType == "VELOCITY")
stryLabel = "ACCELEROMETER(m/s^2)";
else if(vecWaveDisplay.channelType == "THRUST" ||
vecWaveDisplay.channelType == "PROXIMETER")
stryLabel = "Velocity(mm/s)";
}else if(m_bDoubleDifferentiation){
stryLabel = "ACCELEROMETER(m/s^2)";
}
QCPGraph* graph = MultiyAxis(strID,vecWaveDisplay.channelType,stryLabel);
if(graph == NULL)
return;
ui->widget->xAxis->setLabel("Frequency(Hz)");
ui->widget->graph(line)->setData(vecWaveDisplay.Key, vecWaveDisplay.wavedata);
ui->widget->graph(line)->setName(waveData[0].channelName);
ui->widget->graph(line)->setData(vecWaveDisplay.Key, vecWaveDisplay.wavedataFre);
ui->widget->graph(line)->setName(waveData[m_position].channelName);
UpdateDiffMenu();
}else if(m_iFormType == EnvChartPlot){//包络图
QVector<QVector<double>> wavetempData;
WAVE_DISPALYDATA vecWaveDisplay;
SecondData( strID,waveData[0], vecWaveDisplay);
QCPGraph* graph = MultiyAxis(strID,vecWaveDisplay.channelType,vecWaveDisplay.sensorEngineeringUnit);
SecondData( strID,waveData[m_position], vecWaveDisplay);
mapWaveDisplayData.insert(strID,vecWaveDisplay);
QString stryLabel = vecWaveDisplay.channelType + "(" + vecWaveDisplay.sensorEngineeringUnit +")";
QCPGraph* graph = MultiyAxis(strID,vecWaveDisplay.channelType,stryLabel);
if(graph == NULL)
return;
ui->widget->xAxis->setLabel("Frequency(Hz)");
ui->widget->xAxis->setRange(0, 1000);
qDebug() << "line" <<line << endl;
ui->widget->graph(line)->setData(vecWaveDisplay.Key, vecWaveDisplay.wavedataEnv);
ui->widget->graph(line)->setName(waveData[0].channelName);
ui->widget->graph(line)->setName(waveData[m_position].channelName);
}else if(m_iFormType == WaterFallPlot){//瀑布图
int k = 0;
@ -893,7 +1062,7 @@ void ChildForm::AddSeries(QString strID, QVector<WAVE_DATA>& waveData)
}
ui->widget->graph(0)->rescaleAxes();
ui->widget->xAxis->setRange(0, waveData[0].SamleRate/2);
ui->widget->xAxis->setRange(0, waveData[m_position].SamleRate/2);
ui->widget->xAxis->setLabel("Frequency(Hz)");
ui->widget->yAxis->setLabel(waveData[0].sensorType + "(" + waveData[0].sensorEngineeringUnit+")");
@ -1021,16 +1190,22 @@ void ChildForm::handlePlayWave(double position,double size )
qDebug() << iterAxis.key() << endl;
SecondData(listChannelID.at(i),iterWaveData.value()[position],waveShowData);
graph = ui->widget->addGraph(ui->widget->xAxis,iterAxis.value());
if(!m_bIntegration && !m_bDoubleIntegration &&
!m_bDifferentiation && !m_bDoubleDifferentiation){
iterAxis.value()->setLabel(waveShowData.channelType + "(" + waveShowData.sensorEngineeringUnit+")");
}
//iterAxis.value()->setLabel(waveShowData.channelType + "(" + waveShowData.sensorEngineeringUnit+")");
}
}
}
}
}
if(m_bRpm){
CalculateRPM();
}
if(m_bIntegration || m_bDoubleIntegration){
/*if(m_bIntegration || m_bDoubleIntegration){
if(m_bIntegration)
CalculateIntegration(false);
else if(m_bDoubleIntegration)
@ -1041,14 +1216,17 @@ void ChildForm::handlePlayWave(double position,double size )
CalculateDifferentiation(false);
else if(m_bDoubleDifferentiation)
CalculateDifferentiation(true);
}else
}*/else
{
if(m_bDC){
graph->setData(waveShowData.Key, waveShowData.wavedata_DC);
}else{
if(m_iFormType == EnvChartPlot){
graph->setData(waveShowData.Key, waveShowData.wavedataEnv);
}else{
}else if(m_iFormType == FrequencyDomainPlot){
graph->setData(waveShowData.Key, waveShowData.wavedataFre);
}else
{
graph->setData(waveShowData.Key, waveShowData.wavedata);
}
}
@ -1927,9 +2105,9 @@ void ChildForm::RemoveSeries(QString strID)
for(;itermultiGraph != mapMultiGraph.end();itermultiGraph++){
int flag = 0;
QMap<QString,QCPAxis*>::Iterator iterGraph = itermultiGraph.value().begin();
for(;iterGraph != itermultiGraph.value().end();iterGraph++){
for(iterGraph = itermultiGraph.value().begin();iterGraph != itermultiGraph.value().end();iterGraph++){
if(iterGraph.key() == strID){
if(mapMultiGraph[itermultiGraph.key()].size() == 1){
if(mapMultiGraph[itermultiGraph.key()].size() == 1){//当前Y轴最后一条数据清除时隐藏Y轴
iterGraph.value()->setVisible(false);
}
mapMultiGraph[itermultiGraph.key()].erase(iterGraph);
@ -2062,14 +2240,31 @@ void ChildForm::ItemPressSlot(QTableWidgetItem *item)
if(item->column() != 0) return;
QString strID = item->data(CHANNELID_ROLE).toString();
QString strType = item->data(CHANNELTYPE_ROLE).toString();
if(item->isSelected() && !item->checkState())
{
if(ui->widget->graphCount() == 3){
if(ui->widget->graphCount() == 3 && (m_iFormType == TimeDomainPlot ||
m_iFormType == FrequencyDomainPlot ||
m_iFormType == TrendChartPlot ||
m_iFormType == SpecChartPlot ||
m_iFormType == EnvChartPlot)){
item->setCheckState(Qt::Unchecked);
item->setSelected(false);
return;
}
if((m_iFormType == OrbitPlot || m_iFormType == ShaftCenterline || m_iFormType == PolarPlot) && (strType != "PROXIMETER" /*|| strType != "THRUST"*/)){
item->setCheckState(Qt::Unchecked);
item->setSelected(false);
return;
}else if(m_iFormType == BodePlot && strType != "ACCELEROMETER"){
item->setCheckState(Qt::Unchecked);
item->setSelected(false);
return;
}
item->setCheckState(Qt::Checked);
emit ItemCheckStateSignal(strID, true);
listChannelID.push_back(strID);
@ -2094,14 +2289,44 @@ void ChildForm::ItemChangedSlot(QTableWidgetItem *item)
QString strID = item->data(CHANNELID_ROLE).toString();
QString strType = item->data(CHANNELTYPE_ROLE).toString();
if(item->isSelected() && item->checkState())
{
if((m_iFormType == OrbitPlot || m_iFormType == ShaftCenterline || m_iFormType == PolarPlot) && (strType != "PROXIMETER" /*|| strType != "THRUST"*/)){
item->setCheckState(Qt::Unchecked);
item->setSelected(false);
return;
}else if(m_iFormType == BodePlot && strType != "ACCELEROMETER"){
item->setCheckState(Qt::Unchecked);
item->setSelected(false);
return;
}
}
if(item->checkState() && !item->isSelected())
{
if(ui->widget->graphCount() == 3 && m_iFormType != OrbitPlot){
if(ui->widget->graphCount() == 3 && (m_iFormType == TimeDomainPlot ||
m_iFormType == FrequencyDomainPlot ||
m_iFormType == TrendChartPlot ||
m_iFormType == SpecChartPlot ||
m_iFormType == EnvChartPlot)){
MyMsgBox(QMessageBox::Information,"提示","最大支持三条曲线");
item->setCheckState(Qt::Unchecked);
item->setSelected(false);
return;
}
if((m_iFormType == OrbitPlot || m_iFormType == ShaftCenterline || m_iFormType == PolarPlot) && (strType != "PROXIMETER" /*|| strType != "THRUST"*/)){
item->setCheckState(Qt::Unchecked);
item->setSelected(false);
return;
}else if(m_iFormType == BodePlot && strType != "ACCELEROMETER"){
item->setCheckState(Qt::Unchecked);
item->setSelected(false);
return;
}
item->setCheckState(Qt::Checked);
item->setSelected(true);
emit ItemCheckStateSignal(strID, true);
@ -2350,6 +2575,7 @@ void ChildForm::CalculateRPM()
WaveDisplay.channelType = iter.value().channelType;
WaveDisplay.sensorEngineeringUnit = iter.value().sensorEngineeringUnit;
WaveDisplay.SamleRate = iter.value().SamleRate;
WaveDisplay.channleName = iter.value().channleName;
//file.close();
mapWaveDisplayData_RPM.insert(iter.key(),WaveDisplay);
@ -2371,6 +2597,7 @@ void ChildForm::CalculateRPM()
pen.setWidth(0);
ui->widget->graph(i)->setPen(pen);
ui->widget->replot(QCustomPlot::rpImmediateRefresh);
ui->widget->graph(i)->setName(iter1.value().channleName);
waveGraph.insert(iter1.key(),graph);
QString xAxis = "";
xAxis = QString("Time(s) 平均转速:%1").arg(iter1.value().meanRpm);
@ -2458,9 +2685,9 @@ void ChildForm::ZoomBtnSlot_XY()
ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmNone);
int graphCount = ui->widget->graphCount();
if(graphCount > 0){
ui->widget->graph(0)->rescaleValueAxis();
ui->widget->graph(0)->rescaleAxes();
for(int i = 1; i < graphCount; i++){
ui->widget->graph(i)->rescaleValueAxis(true);
ui->widget->graph(i)->rescaleAxes(true);
}
ui->widget->replot();
@ -2517,22 +2744,22 @@ void ChildForm::ScalesY()
ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmNone);
ui->widget->setInteractions(QCP::iRangeZoom|QCP::iRangeDrag|QCP::iSelectAxes);
ui->widget->axisRect()->setRangeZoomFactor(1,1.2);
for(int i = 0; i < axes.size();i++){
if (axes[i]->selectedParts().testFlag(QCPAxis::spAxis))
ui->widget->axisRect()->setRangeZoomAxes(ui->widget->xAxis,axes[i]);
for(int i = 0; i < Axis.size();i++){
if (Axis[i]->selectedParts().testFlag(QCPAxis::spAxis))
ui->widget->axisRect()->setRangeZoomAxes(ui->widget->xAxis,Axis[i]);
}
//ui->widget->axisRect()->setRangeZoomAxes(ui->widget->xAxis,ui->widget->yAxis);
//ui->widget->axisRect()->setRangeZoomAxis(ui->widget->xAxis,ui->widget->yAxis);
}
void ChildForm::ScalesXY()
{
ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmNone);
ui->widget->setInteractions(QCP::iRangeZoom|QCP::iRangeDrag|QCP::iSelectAxes);
ui->widget->axisRect()->setRangeZoomFactor(1.2,1.2);
for(int i = 0; i < axes.size();i++){
if (axes[i]->selectedParts().testFlag(QCPAxis::spAxis))
ui->widget->axisRect()->setRangeZoomAxes(ui->widget->xAxis,axes[i]);
for(int i = 0; i < Axis.size();i++){
if (Axis[i]->selectedParts().testFlag(QCPAxis::spAxis))
ui->widget->axisRect()->setRangeZoomAxes(ui->widget->xAxis,Axis[i]);
}
//ui->widget->axisRect()->setRangeZoomAxes(ui->widget->xAxis,ui->widget->yAxis);
//ui->widget->axisRect()->setRangeZoomAxis(ui->widget->xAxis,ui->widget->yAxis);
}
void ChildForm::ScalesBox()
{
@ -2542,6 +2769,11 @@ void ChildForm::ScalesBox()
}
void ChildForm::Cursor()
{
if(tracer->visible())
tracer->setVisible(false);
else
tracer->setVisible(true);
ui->widget->setInteractions(QCP::iRangeZoom|QCP::iRangeDrag);
dismove = connect(ui->widget, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoveEvent(QMouseEvent*)));
disDoubleclick = connect(ui->widget, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, SLOT(mouseDoubleClickEvent(QMouseEvent*)));
@ -2560,11 +2792,21 @@ void ChildForm::slotSetScales(QString str)
QStringList strList = str.split(",");
qDebug() << "slotSetScales" << strList[2].toFloat()<<strList[3].toFloat() << endl;
ui->widget->xAxis->setRange(strList[0].toFloat(), strList[1].toFloat()-strList[0].toFloat(), Qt::AlignLeft);
for(int i = 0; i < axes.size();i++){
if (axes[i]->selectedParts().testFlag(QCPAxis::spAxis))
axes[i]->setRange(strList[2].toFloat(), strList[3].toFloat()-strList[2].toFloat(), Qt::AlignLeft);
}
int j = 0,ii = 0;
for(int i = 0; i < Axis.size();i++){
if(Axis[i]->visible()){
j ++;
ii = i;
}
if (Axis[i]->selectedParts().testFlag(QCPAxis::spAxis) && j > 1){
Axis[i]->setRange(strList[2].toFloat(), strList[3].toFloat()-strList[2].toFloat(), Qt::AlignLeft);
}
}
if(j == 1){
Axis[ii]->setRange(strList[2].toFloat(), strList[3].toFloat()-strList[2].toFloat(), Qt::AlignLeft);
}
ui->widget->replot(QCustomPlot::rpImmediateRefresh);
}
void ChildForm::slotSetFilter(QString str)
@ -2817,6 +3059,7 @@ void ChildForm::OnPlayWaveSound()
ui->Btn_Sound->setChecked(false);
std::unique_lock<std::mutex> lock(mu);
m_isPause = true;
EnableBtn();
m_cv.notify_one();
return;
}
@ -2885,17 +3128,17 @@ void ChildForm::realTimeData()
void ChildForm::SetDC()
{
QMap<QString,QMap<QString,QCPAxis*>>::iterator iter = mapMultiGraph.begin();
for(;iter != mapMultiGraph.end();iter ++){
if(iter.key() == "VELOCITY" || iter.key() == "MICROPHONE" || iter.key() == "ACCELEROMETER" ){
MyMsgBox(QMessageBox::Warning,"警告","加速度、速度信号、声音信号只有AC数据");
if(ui->Btn_AC_DC->isChecked()){
ui->Btn_AC_DC->setChecked(false);
ui->Btn_AC_DC->setEnabled(false);
}
return;
}
}
// QMap<QString,QMap<QString,QCPAxis*>>::iterator iter = mapMultiGraph.begin();
// for(;iter != mapMultiGraph.end();iter ++){
// if(iter.key() == "VELOCITY" || iter.key() == "MICROPHONE" || iter.key() == "ACCELEROMETER" ){
// MyMsgBox(QMessageBox::Warning,"警告","加速度、速度信号、声音信号只有AC数据");
// if(ui->Btn_AC_DC->isChecked()){
// ui->Btn_AC_DC->setChecked(false);
// ui->Btn_AC_DC->setEnabled(false);
// }
// return;
// }
// }
int graphCount = ui->widget->clearGraphs();
QMap<QString,QCPGraph*>().swap(waveGraph);
@ -2911,13 +3154,16 @@ void ChildForm::SetDC()
void ChildForm::CalculateIntegration(bool isDoubleIntegration)
{
ui->widget->clearGraphs();
QMap<QString,QCPGraph*>().swap(waveGraph);
QVector<double> x,y;
QVector<double> temDCWave;
<<<<<<< HEAD
=======
QString strLabel;
>>>>>>> master
QMap<QString,WAVE_DISPALYDATA>::Iterator iter = mapWaveDisplayData.begin();
for (int i = 0; i < listChannelID.size(); ++i){
for(;iter != mapWaveDisplayData.end();iter++){
for(iter = mapWaveDisplayData.begin();iter != mapWaveDisplayData.end();iter++){
if(listChannelID.at(i) == iter.key()){
QVector<double>().swap(x);
QVector<double>().swap(y);
@ -2939,22 +3185,25 @@ void ChildForm::CalculateIntegration(bool isDoubleIntegration)
key.push_back(f);
}
<<<<<<< HEAD
=======
if(iter.value().channelType =="ACCELEROMETER"){
strLabel = "PROXIMETER(um)";
}
QCPGraph* graph = MultiyAxis(iter.key(),iter.value().channelType,strLabel);
>>>>>>> master
ui->widget->xAxis->setRange(0, 1);
QCPGraph* graph = ui->widget->addGraph();
ui->widget->graph(i)->setData(key, Proximeter);
graph->setData(key, Proximeter);
// let the ranges scale themselves so graph 0 fits perfectly in the visible area:
ui->widget->graph(i)->rescaleValueAxis();
graph->rescaleValueAxis();
graph->setName(iter.value().channleName);
QPen pen;
pen.setColor(iter.value().linColor);
pen.setStyle(Qt::SolidLine);
pen.setWidth(0);
ui->widget->graph(i)->setPen(pen);
// give the axes some labels:
graph->setPen(pen);
// give the Axis some labels:
ui->widget->xAxis->setLabel("Time(s)");
if(iter.value().channelType =="ACCELEROMETER"){
ui->widget->yAxis->setLabel("PROXIMETER(um)");
}
waveGraph.insert(listChannelID.at(i), graph);
}else{
@ -2963,15 +3212,24 @@ void ChildForm::CalculateIntegration(bool isDoubleIntegration)
f += gap;
x.push_back(f);
}
if(iter.value().channelType =="VELOCITY"){
strLabel = "PROXIMETER(um)";
}else if(iter.value().channelType =="ACCELEROMETER"){
strLabel = "Velocity(mm/s)";
}
QCPGraph* graph = MultiyAxis(iter.key(),iter.value().channelType,strLabel);
ui->widget->xAxis->setRange(0, 1);
QCPGraph* graph = ui->widget->addGraph();
ui->widget->graph(i)->setData(x, y);
//QCPGraph* graph = ui->widget->addGraph();
graph->setData(x, y);
// let the ranges scale themselves so graph 0 fits perfectly in the visible area:
ui->widget->graph(i)->rescaleValueAxis();
graph->rescaleValueAxis();
graph->setName(iter.value().channleName);
QPen pen;
pen.setColor(iter.value().linColor);
pen.setStyle(Qt::SolidLine);
pen.setWidth(0);
<<<<<<< HEAD
ui->widget->graph(i)->setPen(pen);
// give the axes some labels:
// QString strRMS = QString("Time(s) %1: %2").arg( "RMS" ).arg(rms);
@ -2983,6 +3241,15 @@ void ChildForm::CalculateIntegration(bool isDoubleIntegration)
ui->widget->yAxis->setLabel("Velocity(mm/s)");
}
waveGraph.insert(listChannelID.at(i), graph);
=======
graph->setPen(pen);
// give the Axis some labels:
QString strRMS = QString("Time(s) %1: %2").arg( "RMS" ).arg(rms);
ui->widget->xAxis->setLabel(strRMS);
//waveGraph.insert(listChannelID.at(i), graph);
>>>>>>> master
}
ui->widget->replot(QCustomPlot::rpImmediateRefresh);
@ -2996,9 +3263,15 @@ void ChildForm::CalculateDifferentiation(bool isDoubleDifferentiation)
{
QVector<double> key,value,yValue,key2,yValue2;
QVector<double> temDCWave,diffValue,diffValue2;
<<<<<<< HEAD
=======
QString strLabel;
QCPGraph* graph = NULL;
qDebug() << mapWaveDisplayData.size() << endl;
>>>>>>> master
QMap<QString,WAVE_DISPALYDATA>::Iterator iter = mapWaveDisplayData.begin();
for (int i = 0; i < listChannelID.size(); ++i){
for(;iter != mapWaveDisplayData.end();iter++){
for(iter = mapWaveDisplayData.begin();iter != mapWaveDisplayData.end();iter++){
if(listChannelID.at(i) == iter.key()){
double gap,f;
f= 0.0;
@ -3016,8 +3289,6 @@ void ChildForm::CalculateDifferentiation(bool isDoubleDifferentiation)
key.push_back(f);
}
QCPGraph* graph = ui->widget->addGraph();
if(isDoubleDifferentiation){//二次微分
m_bDoubleDifferentiation = true;
QVector<double>().swap(diffValue2);
@ -3029,42 +3300,60 @@ void ChildForm::CalculateDifferentiation(bool isDoubleDifferentiation)
f += gap;
key2.push_back(f);
}
strLabel = "ACCELEROMETER(m/s^2)";
graph = MultiyAxis(iter.key(),iter.value().channelType,strLabel);
ui->widget->xAxis->setRange(0, 1);
ui->widget->graph(i)->setData(key2, yValue2);
ui->widget->yAxis->setLabel("ACCELEROMETER(m/s^2)");
graph->setData(key2, yValue2);
}else{
ui->widget->xAxis->setRange(0, 1);
<<<<<<< HEAD
ui->widget->graph(i)->setData(key, yValue);
if(iter.value().channelType == "VELOCITY")
ui->widget->yAxis->setLabel("ACCELEROMETER(mm/s)");
else if(iter.value().channelType == "THRUST" ||
iter.value().channelType == "PROXIMETER")
ui->widget->yAxis->setLabel("Velocity(mm/s)");
=======
if(iter.value().channelType == "VELOCITY")
strLabel = "ACCELEROMETER(m/s^2)";
else if(iter.value().channelType == "THRUST" ||
iter.value().channelType == "PROXIMETER")
strLabel = "Velocity(mm/s)";
graph = MultiyAxis(iter.key(),iter.value().channelType,strLabel);
graph->setData(key, yValue);
>>>>>>> master
}
waveGraph.insert(listChannelID.at(i), graph);
// let the ranges scale themselves so graph 0 fits perfectly in the visible area:
ui->widget->graph(i)->rescaleValueAxis();
graph->rescaleValueAxis();
QPen pen;
pen.setColor(iter.value().linColor);
pen.setStyle(Qt::SolidLine);
pen.setWidth(0);
ui->widget->graph(i)->setPen(pen);
graph->setPen(pen);
graph->setName(iter.value().channleName);
// give the axes some labels:
ui->widget->xAxis->setLabel("Time(s)");
<<<<<<< HEAD
=======
qDebug() << listChannelID.at(i) << endl;
>>>>>>> master
ui->widget->replot(QCustomPlot::rpImmediateRefresh);
}
}
}
}
void ChildForm::DoubleDifferentiationSlot()
{
qDebug() << "DoubleDifferentiationSlot" << endl;
if(listChannelID.size() > 1)
return;
// if(listChannelID.size() > 1)
// return;
ui->widget->clearGraphs();
if(m_bDoubleDifferentiation){
m_bDoubleDifferentiation = false;
@ -3077,12 +3366,13 @@ void ChildForm::DoubleDifferentiationSlot()
}
}
}
void ChildForm::DifferentiationSlot()
{
qDebug() << "differentiationSlot" << endl;
if(listChannelID.size() > 1)
return;
// if(listChannelID.size() > 1)
// return;
ui->widget->clearGraphs();
if(m_bDifferentiation){
m_bDifferentiation = false;
@ -3090,17 +3380,19 @@ void ChildForm::DifferentiationSlot()
}else{
m_bDifferentiation = true;
m_bDoubleDifferentiation = false;
m_bIntegration = false;
if(m_iFormType == TimeDomainPlot){
CalculateDifferentiation();
}
}
}
void ChildForm::DoubleIntegrationSlot(){
void ChildForm::DoubleIntegrationSlot()
{
qDebug() << "DoubleIntegrationSlot" << endl;
if(listChannelID.size() > 1)
return;
// if(listChannelID.size() > 1)
// return;
ui->widget->clearGraphs();
if(m_bDoubleIntegration){
m_bDoubleIntegration = false;
@ -3116,22 +3408,20 @@ void ChildForm::DoubleIntegrationSlot(){
void ChildForm::IntegrationSlot()
{
if(listChannelID.size() > 1)
return;
// if(listChannelID.size() > 1)
// return;
ui->widget->clearGraphs();
// InitDisPaly();
if(m_bIntegration){
m_bIntegration = false;
handlePlayWave(m_position);
}else{
m_bIntegration = true;
m_bDoubleIntegration = false;
m_bDifferentiation = false;
QVector<double> x,y,y1,realvalue,imagevalue;
QVector<double> temDCWave;
QVector<double> temHanning;
QVector<double> AddHanning;
QVector<double> realshiftfft;
QVector<double> imageshiftfft;
QVector<double> ifft;
if(m_iFormType == TimeDomainPlot){
CalculateIntegration();
}else if(m_iFormType == FrequencyDomainPlot){
@ -3141,30 +3431,27 @@ void ChildForm::IntegrationSlot()
if(listChannelID.at(i) == iter.key()){
QVector<double>().swap(x);
QVector<double>().swap(y);
QVector<double>().swap(realvalue);
QVector<double>().swap(imagevalue);
QVector<double>().swap(temDCWave);
QVector<double>().swap(realshiftfft);
QVector<double>().swap(imageshiftfft);
for(int j = 0; j < iter.value().SamleRate;j++){
temDCWave.push_back(iter.value().wavedata.at(j) - iter.value().mean);
}
//pCalculation->_FFT(temDCWave,realshiftfft,imageshiftfft);
pCalculation->FFTSpec(temDCWave,realshiftfft);
for (int i = 0; i < 10; i++) {
realshiftfft[i] = 0;
}
for (int i = 1000; i < realshiftfft.size(); i++) {
realshiftfft[i] = 0;
double f = iter.value().wavedata.at(j) - iter.value().mean;
temDCWave.push_back(f);
}
for(int k = 1; k < realshiftfft.size()+1;k++){
x.push_back(k - 1);
realvalue.push_back(realshiftfft.at(k-1)/(k*2*3.14)*1000);
double rms = 0.0;
pCalculation->_Integration(temDCWave,y,rms);
pCalculation->FFTSpec(y,realvalue);
for(int jj = 0 ; jj < realvalue.size();jj++){
x.push_back(jj);
}
ui->widget->xAxis->setRange(0, realvalue.size());
ui->widget->addGraph();
QString strLabel = "";
if(iter.value().channelType == "ACCELEROMETER")
strLabel = "Velocity(mm/s)";
else if(iter.value().channelType == "VELOCITY")
strLabel = "PROXIMETER(um)";
QCPGraph* graph = MultiyAxis(iter.key(),iter.value().channelType,strLabel);
//QCPGraph* graph = ui->widget->addGraph();
ui->widget->graph(i)->setData(x, realvalue);
// let the ranges scale themselves so graph 0 fits perfectly in the visible area:
ui->widget->graph(i)->rescaleValueAxis();
@ -3175,12 +3462,11 @@ void ChildForm::IntegrationSlot()
ui->widget->graph(i)->setPen(pen);
// give the axes some labels:
ui->widget->xAxis->setLabel("Frequency(Hz)");
ui->widget->yAxis->setLabel("Velocity(mm/s)");
ui->widget->replot(QCustomPlot::rpImmediateRefresh);
}
//waveGraph.insert(listChannelID.at(i), graph);
}
}
}
}
}

View File

@ -181,7 +181,7 @@ private:
QAction *Rad;
QCPAxis *yAxis3;
QList<QCPAxis*> axes;
QList<QCPAxis*> Axis;
QCPItemTracer *tracer; //游标
QCPItemTracer *tracer2; //游标

View File

@ -1193,9 +1193,6 @@ void MainWidget::ItemCheckStateSlot(QString strID, bool bChecked)
QString strChannelType = iter.value().at(0).sensorType;
if(strChannelType != "PROXIMETER")
return;
qDebug() << "speedChannelID" << speedChannelID << endl;
qDebug() << "ChannelID" << ChannelID << endl;
qDebug() << "size" << mapWaveData[ChannelID].size() << endl;
if(speedChannelID == "NONE" || speedChannelID == ""){
MyMsgBox(QMessageBox::Warning,"警告","当前文件中没有转速通道数据");
return;
@ -1259,7 +1256,7 @@ void MainWidget::ItemCheckStateSlot(QString strID, bool bChecked)
if((iter.key() == strChannelID)){
QString ChannelID = iter.value().at(0).pairChannelID;
QString ChannelType = iter.value().at(0).sensorType;
if((ChannelType != "PROXIMETER") && (ChannelID == "NONE" || ChannelID == "")){
if((ChannelType != "PROXIMETER") /*&& (ChannelID == "NONE" || ChannelID == "")*/){
MyMsgBox(QMessageBox::Warning,"警告","请选择径向位移通道");
return;
}
@ -1775,6 +1772,10 @@ void MainWidget::View3D()
}
void MainWidget::Dat2Csv()
{
if(mapWaveData.size() < 1){
MyMsgBox(QMessageBox::Warning,"警告","请先打开数据文件!");
return;
}
QString dirpath = QFileDialog::getExistingDirectory(this, QStringLiteral("选择目录"), "./", QFileDialog::ShowDirsOnly);
if(dirpath.isEmpty()) return;
@ -2230,7 +2231,7 @@ void MainWidget::ReadDatData(QString strPath,QString strFileName,QString strIP)
for (int i = 0; i < waveSize; i++) {
file.read((char *)&f, sizeof(f));
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;
}
@ -2266,13 +2267,13 @@ void MainWidget::ReadDatData(QString strPath,QString strFileName,QString strIP)
if(iter->channelId.left(15) == m_WaveChnData[i].channelId.left(15)){
wave.waveData = m_WaveChnData[i].waveData;
float sum = 0.0;
double sum = 0.0;
if(iter->sensorType == "ACCELEROMETER" || iter->sensorType == "MICROPHONE" ||
iter->sensorType == "PROXIMETER" || iter->sensorType == "VELOCITY" ||
iter->sensorType == "TACHOMETER" || iter->sensorType == "THRUST" ||
iter->sensorType == "FAST_VOLTAGE"){
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;
}else{

View File

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