2022-07-30 11:50:01 +08:00
|
|
|
|
#include "ChildForm.h"
|
|
|
|
|
|
#include "ui_ChildForm.h"
|
|
|
|
|
|
#include <QtCore/QtMath>
|
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
|
#include <QLineSeries>
|
|
|
|
|
|
#include <QValueAxis>
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
#include <QAudioFormat>
|
|
|
|
|
|
#include <QAudioOutput>
|
|
|
|
|
|
#include <QJsonArray>
|
|
|
|
|
|
#include <QJsonValue>
|
|
|
|
|
|
#include <QJsonDocument>
|
|
|
|
|
|
#include <QJsonObject>
|
|
|
|
|
|
#include <QScriptEngine>
|
|
|
|
|
|
#include <QScriptValueIterator>
|
|
|
|
|
|
#include "LegendForm.h"
|
|
|
|
|
|
#include "secure.h"
|
|
|
|
|
|
#include <gsl/gsl_poly.h>
|
|
|
|
|
|
#include "portaudio.h"
|
|
|
|
|
|
#include <thread>
|
|
|
|
|
|
#include <synchapi.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define FRAMES_PER_BUFFER (1024)
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef M_PI
|
|
|
|
|
|
#define M_PI (3.14159265)
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#define TABLE_SIZE (200)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define CHANNELID_ROLE (Qt::UserRole + 2)
|
|
|
|
|
|
#define CHANNELTYPE_ROLE (Qt::UserRole + 3)
|
|
|
|
|
|
|
|
|
|
|
|
ChildForm::ChildForm(FormType iType,QString m_strName,DEVICE_INFO* DeviceInfo,QWidget *parent) :
|
|
|
|
|
|
BaseWgt(parent),
|
|
|
|
|
|
ui(new Ui::ChildForm),
|
|
|
|
|
|
m_pChartView(nullptr),
|
|
|
|
|
|
m_iFormType(iType),
|
|
|
|
|
|
m_bAttach(false),
|
|
|
|
|
|
m_pLegendForm(nullptr),
|
|
|
|
|
|
m_iRealTimer(0),
|
|
|
|
|
|
m_bDC(false),
|
|
|
|
|
|
//m_client(nullptr),
|
|
|
|
|
|
m_bRpm(false),
|
|
|
|
|
|
m_bIntegration(false),
|
|
|
|
|
|
m_bDifferentiation(false),
|
|
|
|
|
|
m_bDoubleIntegration(false),
|
|
|
|
|
|
m_bDoubleDifferentiation(false),
|
|
|
|
|
|
m_isconnect(false),
|
|
|
|
|
|
m_bRealTime(false),
|
|
|
|
|
|
m_isPause(false),
|
2022-08-02 10:19:41 +08:00
|
|
|
|
m_isStop(true)
|
2022-07-30 11:50:01 +08:00
|
|
|
|
{
|
|
|
|
|
|
m_position = 0;
|
|
|
|
|
|
m_nStart = 0;
|
|
|
|
|
|
m_nEnd = 0;
|
|
|
|
|
|
ui->setupUi(m_pMainWgt);
|
|
|
|
|
|
SetFormType(iType);
|
|
|
|
|
|
setWindowTitle(m_strName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(ui->Btn_Open, SIGNAL(clicked()), this, SIGNAL(OutSig()));
|
|
|
|
|
|
connect(ui->Btn_Close, SIGNAL(clicked()), this, SIGNAL(ReturnSig()));
|
|
|
|
|
|
|
|
|
|
|
|
// connect(ui->zoomBtn_X, SIGNAL(clicked()), this, SLOT(ZoomBtnSlot_X()));
|
|
|
|
|
|
// connect(ui->zoomBtn_Y, SIGNAL(clicked()), this, SLOT(ZoomBtnSlot_Y()));
|
|
|
|
|
|
// connect(ui->Btn_Integration, SIGNAL(clicked()), this, SLOT(Integration()));
|
|
|
|
|
|
// connect(ui->zoomBtn_hand, SIGNAL(clicked()), this, SLOT(ZoomBtnSlot_Hand()));
|
|
|
|
|
|
// connect(ui->measureBtn, SIGNAL(clicked()), this, SLOT(MeasureBtnSlot()));
|
|
|
|
|
|
|
|
|
|
|
|
connect(ui->ChannelBtn, SIGNAL(clicked()), this, SLOT(ChannelBtnSlot())); //打开通道选择
|
|
|
|
|
|
connect(ui->zoomBtn_hand, SIGNAL(clicked()), this, SLOT(ZoomBtnSlot_Hand()));
|
|
|
|
|
|
connect(ui->Btn_Zoom, SIGNAL(clicked()), this, SLOT(Btn_ZoomSlot()));
|
|
|
|
|
|
connect(ui->Btn_setScales, SIGNAL(clicked()), this, SLOT(SetScales()));
|
|
|
|
|
|
connect(ui->temBtn_4, SIGNAL(clicked()), this, SLOT(SetFilter()));
|
|
|
|
|
|
connect(ui->Btn_AC_DC, SIGNAL(clicked()), this, SLOT(SetDC()));
|
|
|
|
|
|
connect(ui->realTimeDataBtn, SIGNAL(clicked()), this, SLOT(realTimeData()));
|
|
|
|
|
|
connect(ui->Btn_Sound, SIGNAL(clicked()), this, SLOT(OnPlayWaveSound()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(ui->tableWidget, SIGNAL(itemChanged(QTableWidgetItem *)), this, SLOT(ItemChangedSlot(QTableWidgetItem *)));
|
|
|
|
|
|
connect(ui->tableWidget, SIGNAL(itemPressed(QTableWidgetItem *)),SLOT(ItemPressSlot(QTableWidgetItem *)));
|
|
|
|
|
|
|
|
|
|
|
|
InitWidget();
|
|
|
|
|
|
mqttclient = new MqttClient(this);
|
|
|
|
|
|
mqttclient->ConnectMQTT(DeviceInfo->DeviceIP);
|
|
|
|
|
|
m_DeviceInfo = DeviceInfo;
|
|
|
|
|
|
line = 0;
|
|
|
|
|
|
ui->ChannelWgt->setVisible(false);
|
|
|
|
|
|
ui->tableWidget->setColumnWidth(0, 260);
|
|
|
|
|
|
ui->tableWidget->setColumnWidth(1, 20);
|
|
|
|
|
|
ui->tableWidget->setSelectionMode(QAbstractItemView::MultiSelection);
|
|
|
|
|
|
|
|
|
|
|
|
tracer = new QCPItemTracer(ui->widget);
|
|
|
|
|
|
tracer->setStyle(QCPItemTracer::tsCrosshair);
|
|
|
|
|
|
tracer->setPen(QPen(Qt::red));
|
|
|
|
|
|
tracer->setBrush(Qt::red);
|
|
|
|
|
|
tracer->setSize(6);
|
|
|
|
|
|
tracer->setVisible(false);
|
|
|
|
|
|
tracer->setInterpolating(false);
|
|
|
|
|
|
|
|
|
|
|
|
tracer2 = new QCPItemTracer(ui->widget);
|
|
|
|
|
|
tracer2->setStyle(QCPItemTracer::tsCircle);
|
|
|
|
|
|
tracer2->setPen(QPen(Qt::red));
|
|
|
|
|
|
tracer2->setBrush(Qt::red);
|
|
|
|
|
|
tracer2->setSize(6);
|
|
|
|
|
|
tracer2->setVisible(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tracerLabel = new QCPItemText(ui->widget);
|
|
|
|
|
|
tracerLabel->setLayer("overlay");
|
|
|
|
|
|
tracerLabel->setPen(QPen(Qt::black));
|
|
|
|
|
|
tracerLabel->setBrush(Qt::white);
|
|
|
|
|
|
tracerLabel->setPadding(QMargins(2,2,2,2));//边界宽度
|
|
|
|
|
|
tracerLabel->setPositionAlignment(Qt::AlignTop|Qt::AlignLeft);//文字布局:顶、左对齐
|
|
|
|
|
|
tracerLabel->position->setType(QCPItemPosition::ptAxisRectRatio);//位置类型(当前轴范围的比例为单位/实际坐标为单位)
|
|
|
|
|
|
tracerLabel->position->setCoords(0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
//下面这个语句很重要,它将游标说明锚固在tracer位置处,实现自动跟随
|
|
|
|
|
|
//tracerLabel->position->setParentAnchor(tracer->position);
|
|
|
|
|
|
tracerLabel->setVisible(false);
|
|
|
|
|
|
|
|
|
|
|
|
tracerLabel2 = new QCPItemText(ui->widget);
|
|
|
|
|
|
tracerLabel2->setLayer("overlay");
|
|
|
|
|
|
tracerLabel2->setPen(QPen(Qt::black));
|
|
|
|
|
|
tracerLabel2->setBrush(Qt::white);
|
|
|
|
|
|
tracerLabel2->setPadding(QMargins(2,2,2,2));//边界宽度
|
|
|
|
|
|
tracerLabel2->setPositionAlignment(Qt::AlignHCenter | Qt::AlignTop);
|
|
|
|
|
|
tracerLabel2->setVisible(false);
|
|
|
|
|
|
|
|
|
|
|
|
tracerLabel3 = new QCPItemText(ui->widget);
|
|
|
|
|
|
tracerLabel3->setLayer("overlay");
|
|
|
|
|
|
tracerLabel3->setPen(QPen(Qt::black));
|
|
|
|
|
|
tracerLabel3->setBrush(Qt::white);
|
|
|
|
|
|
tracerLabel3->setPadding(QMargins(2,2,2,2));//边界宽度
|
|
|
|
|
|
tracerLabel3->setPositionAlignment(Qt::AlignTop | Qt::AlignLeft);
|
|
|
|
|
|
tracerLabel3->setVisible(false);
|
|
|
|
|
|
tracerLabel3->position->setType(QCPItemPosition::ptAxisRectRatio);//位置类型(当前轴范围的比例为单位/实际坐标为单位)
|
|
|
|
|
|
tracerLabel3->position->setCoords(0, 0.04);
|
|
|
|
|
|
|
|
|
|
|
|
tracerLabel4 = new QCPItemText(ui->widget);
|
|
|
|
|
|
tracerLabel4->setLayer("overlay");
|
|
|
|
|
|
tracerLabel4->setPen(QPen(Qt::black));
|
|
|
|
|
|
tracerLabel4->setBrush(Qt::white);
|
|
|
|
|
|
tracerLabel4->setPadding(QMargins(2,2,2,2));//边界宽度
|
|
|
|
|
|
tracerLabel4->setPositionAlignment(Qt::AlignTop | Qt::AlignLeft);
|
|
|
|
|
|
tracerLabel4->setVisible(false);
|
|
|
|
|
|
tracerLabel4->position->setType(QCPItemPosition::ptAxisRectRatio);//位置类型(当前轴范围的比例为单位/实际坐标为单位)
|
|
|
|
|
|
tracerLabel4->position->setCoords(0, 0.08);
|
|
|
|
|
|
|
|
|
|
|
|
tracerLabel5 = new QCPItemText(ui->widget);
|
|
|
|
|
|
tracerLabel5->setLayer("overlay");
|
|
|
|
|
|
tracerLabel5->setPen(QPen(Qt::black));
|
|
|
|
|
|
tracerLabel5->setBrush(Qt::white);
|
|
|
|
|
|
tracerLabel5->setPadding(QMargins(2,2,2,2));//边界宽度
|
|
|
|
|
|
tracerLabel5->setPositionAlignment(Qt::AlignTop | Qt::AlignLeft);
|
|
|
|
|
|
tracerLabel5->setVisible(false);
|
|
|
|
|
|
tracerLabel5->position->setType(QCPItemPosition::ptAxisRectRatio);//位置类型(当前轴范围的比例为单位/实际坐标为单位)
|
|
|
|
|
|
tracerLabel5->position->setCoords(0, 0.12);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//背景为黑色
|
|
|
|
|
|
QLinearGradient plotGradient;
|
|
|
|
|
|
plotGradient.setColorAt(0, QColor(0, 0, 0));
|
|
|
|
|
|
plotGradient.setColorAt(1, QColor(0, 0, 0));
|
|
|
|
|
|
ui->widget->setBackground(plotGradient);
|
|
|
|
|
|
//坐标轴为白色
|
|
|
|
|
|
ui->widget->xAxis->setBasePen(QPen(Qt::white, 1));
|
|
|
|
|
|
ui->widget->yAxis->setBasePen(QPen(Qt::white, 1));
|
|
|
|
|
|
ui->widget->yAxis2->setBasePen(QPen(Qt::white, 1));
|
|
|
|
|
|
|
|
|
|
|
|
//坐标轴的提示信息为白色
|
|
|
|
|
|
ui->widget->xAxis->setTickLabelColor(Qt::white);
|
|
|
|
|
|
ui->widget->yAxis->setTickLabelColor(Qt::white);
|
|
|
|
|
|
ui->widget->yAxis2->setTickLabelColor(Qt::white);
|
|
|
|
|
|
//ui->widget->yAxis->setTickLabelRotation(40);//设置刻度显示方向位倾斜向下
|
|
|
|
|
|
|
|
|
|
|
|
ui->widget->xAxis->setLabelColor(Qt::white);
|
|
|
|
|
|
ui->widget->yAxis->setLabelColor(Qt::white);
|
|
|
|
|
|
ui->widget->yAxis2->setLabelColor(Qt::white);
|
|
|
|
|
|
|
|
|
|
|
|
ui->widget->yAxis2->setVisible(false);
|
|
|
|
|
|
ui->widget->yAxis2->setTickLabels(true);
|
|
|
|
|
|
|
|
|
|
|
|
yAxis3 = ui->widget->axisRect()->addAxis(QCPAxis::atRight);
|
|
|
|
|
|
yAxis3->setTickLabelColor(Qt::white);
|
|
|
|
|
|
yAxis3->setBasePen(QPen(Qt::white, 1));
|
|
|
|
|
|
yAxis3->setLabelColor(Qt::white);
|
|
|
|
|
|
yAxis3->setTickLabels(true);
|
|
|
|
|
|
yAxis3->setVisible(false);
|
|
|
|
|
|
|
|
|
|
|
|
axes.append(ui->widget->yAxis);
|
|
|
|
|
|
axes.append(ui->widget->yAxis2);
|
|
|
|
|
|
axes.append(yAxis3);
|
|
|
|
|
|
|
|
|
|
|
|
//ui->widget->setInteractions(QCP::iSelectPlottables);
|
|
|
|
|
|
//鼠标点击
|
|
|
|
|
|
// connect(ui->widget, SIGNAL(plottableClick(QCPAbstractPlottable*, int, QMouseEvent*)), this, SLOT(OnPlotClick(QCPAbstractPlottable*, int, QMouseEvent*)));
|
|
|
|
|
|
|
|
|
|
|
|
if(iType == OrbitPlot){
|
|
|
|
|
|
ui->widget->setOpenGl(true);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
//dismove = connect(ui->widget, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoveEvent(QMouseEvent*)));
|
|
|
|
|
|
disDoubleclick = connect(ui->widget, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, SLOT(mouseDoubleClickEvent(QMouseEvent*)));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
//disPress = connect(ui->widget, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheelEvent(QWheelEvent*)));
|
|
|
|
|
|
qDebug() <<"Is start opengl?=" << ui->widget->openGl();
|
|
|
|
|
|
// ui->widget->setAttribute(Qt::WA_StyledBackground,true);
|
|
|
|
|
|
// ui->widget->setStyleSheet("background-color: rgb(0,0, 0)");.
|
|
|
|
|
|
InitDisPaly();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ChildForm::~ChildForm()
|
|
|
|
|
|
{
|
2022-08-02 10:19:41 +08:00
|
|
|
|
qDebug() << "~ChildForm" << endl;
|
|
|
|
|
|
if(!m_isStop){
|
|
|
|
|
|
emit InitWaveSig();
|
|
|
|
|
|
}
|
2022-07-30 11:50:01 +08:00
|
|
|
|
free(tracer);
|
|
|
|
|
|
free(tracer2);
|
|
|
|
|
|
free(tracerLabel);
|
|
|
|
|
|
free(tracerLabel2);
|
|
|
|
|
|
free(tracerLabel3);
|
|
|
|
|
|
free(tracerLabel4);
|
|
|
|
|
|
free(tracerLabel5);
|
|
|
|
|
|
InitDisPaly();
|
|
|
|
|
|
delete ui;
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::InitDisPaly()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 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 ++ ) {
|
|
|
|
|
|
// QVector<WAVE_DISPALYDATA> temVec = iter.value();
|
|
|
|
|
|
// for (int j = 0; j < temVec.size() ;j++ ) {
|
|
|
|
|
|
// QVector<double>().swap(temVec[i].Key);
|
|
|
|
|
|
// QVector<double>().swap(temVec[i].wavedata);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// QVector<WAVE_DISPALYDATA>().swap(iter.value());
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// mapWaveDisplayData.erase(iter);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* QMap<QString,QVector<WAVE_DATA>>::Iterator iterWave = mapWaveData.begin();
|
|
|
|
|
|
for(iterWave = mapWaveData.begin();iterWave !=mapWaveData.end();iterWave++){
|
|
|
|
|
|
for (int i = 0;iterWave.value().size() ;i ++ ) {
|
|
|
|
|
|
QVector<WAVE_DATA> temVec = iterWave.value();
|
|
|
|
|
|
for (int j = 0; j < temVec.size() ;j++ ) {
|
|
|
|
|
|
QVector<float>().swap(temVec[i].waveData);
|
|
|
|
|
|
}
|
|
|
|
|
|
QVector<WAVE_DATA>().swap(iterWave.value());
|
|
|
|
|
|
}
|
|
|
|
|
|
mapWaveData.erase(iterWave);
|
|
|
|
|
|
}*/
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ChildForm::InitRpmDisPaly()
|
|
|
|
|
|
{
|
|
|
|
|
|
QMap<QString,WAVE_DISPALYDATA>::Iterator iterDC = mapWaveDisplayData_RPM.begin();
|
|
|
|
|
|
for(iterDC = mapWaveDisplayData_RPM.begin();iterDC != mapWaveDisplayData_RPM.end();iterDC++){
|
|
|
|
|
|
mapWaveDisplayData_RPM.erase(iterDC);
|
|
|
|
|
|
}
|
|
|
|
|
|
m_bRpm = false;
|
|
|
|
|
|
}
|
2022-08-02 10:19:41 +08:00
|
|
|
|
void ChildForm::InitIntegration()
|
|
|
|
|
|
{
|
|
|
|
|
|
m_bIntegration = false;
|
|
|
|
|
|
m_bDifferentiation = false;
|
|
|
|
|
|
m_bDoubleIntegration = false;
|
|
|
|
|
|
m_bDoubleDifferentiation = false;
|
|
|
|
|
|
}
|
2022-07-30 11:50:01 +08:00
|
|
|
|
void ChildForm::InitWidget()
|
|
|
|
|
|
{
|
|
|
|
|
|
QMenu *ZoomMenu = new QMenu();
|
|
|
|
|
|
ZoomMenu->setWindowFlags(ZoomMenu->windowFlags() | Qt::FramelessWindowHint);
|
|
|
|
|
|
QAction *Zoom_xy = new QAction(ZoomMenu);
|
|
|
|
|
|
QAction * Zoom_x= new QAction(ZoomMenu);
|
|
|
|
|
|
QAction *Zoom_y = new QAction(ZoomMenu);
|
|
|
|
|
|
|
|
|
|
|
|
ZoomMenu->addAction(Zoom_xy);
|
|
|
|
|
|
ZoomMenu->addAction(Zoom_x);
|
|
|
|
|
|
ZoomMenu->addAction(Zoom_y);
|
|
|
|
|
|
|
|
|
|
|
|
Zoom_xy->setIcon(QIcon(":/images/images/imgModelAction/Zoom_xy.png"));
|
|
|
|
|
|
Zoom_x->setIcon(QIcon(":/images/images/imgModelAction/axisX.png"));
|
|
|
|
|
|
Zoom_y->setIcon(QIcon(":/images/images/imgModelAction/axisY.png"));
|
|
|
|
|
|
|
|
|
|
|
|
Zoom_xy->setText(tr(" 自动缩放XY"));
|
|
|
|
|
|
Zoom_x->setText(tr(" 自动缩放X"));
|
|
|
|
|
|
Zoom_y->setText(tr(" 自动缩放Y"));
|
|
|
|
|
|
ui->Btn_ZoomMenu->setMenu(ZoomMenu);
|
|
|
|
|
|
|
|
|
|
|
|
QMenu *HzMenu = new QMenu();
|
|
|
|
|
|
HzMenu->setWindowFlags(HzMenu->windowFlags() | Qt::FramelessWindowHint);
|
|
|
|
|
|
Hz = new QAction(HzMenu);
|
|
|
|
|
|
Ord= new QAction(HzMenu);
|
|
|
|
|
|
Rad = new QAction(HzMenu);
|
|
|
|
|
|
|
|
|
|
|
|
HzMenu->addAction(Rad);
|
|
|
|
|
|
HzMenu->addAction(Hz);
|
|
|
|
|
|
HzMenu->addAction(Ord);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Hz->setIcon(QIcon(":/images/images/imgModelAction/HZ.png"));
|
|
|
|
|
|
Ord->setIcon(QIcon(":/images/images/imgModelAction/Ord.png"));
|
|
|
|
|
|
Rad->setIcon(QIcon(":/images/images/imgModelAction/rpm.png"));
|
|
|
|
|
|
Rad->setText(tr(" Rpm"));
|
|
|
|
|
|
Hz->setText(tr(" Hz"));
|
|
|
|
|
|
Ord->setText(tr(" Ord"));
|
|
|
|
|
|
ui->Btn_Hz->setMenu(HzMenu);
|
|
|
|
|
|
|
|
|
|
|
|
differentiationMenu = new QMenu();
|
|
|
|
|
|
differentiationMenu->setWindowFlags(differentiationMenu->windowFlags() | Qt::FramelessWindowHint);
|
|
|
|
|
|
Integration = new QAction(differentiationMenu);
|
|
|
|
|
|
doubleIntegration = new QAction(differentiationMenu);
|
|
|
|
|
|
differentiation = new QAction(differentiationMenu);
|
|
|
|
|
|
doubleDifferentiation= new QAction(differentiationMenu);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
differentiationMenu->addAction(Integration);
|
|
|
|
|
|
differentiationMenu->addAction(doubleIntegration);
|
|
|
|
|
|
differentiationMenu->addAction(differentiation);
|
|
|
|
|
|
differentiationMenu->addAction(doubleDifferentiation);
|
|
|
|
|
|
|
|
|
|
|
|
Integration->setIcon(QIcon(":/images/images/imgModelAction/Integration.png"));
|
|
|
|
|
|
doubleIntegration->setIcon(QIcon(":/images/images/imgModelAction/doubleIntegration.png"));
|
|
|
|
|
|
differentiation->setIcon(QIcon(":/images/images/imgModelAction/arf.png"));
|
|
|
|
|
|
doubleDifferentiation->setIcon(QIcon(":/images/images/imgModelAction/doublearf.png"));
|
|
|
|
|
|
Integration->setText(tr(" 积分"));
|
|
|
|
|
|
doubleIntegration->setText(tr(" 二次积分"));
|
|
|
|
|
|
differentiation->setText(tr(" 微分"));
|
|
|
|
|
|
doubleDifferentiation->setText(tr(" 二次微分"));
|
|
|
|
|
|
ui->Btn_differentiation->setMenu(differentiationMenu);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(Integration, SIGNAL(triggered()), this, SLOT(IntegrationSlot()));
|
|
|
|
|
|
connect(doubleIntegration, SIGNAL(triggered()), this, SLOT(DoubleIntegrationSlot()));
|
|
|
|
|
|
connect(differentiation, SIGNAL(triggered()), this, SLOT(DifferentiationSlot()));
|
|
|
|
|
|
connect(doubleDifferentiation, SIGNAL(triggered()), this, SLOT(DoubleDifferentiationSlot()));
|
|
|
|
|
|
|
|
|
|
|
|
connect(Zoom_xy, SIGNAL(triggered()), this, SLOT(ZoomBtnSlot_XY()));
|
|
|
|
|
|
connect(Zoom_x, SIGNAL(triggered()), this, SLOT(ZoomBtnSlot_X()));
|
|
|
|
|
|
connect(Zoom_y, SIGNAL(triggered()), this, SLOT(ZoomBtnSlot_Y()));
|
|
|
|
|
|
connect(Rad, SIGNAL(triggered()), this, SLOT(ToRpm()));
|
|
|
|
|
|
|
|
|
|
|
|
QMenu *ScaleMenu = new QMenu();
|
|
|
|
|
|
ScaleMenu->setWindowFlags(ScaleMenu->windowFlags() | Qt::FramelessWindowHint);
|
|
|
|
|
|
QAction *Scale_X = new QAction(ScaleMenu);
|
|
|
|
|
|
QAction *ScaleMenu_Y = new QAction(ScaleMenu);
|
|
|
|
|
|
QAction *ScaleMenu_XY = new QAction(ScaleMenu);
|
|
|
|
|
|
QAction *ScaleMenu_Box = new QAction(ScaleMenu);
|
|
|
|
|
|
|
|
|
|
|
|
ScaleMenu->addAction(Scale_X);
|
|
|
|
|
|
ScaleMenu->addAction(ScaleMenu_Y);
|
|
|
|
|
|
ScaleMenu->addAction(ScaleMenu_XY);
|
|
|
|
|
|
ScaleMenu->addAction(ScaleMenu_Box);
|
|
|
|
|
|
|
|
|
|
|
|
Scale_X->setIcon(QIcon(":/images/images/imgModelAction/Zoom_X.png"));
|
|
|
|
|
|
ScaleMenu_Y->setIcon(QIcon(":/images/images/imgModelAction/Zoom_Y.png"));
|
|
|
|
|
|
ScaleMenu_XY->setIcon(QIcon(":/images/images/imgModelAction/Zoom-XY.png"));
|
|
|
|
|
|
ScaleMenu_Box->setIcon(QIcon(":/images/images/imgModelAction/Zoom_Box.png"));
|
|
|
|
|
|
Scale_X->setText(tr(" 放大X"));
|
|
|
|
|
|
ScaleMenu_Y->setText(tr(" 放大Y"));
|
|
|
|
|
|
ScaleMenu_XY->setText(tr(" 放大XY"));
|
|
|
|
|
|
ScaleMenu_Box->setText(tr(" 框选放大"));
|
|
|
|
|
|
ui->Btn_Zoom->setMenu(ScaleMenu);
|
|
|
|
|
|
|
|
|
|
|
|
connect(Scale_X, SIGNAL(triggered()), this, SLOT(ScalesX()));
|
|
|
|
|
|
connect(ScaleMenu_Y, SIGNAL(triggered()), this, SLOT(ScalesY()));
|
|
|
|
|
|
connect(ScaleMenu_XY, SIGNAL(triggered()), this, SLOT(ScalesXY()));
|
|
|
|
|
|
connect(ScaleMenu_Box, SIGNAL(triggered()), this, SLOT(ScalesBox()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QMenu *CursorMenu = new QMenu();
|
|
|
|
|
|
CursorMenu->setWindowFlags(CursorMenu->windowFlags() | Qt::FramelessWindowHint);
|
|
|
|
|
|
QAction *Cursor = new QAction(CursorMenu);
|
|
|
|
|
|
QAction *biandai = new QAction(CursorMenu);
|
|
|
|
|
|
QAction *xiebo = new QAction(CursorMenu);
|
|
|
|
|
|
QAction *fengzhi = new QAction(CursorMenu);
|
|
|
|
|
|
|
|
|
|
|
|
CursorMenu->addAction(Cursor);
|
|
|
|
|
|
CursorMenu->addAction(biandai);
|
|
|
|
|
|
CursorMenu->addAction(xiebo);
|
|
|
|
|
|
CursorMenu->addAction(fengzhi);
|
|
|
|
|
|
|
|
|
|
|
|
Cursor->setIcon(QIcon(":/images/images/imgModelAction/Cursor.png"));
|
|
|
|
|
|
biandai->setIcon(QIcon(":/images/images/imgModelAction/biandai.png"));
|
|
|
|
|
|
xiebo->setIcon(QIcon(":/images/images/imgModelAction/xiebo.png"));
|
|
|
|
|
|
fengzhi->setIcon(QIcon(":/images/images/imgModelAction/fengzhi.png"));
|
|
|
|
|
|
Cursor->setText(tr(" 光标"));
|
|
|
|
|
|
biandai->setText(tr(" 边带光标"));
|
|
|
|
|
|
xiebo->setText(tr(" 谐波光标"));
|
|
|
|
|
|
fengzhi->setText(tr(" 峰值光标"));
|
|
|
|
|
|
biandai->setEnabled(false);
|
|
|
|
|
|
xiebo->setEnabled(false);
|
|
|
|
|
|
fengzhi->setEnabled(false);
|
|
|
|
|
|
ui->Btn_Cursor->setMenu(CursorMenu);
|
|
|
|
|
|
|
|
|
|
|
|
connect(Cursor, SIGNAL(triggered()), this, SLOT(Cursor()));
|
|
|
|
|
|
|
|
|
|
|
|
ui->Btn_ZoomMenu->setStyleSheet("QPushButton::menu-indicator{image:none;}");
|
|
|
|
|
|
ui->Btn_Zoom->setStyleSheet("QPushButton::menu-indicator{image:none;}");
|
|
|
|
|
|
ui->Btn_Cursor->setStyleSheet("QPushButton::menu-indicator{image:none;}");
|
|
|
|
|
|
|
|
|
|
|
|
if(m_iFormType == EnvChartPlot){
|
|
|
|
|
|
ui->temBtn_4->setStyleSheet(" QPushButton{ border-image:url(:/images/images/imgModelAction/lvbo.png) 5; }\
|
|
|
|
|
|
QPushButton:hover{ border-image:url(:/images/images/imgModelAction/lvbo-h.png) 5; }\
|
|
|
|
|
|
QPushButton:pressed{border-image:url(:/images/images/imgModelAction/lvbo-p.png) 5; }\
|
|
|
|
|
|
QPushButton:checked{border-image:url(:/images/images/imgModelAction/lvbo.png) 5; } " );
|
|
|
|
|
|
|
|
|
|
|
|
ui->temBtn_4->setEnabled(true);
|
|
|
|
|
|
}else if (m_iFormType == TimeDomainPlot) {
|
|
|
|
|
|
ui->Btn_differentiation->setStyleSheet(" QPushButton { border-image:url(:/images/images/imgModelAction/arf.png) 1; }\
|
|
|
|
|
|
QPushButton:hover { border-image:url(:/images/images/imgModelAction/arf-h.png) 1; }\
|
|
|
|
|
|
QPushButton:pressed {border-image:url(:/images/images/imgModelAction/arf-p.png) 1; }\
|
|
|
|
|
|
QPushButton:checked {border-image:url(:/images/images/imgModelAction/arf.png) 1; }\
|
|
|
|
|
|
QPushButton::menu-indicator{image:none;}");
|
|
|
|
|
|
|
|
|
|
|
|
ui->Btn_AC_DC->setStyleSheet(" QPushButton { border-image:url(:/images/images/imgModelAction/AC-p.png) 5; }\
|
|
|
|
|
|
QPushButton:hover { border-image:url(:/images/images/imgModelAction/AC-h.png) 5; }\
|
|
|
|
|
|
QPushButton:pressed {border-image:url(:/images/images/imgModelAction/AC.png) 5; }\
|
|
|
|
|
|
QPushButton:checked {border-image:url(:/images/images/imgModelAction/DC.png) 5; }");
|
|
|
|
|
|
|
|
|
|
|
|
ui->Btn_Hz->setStyleSheet(" QPushButton { border-image:url(:/images/images/imgModelAction/HZ.png) 1; }\
|
|
|
|
|
|
QPushButton:hover { border-image:url(:/images/images/imgModelAction/HZ-h.png) 1; }\
|
|
|
|
|
|
QPushButton:pressed {border-image:url(:/images/images/imgModelAction/hz-2.png) 1; }\
|
|
|
|
|
|
QPushButton:checked {border-image:url(:/images/images/imgModelAction/HZ.png) 1; }");
|
|
|
|
|
|
|
|
|
|
|
|
ui->Btn_Sound->setStyleSheet(" QPushButton { border-image:url(:/images/images/imgModelAction/Sound.png) 1; }\
|
|
|
|
|
|
QPushButton:hover { border-image:url(:/images/images/imgModelAction/Sound-h.png) 1; }\
|
|
|
|
|
|
QPushButton:pressed {border-image:url(:/images/images/imgModelAction/Sound-p.png) 1; }\
|
|
|
|
|
|
QPushButton:checked {border-image:url(:/images/images/imgModelAction/Sound-p.png) 1; }");
|
|
|
|
|
|
|
|
|
|
|
|
ui->temBtn_4->setStyleSheet(" QPushButton{ border-image:url(:/images/images/imgModelAction/lvbo.png) 5; }\
|
|
|
|
|
|
QPushButton:hover{ border-image:url(:/images/images/imgModelAction/lvbo-h.png) 5; }\
|
|
|
|
|
|
QPushButton:pressed{border-image:url(:/images/images/imgModelAction/lvbo-p.png) 5; }\
|
|
|
|
|
|
QPushButton:checked{border-image:url(:/images/images/imgModelAction/lvbo.png) 5; } " );
|
|
|
|
|
|
|
|
|
|
|
|
ui->temBtn_4->setEnabled(true);
|
|
|
|
|
|
|
|
|
|
|
|
ui->Btn_AC_DC->setEnabled(true);
|
|
|
|
|
|
ui->Btn_Sound->setEnabled(true);
|
|
|
|
|
|
ui->Btn_differentiation->setEnabled(true);
|
|
|
|
|
|
doubleIntegration->setEnabled(true);
|
|
|
|
|
|
differentiation->setEnabled(true);
|
|
|
|
|
|
doubleDifferentiation->setEnabled(true);
|
|
|
|
|
|
ui->Btn_Hz->setEnabled(true);
|
|
|
|
|
|
Ord->setEnabled(false);
|
|
|
|
|
|
Hz->setEnabled(false);
|
|
|
|
|
|
Rad->setEnabled(false);
|
|
|
|
|
|
}else if(m_iFormType == FrequencyDomainPlot){
|
|
|
|
|
|
ui->Btn_differentiation->setStyleSheet(" QPushButton { border-image:url(:/images/images/imgModelAction/arf.png) 1; }\
|
|
|
|
|
|
QPushButton:hover { border-image:url(:/images/images/imgModelAction/arf-h.png) 1; }\
|
|
|
|
|
|
QPushButton:pressed {border-image:url(:/images/images/imgModelAction/arf-p.png) 1; }\
|
|
|
|
|
|
QPushButton:checked {border-image:url(:/images/images/imgModelAction/arf.png) 1; }\
|
|
|
|
|
|
QPushButton::menu-indicator{image:none;}");
|
|
|
|
|
|
ui->temBtn_4->setStyleSheet(" QPushButton{ border-image:url(:/images/images/imgModelAction/lvbo.png) 5; }\
|
|
|
|
|
|
QPushButton:hover{ border-image:url(:/images/images/imgModelAction/lvbo-h.png) 5; }\
|
|
|
|
|
|
QPushButton:pressed{border-image:url(:/images/images/imgModelAction/lvbo-p.png) 5; }\
|
|
|
|
|
|
QPushButton:checked{border-image:url(:/images/images/imgModelAction/lvbo.png) 5; } " );
|
|
|
|
|
|
|
|
|
|
|
|
ui->temBtn_4->setEnabled(true);
|
|
|
|
|
|
|
|
|
|
|
|
ui->Btn_differentiation->setEnabled(true);
|
|
|
|
|
|
doubleIntegration->setEnabled(false);
|
|
|
|
|
|
differentiation->setEnabled(false);
|
|
|
|
|
|
doubleDifferentiation->setEnabled(false);
|
|
|
|
|
|
}else if(m_iFormType == ShaftCenterline /*|| m_iFormType == BodePlot*/ || m_iFormType == PolarPlot || m_iFormType == OrbitPlot
|
|
|
|
|
|
|| m_iFormType ==WaterFallPlot){
|
|
|
|
|
|
Cursor->setEnabled(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ChildForm::SetWaveData(QString strID, QVector<WAVE_DATA>& waveData)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
QCPGraph* ChildForm::MultiyAxis(QString strID,QString sensorType,QString sensorEngineeringUnit)
|
|
|
|
|
|
{
|
|
|
|
|
|
QCPGraph* graph = NULL;
|
|
|
|
|
|
QMap<QString,QCPAxis*> mapGraph;
|
|
|
|
|
|
|
|
|
|
|
|
if(mapMultiGraph.size() < 3 || (mapMultiGraph.size() == 3 && mapMultiGraph.contains(sensorType))){
|
|
|
|
|
|
|
|
|
|
|
|
if(!mapMultiGraph.contains(sensorType)){
|
|
|
|
|
|
|
|
|
|
|
|
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]);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(mapMultiGraph.size() == 2 || mapMultiGraph.size() == 1){
|
|
|
|
|
|
qDebug() << "mapMultiGraph3" << endl;
|
|
|
|
|
|
QList<QCPAxis*> tmpaxes;
|
|
|
|
|
|
for(int i = 0 ; i < axes.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(i == axes.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]){
|
|
|
|
|
|
eql1 = 1;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
eql1 = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
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]);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
|
|
qDebug() << "contains2" << endl;
|
|
|
|
|
|
QMap<QString,QMap<QString,QCPAxis*>>::iterator iter = mapMultiGraph.begin();
|
|
|
|
|
|
for(; iter != mapMultiGraph.end();iter++){
|
|
|
|
|
|
if(iter.key() == sensorType){
|
|
|
|
|
|
|
|
|
|
|
|
QMap<QString,QCPAxis*>::iterator iterGraph = iter.value().begin();
|
|
|
|
|
|
graph = ui->widget->addGraph(ui->widget->xAxis, iterGraph.value());
|
|
|
|
|
|
mapGraph.insert(strID,iterGraph.value());
|
|
|
|
|
|
qDebug() << "strID1" << strID << endl;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QMap<QString,QMap<QString,QCPAxis*>>::iterator iter = mapMultiGraph.begin();
|
|
|
|
|
|
for(; iter != mapMultiGraph.end();iter++){
|
|
|
|
|
|
if(iter.key() == sensorType){
|
|
|
|
|
|
QMap<QString,QCPAxis*>::iterator iterGraph = iter.value().begin();
|
|
|
|
|
|
for(;iterGraph != iter.value().end();iterGraph ++){
|
|
|
|
|
|
mapGraph.insert(iterGraph.key(),iterGraph.value());
|
|
|
|
|
|
qDebug() << "strID2" << iterGraph.key() << endl;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
mapMultiGraph.insert(sensorType,mapGraph);
|
|
|
|
|
|
waveGraph.insert(strID,graph);
|
|
|
|
|
|
return graph;
|
|
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
|
|
|
|
qDebug() << "multiGraph" << endl;
|
|
|
|
|
|
|
|
|
|
|
|
m_mapChannelIDtoLabel[strID]->setSelected(false);
|
|
|
|
|
|
m_mapChannelIDtoLabel[strID]->setCheckState(Qt::Unchecked);
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::SecondData(const QString& strID,WAVE_DATA& waveData,WAVE_DISPALYDATA& waveShowData)
|
|
|
|
|
|
{
|
|
|
|
|
|
double f = 0;
|
|
|
|
|
|
double gap = (double)1/(double)waveData.SamleRate;
|
|
|
|
|
|
if(m_iFormType == TimeDomainPlot)//时域图
|
|
|
|
|
|
{
|
|
|
|
|
|
f = 0.0;
|
|
|
|
|
|
if(m_bRealTime){
|
|
|
|
|
|
gap = (double)1/(double)waveData.SamleRateRealTime;
|
|
|
|
|
|
double sum = std::accumulate(std::begin(waveData.waveDataRealTime), std::end(waveData.waveDataRealTime), 0.0);
|
|
|
|
|
|
float size = waveData.SamleRateRealTime;
|
|
|
|
|
|
double mean = sum/size;
|
|
|
|
|
|
for(int j = 0 ; j < waveData.SamleRateRealTime;j++){
|
|
|
|
|
|
|
|
|
|
|
|
waveShowData.wavedata.push_back(waveData.waveDataRealTime.at(j)-mean);
|
|
|
|
|
|
f += gap;
|
|
|
|
|
|
waveShowData.Key.push_back(f);
|
|
|
|
|
|
waveShowData.wavedata_DC.push_back(waveData.waveDataRealTime.at(j));
|
|
|
|
|
|
}
|
2022-08-02 10:19:41 +08:00
|
|
|
|
if(m_bIntegration){
|
|
|
|
|
|
QVector<double> retValue;
|
|
|
|
|
|
double RMS = 0.0;
|
|
|
|
|
|
pCalculation->_Integration(waveShowData.wavedata,retValue,RMS);
|
|
|
|
|
|
QVector<double>().swap(waveShowData.wavedata);
|
|
|
|
|
|
waveShowData.wavedata = retValue;
|
|
|
|
|
|
waveShowData.RMS = RMS;
|
|
|
|
|
|
}
|
2022-07-30 11:50:01 +08:00
|
|
|
|
qDebug() << "waveShowData.wavedata_DC" << waveShowData.wavedata_DC.size()<< endl;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
QVector<double> vecOutData;
|
|
|
|
|
|
for(int j = 0 ; j < waveData.wavesize;j++){
|
|
|
|
|
|
waveShowData.wavedata.push_back(waveData.waveData.at(j)-waveData.mean);
|
|
|
|
|
|
f += gap;
|
|
|
|
|
|
waveShowData.Key.push_back(f);
|
|
|
|
|
|
waveShowData.wavedata_DC.push_back(waveData.waveData.at(j));
|
|
|
|
|
|
}
|
|
|
|
|
|
if(m_nStart > 0 && m_nEnd > 0){
|
|
|
|
|
|
double FrequencyBands[2] = { (double)m_nStart/waveData.SamleRate*2, (double)m_nEnd/waveData.SamleRate*2 };
|
|
|
|
|
|
pCalculation->ButterWorth(waveShowData.wavedata,FrequencyBands,vecOutData);
|
|
|
|
|
|
QVector<double>().swap(waveShowData.wavedata);
|
|
|
|
|
|
waveShowData.wavedata = vecOutData;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
waveShowData.linColor = waveData.linColor;
|
|
|
|
|
|
waveShowData.channelType = waveData.sensorType;
|
|
|
|
|
|
waveShowData.sensorEngineeringUnit = waveData.sensorEngineeringUnit;
|
|
|
|
|
|
waveShowData.SamleRate = waveData.SamleRate;
|
|
|
|
|
|
waveShowData.mean = waveData.mean;
|
|
|
|
|
|
waveShowData.channleName = waveData.channelName;
|
|
|
|
|
|
|
|
|
|
|
|
waveShowData.iTrigger = waveData.iTrigger;
|
|
|
|
|
|
waveShowData.iKeyCount = waveData.iKeyCount;
|
|
|
|
|
|
waveShowData.iTriggerValue = waveData.iTriggerValue;
|
|
|
|
|
|
waveShowData.iHysteresis = waveData.iHysteresis;
|
|
|
|
|
|
ui->widget->xAxis->setLabel("Time(s)");
|
|
|
|
|
|
}else if(m_iFormType == FrequencyDomainPlot){
|
|
|
|
|
|
WAVE_DISPALYDATA WaveDisplay;
|
|
|
|
|
|
QVector<double> vecFFTSpecData;
|
|
|
|
|
|
QVector<double> vecData;
|
|
|
|
|
|
for(int j = 0; j < waveData.wavesize;j++){
|
|
|
|
|
|
float fData = waveData.waveData.at(j)-waveData.mean;
|
|
|
|
|
|
vecData.push_back(fData);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QVector<double> vecOutData;
|
|
|
|
|
|
if(m_nStart > 0 && m_nEnd > 0){
|
|
|
|
|
|
double FrequencyBands[2] = { (double)m_nStart/waveData.SamleRate*2, (double)m_nEnd/waveData.SamleRate*2 };
|
|
|
|
|
|
pCalculation->ButterWorth(vecData,FrequencyBands,vecOutData);
|
|
|
|
|
|
QVector<double>().swap(vecData);
|
|
|
|
|
|
vecData = vecOutData;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pCalculation->FFTSpec(vecData,vecFFTSpecData);//每一秒的FFT
|
|
|
|
|
|
qDebug() << vecData.size() <<vecData[100] << vecFFTSpecData.size() << vecFFTSpecData[50]<< endl;
|
|
|
|
|
|
for(int jj = 0 ; jj < vecFFTSpecData.size();jj++){
|
|
|
|
|
|
waveShowData.Key.push_back(jj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
waveShowData.wavedata = vecFFTSpecData;
|
|
|
|
|
|
waveShowData.linColor = waveData.linColor;
|
|
|
|
|
|
waveShowData.channelType = waveData.sensorType;
|
|
|
|
|
|
waveShowData.sensorEngineeringUnit = waveData.sensorEngineeringUnit;
|
|
|
|
|
|
ui->widget->xAxis->setLabel("Frequency(Hz)");
|
|
|
|
|
|
}else if(m_iFormType == EnvChartPlot){
|
|
|
|
|
|
|
|
|
|
|
|
QVector<double> vecEnvSpecData;
|
|
|
|
|
|
QVector<double> vecData;
|
|
|
|
|
|
for(int j = 0; j < waveData.wavesize;j++){
|
|
|
|
|
|
float fData = waveData.waveData.at(j)-waveData.mean;
|
|
|
|
|
|
vecData.push_back(fData);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(m_nStart == 0 || m_nEnd == 0){
|
|
|
|
|
|
pCalculation->envSpec(vecData,vecEnvSpecData,1000,10000);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
pCalculation->envSpec(vecData,vecEnvSpecData,m_nStart,m_nEnd);
|
|
|
|
|
|
}
|
|
|
|
|
|
for(int jj = 0 ; jj < vecEnvSpecData.size();jj++){
|
|
|
|
|
|
waveShowData.Key.push_back(jj);
|
|
|
|
|
|
}
|
|
|
|
|
|
waveShowData.wavedataEnv = vecEnvSpecData;
|
|
|
|
|
|
waveShowData.wavedata = vecData;
|
|
|
|
|
|
waveShowData.linColor = waveData.linColor;
|
|
|
|
|
|
//wavetempData.push_back(vecEnvSpecData);
|
|
|
|
|
|
waveShowData.channelType = waveData.sensorType;
|
|
|
|
|
|
waveShowData.sensorEngineeringUnit = waveData.sensorEngineeringUnit;
|
|
|
|
|
|
ui->widget->xAxis->setLabel("Frequency(Hz)");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(mapWaveDisplayData.contains(strID)){
|
|
|
|
|
|
|
|
|
|
|
|
mapWaveDisplayData[strID] = waveShowData;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
mapWaveDisplayData.insert(strID,waveShowData);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::UpdateDiffMenu()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(mapMultiGraph.contains("VELOCITY") && mapMultiGraph.contains("ACCELEROMETER")){
|
|
|
|
|
|
Integration->setEnabled(true);
|
|
|
|
|
|
doubleIntegration->setEnabled(false);
|
|
|
|
|
|
differentiation->setEnabled(false);
|
|
|
|
|
|
doubleDifferentiation->setEnabled(false);
|
|
|
|
|
|
}else if(mapMultiGraph.contains("VELOCITY") && mapMultiGraph.contains("ACCELEROMETER")){
|
|
|
|
|
|
Integration->setEnabled(false);
|
|
|
|
|
|
doubleIntegration->setEnabled(false);
|
|
|
|
|
|
differentiation->setEnabled(true);
|
|
|
|
|
|
doubleDifferentiation->setEnabled(false);
|
|
|
|
|
|
}else if(mapMultiGraph.contains("ACCELEROMETER") &&
|
|
|
|
|
|
!(mapMultiGraph.contains("THRUST") || mapMultiGraph.contains("PROXIMETER"))
|
|
|
|
|
|
&& !(mapMultiGraph.contains("VELOCITY")) && !(mapMultiGraph.contains("MICROPHONE"))
|
|
|
|
|
|
&& !(mapMultiGraph.contains("SLOW_CURRENT")) && !(mapMultiGraph.contains("FAST_VOLTAGE"))
|
|
|
|
|
|
&& !(mapMultiGraph.contains("TACHOMETER"))){
|
|
|
|
|
|
Integration->setEnabled(true);
|
|
|
|
|
|
doubleIntegration->setEnabled(true);
|
|
|
|
|
|
differentiation->setEnabled(false);
|
|
|
|
|
|
doubleDifferentiation->setEnabled(false);
|
|
|
|
|
|
}else if(mapMultiGraph.contains("VELOCITY") &&
|
|
|
|
|
|
!(mapMultiGraph.contains("ACCELEROMETER"))
|
|
|
|
|
|
&& !(mapMultiGraph.contains("ACCELEROMETER"))
|
|
|
|
|
|
&& !((mapMultiGraph.contains("THRUST")) || mapMultiGraph.contains("PROXIMETER"))
|
|
|
|
|
|
&& !(mapMultiGraph.contains("MICROPHONE"))
|
|
|
|
|
|
&& !(mapMultiGraph.contains("SLOW_CURRENT")) && !(mapMultiGraph.contains("FAST_VOLTAGE"))
|
|
|
|
|
|
&& !(mapMultiGraph.contains("TACHOMETER"))){
|
|
|
|
|
|
Integration->setEnabled(true);
|
|
|
|
|
|
doubleIntegration->setEnabled(false);
|
|
|
|
|
|
differentiation->setEnabled(true);
|
|
|
|
|
|
doubleDifferentiation->setEnabled(false);
|
|
|
|
|
|
}else if((mapMultiGraph.contains("THRUST") || mapMultiGraph.contains("PROXIMETER")) &&
|
|
|
|
|
|
!(mapMultiGraph.contains("ACCELEROMETER")) && !(mapMultiGraph.contains("VELOCITY"))
|
|
|
|
|
|
&& !(mapMultiGraph.contains("MICROPHONE"))
|
|
|
|
|
|
&& !(mapMultiGraph.contains("SLOW_CURRENT")) && !(mapMultiGraph.contains("FAST_VOLTAGE"))
|
|
|
|
|
|
&& !(mapMultiGraph.contains("TACHOMETER"))){
|
|
|
|
|
|
Integration->setEnabled(false);
|
|
|
|
|
|
doubleIntegration->setEnabled(false);
|
|
|
|
|
|
differentiation->setEnabled(true);
|
|
|
|
|
|
doubleDifferentiation->setEnabled(true);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
Integration->setEnabled(false);
|
|
|
|
|
|
doubleIntegration->setEnabled(false);
|
|
|
|
|
|
differentiation->setEnabled(false);
|
|
|
|
|
|
doubleDifferentiation->setEnabled(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::AddSeries(QString strID, QVector<WAVE_DATA>& waveData)
|
|
|
|
|
|
{
|
|
|
|
|
|
//InitDisPaly();
|
|
|
|
|
|
qDebug() << "AddSeries"<<waveData.size() << endl;
|
|
|
|
|
|
|
|
|
|
|
|
childWave = waveData;
|
|
|
|
|
|
mapWaveData.insert(strID,waveData);
|
|
|
|
|
|
if(m_iFormType == TimeDomainPlot)//时域图
|
|
|
|
|
|
{
|
|
|
|
|
|
WAVE_DISPALYDATA waveShowData;
|
|
|
|
|
|
SecondData( strID,waveData[0], 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);
|
|
|
|
|
|
if(graph == NULL)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(waveData[0].sensorType == "ACCELEROMETER" || waveData[0].sensorType == "VELOCITY" ||
|
|
|
|
|
|
waveData[0].sensorType == "MICROPHONE"){
|
|
|
|
|
|
|
|
|
|
|
|
ui->Btn_AC_DC->setEnabled(false);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
ui->Btn_AC_DC->setEnabled(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(!m_bDC)
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->widget->graph(line)->setData(waveShowData.Key, waveShowData.wavedata);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
ui->widget->graph(line)->setData(waveShowData.Key, waveShowData.wavedata_DC);
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->graph(line)->setName(waveData[0].channelName);
|
|
|
|
|
|
ui->widget->xAxis->setRange(0, 1);
|
|
|
|
|
|
UpdateDiffMenu();
|
|
|
|
|
|
|
|
|
|
|
|
}else if(m_iFormType == TrendChartPlot){//趋势图
|
|
|
|
|
|
int Time = waveData.size();
|
|
|
|
|
|
//qDebug() << "Time" << Time << endl;
|
|
|
|
|
|
QVector<double>().swap(x);
|
|
|
|
|
|
QVector<double> wavetempTrendData;
|
|
|
|
|
|
for(int i = 0; i < Time;i++){//平方和除以点数再开根
|
|
|
|
|
|
|
|
|
|
|
|
// float Sum = 0.0;
|
|
|
|
|
|
// for(int j = 0; j < waveData[i].SamleRate;j++){
|
|
|
|
|
|
// float fData = waveData[i].waveData.at(j)-waveData[i].mean;
|
|
|
|
|
|
// fData = fData*fData;
|
|
|
|
|
|
// Sum += fData;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// float rms = sqrt(Sum/waveData[i].SamleRate); //加速度有效值
|
|
|
|
|
|
x.push_back(i);
|
|
|
|
|
|
//wavetempTrendData.push_back(rms);
|
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
|
if(graph == NULL)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(waveData[0].sensorType == "TACHOMETER"){
|
|
|
|
|
|
ui->widget->graph(line)->setData(x, waveData[0].SpeedProfileSpeed);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
ui->widget->graph(line)->setData(x, waveData[0].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);
|
|
|
|
|
|
|
|
|
|
|
|
ui->widget->xAxis->setRange(0, 1000);
|
|
|
|
|
|
QCPGraph* graph = MultiyAxis(strID,vecWaveDisplay.channelType,vecWaveDisplay.sensorEngineeringUnit);
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
}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);
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
}else if(m_iFormType == WaterFallPlot){//瀑布图
|
|
|
|
|
|
int k = 0;
|
|
|
|
|
|
//取消其他通道
|
|
|
|
|
|
foreach (auto ID, listChannelID){
|
|
|
|
|
|
if(ID != strID){
|
|
|
|
|
|
m_mapChannelIDtoLabel[ID]->setCheckState(Qt::Unchecked);
|
|
|
|
|
|
m_mapChannelIDtoLabel[ID]->setSelected(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->clearGraphs();
|
|
|
|
|
|
line = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < waveData.size();i++){
|
|
|
|
|
|
QVector<double> vecFFTSpecData;
|
|
|
|
|
|
QVector<double> vecData;
|
|
|
|
|
|
QVector<double> x1,y1;
|
|
|
|
|
|
for(int j = 0; j < waveData[i].waveData.size();j++){
|
|
|
|
|
|
float fData = waveData[i].waveData.at(j)-waveData[i].mean;
|
|
|
|
|
|
vecData.push_back(fData);
|
|
|
|
|
|
}
|
|
|
|
|
|
pCalculation->FFTSpec(vecData,vecFFTSpecData);
|
|
|
|
|
|
for(k = 0; k < vecFFTSpecData.size();k++){
|
|
|
|
|
|
x1.push_back(k+50*line);
|
|
|
|
|
|
y1.push_back(vecFFTSpecData.at(k)+0.1*line);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ui->widget->addGraph();
|
|
|
|
|
|
QPen pen;
|
|
|
|
|
|
pen.setColor(waveData.at(0).linColor);
|
|
|
|
|
|
pen.setStyle(Qt::SolidLine);
|
|
|
|
|
|
pen.setWidth(0);
|
|
|
|
|
|
ui->widget->graph(line)->setData(x1, y1);
|
|
|
|
|
|
ui->widget->graph(line)->setPen(pen);
|
|
|
|
|
|
|
|
|
|
|
|
line ++;
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->graph(0)->rescaleAxes();
|
|
|
|
|
|
|
|
|
|
|
|
ui->widget->xAxis->setRange(0, waveData[0].SamleRate/2);
|
|
|
|
|
|
ui->widget->xAxis->setLabel("Frequency(Hz)");
|
|
|
|
|
|
ui->widget->yAxis->setLabel(waveData[0].sensorType + "(" + waveData[0].sensorEngineeringUnit+")");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if(m_iFormType != WaterFallPlot){//设置通道颜色
|
|
|
|
|
|
ui->widget->graph(line)->rescaleValueAxis();
|
|
|
|
|
|
QPen pen;
|
|
|
|
|
|
pen.setColor(waveData.at(line).linColor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pen.setStyle(Qt::SolidLine);
|
|
|
|
|
|
if(m_iFormType == TrendChartPlot){
|
|
|
|
|
|
pen.setWidth(2);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
pen.setWidth(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->graph(line)->setPen(pen);
|
|
|
|
|
|
line++;
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->replot();
|
|
|
|
|
|
ZoomBtnSlot_XY();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::UpdateEnvSerises(QString Start,QString End)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
ui->widget->clearGraphs();
|
|
|
|
|
|
InitDisPaly();
|
|
|
|
|
|
if(Start.toInt() < 10 || End.toInt() > 131072){
|
|
|
|
|
|
MyMsgBox(QMessageBox::Warning,"警告","请输入正确信息!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_nStart = Start.toInt();
|
|
|
|
|
|
m_nEnd = End.toInt();
|
|
|
|
|
|
handlePlayWave(m_position,0);
|
|
|
|
|
|
|
|
|
|
|
|
// QVector<WAVE_DISPALYDATA> vecWaveDisplay;
|
|
|
|
|
|
// WAVE_DISPALYDATA WaveDisplay;
|
|
|
|
|
|
// QMap<QString,WAVE_DISPALYDATA>::Iterator iter = mapWaveDisplayData.begin();
|
|
|
|
|
|
// qDebug() << "listChannelID" << listChannelID.size() <<endl;
|
|
|
|
|
|
// for (int ii = 0; ii < listChannelID.size(); ++ii){
|
|
|
|
|
|
// for(;iter != mapWaveDisplayData.end();iter++){
|
|
|
|
|
|
// if(listChannelID.at(ii) == iter.key())
|
|
|
|
|
|
// {
|
|
|
|
|
|
// qDebug() << "ID" << iter.key() <<endl;
|
|
|
|
|
|
|
|
|
|
|
|
// WAVE_DISPALYDATA WaveDisplay;
|
|
|
|
|
|
// QVector<double> vecEnvSpecData;
|
|
|
|
|
|
// QVector<double> vecData;
|
|
|
|
|
|
// for(int j = 0; j < iter.value().wavedata.size();j++){
|
|
|
|
|
|
// float fData = iter.value().wavedata.at(j);
|
|
|
|
|
|
// vecData.push_back(fData);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// pCalculation->envSpec(vecData,vecEnvSpecData,Start.toInt(),End.toInt());
|
|
|
|
|
|
// qDebug() << "vecEnvSpecData" << vecEnvSpecData.size() <<endl;
|
|
|
|
|
|
// for(int jj = 0 ; jj < vecEnvSpecData.size();jj++){
|
|
|
|
|
|
// WaveDisplay.Key.push_back(jj);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// WaveDisplay.wavedataEnv = vecEnvSpecData;
|
|
|
|
|
|
|
|
|
|
|
|
// QPen pen;
|
|
|
|
|
|
// pen.setColor(iter.value().linColor);
|
|
|
|
|
|
// pen.setStyle(Qt::SolidLine);
|
|
|
|
|
|
// pen.setWidth(0);
|
|
|
|
|
|
// QCPGraph* graph = ui->widget->addGraph();
|
|
|
|
|
|
// waveGraph.insert(listChannelID.at(ii),graph);
|
|
|
|
|
|
// qDebug() << "wavedataEnv" << WaveDisplay.wavedataEnv.size() <<endl;
|
|
|
|
|
|
// ui->widget->graph(line)->setData(WaveDisplay.Key, WaveDisplay.wavedataEnv);
|
|
|
|
|
|
// ui->widget->graph(line)->rescaleValueAxis(true);
|
|
|
|
|
|
// ui->widget->graph(line)->setPen(pen);
|
|
|
|
|
|
// ui->widget->replot(QCustomPlot::rpImmediateRefresh);
|
|
|
|
|
|
// line ++ ;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::handlePlayWave(double position,double size )
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_iFormType == WaterFallPlot){
|
|
|
|
|
|
int graphCount = ui->widget->graphCount();
|
|
|
|
|
|
if(graphCount < 1)
|
|
|
|
|
|
return;
|
|
|
|
|
|
QPen pen;
|
|
|
|
|
|
pen.setColor(QColor(255,140,0));
|
|
|
|
|
|
pen.setStyle(Qt::SolidLine);
|
|
|
|
|
|
pen.setWidth(2);
|
|
|
|
|
|
ui->widget->graph(position)->setPen(pen);
|
|
|
|
|
|
ui->widget->replot();
|
|
|
|
|
|
for(int i = 0; i < graphCount;i++){
|
|
|
|
|
|
if( i != position){
|
|
|
|
|
|
QPen pen;
|
|
|
|
|
|
pen.setColor(childWave[0].linColor);
|
|
|
|
|
|
pen.setStyle(Qt::SolidLine);
|
|
|
|
|
|
pen.setWidth(0);
|
|
|
|
|
|
ui->widget->graph(position)->setPen(pen);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}else if(m_iFormType == TrendChartPlot){
|
|
|
|
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
|
{
|
|
|
|
|
|
int graphCount = ui->widget->clearGraphs();
|
|
|
|
|
|
}
|
|
|
|
|
|
if(m_iFormType != TrendChartPlot)
|
|
|
|
|
|
QMap<QString,QCPGraph*>().swap(waveGraph);
|
|
|
|
|
|
m_position = position;
|
|
|
|
|
|
//使键轴范围与数据一起滚动:
|
|
|
|
|
|
if(m_iFormType == FrequencyDomainPlot ||
|
|
|
|
|
|
m_iFormType == EnvChartPlot ||
|
|
|
|
|
|
m_iFormType == TimeDomainPlot){
|
|
|
|
|
|
int xRange = 0;
|
|
|
|
|
|
QCPGraph* graph = NULL;
|
|
|
|
|
|
for (int i = 0; i < listChannelID.size(); ++i){
|
|
|
|
|
|
WAVE_DISPALYDATA waveShowData;
|
|
|
|
|
|
QMap<QString,QVector<WAVE_DATA>>::Iterator iterWaveData = mapWaveData.begin();
|
|
|
|
|
|
for(;iterWaveData != mapWaveData.end();iterWaveData++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(listChannelID.at(i) == iterWaveData.key()){
|
|
|
|
|
|
QMap<QString,QMap<QString,QCPAxis*>>::Iterator iterMultiAxis = mapMultiGraph.begin();
|
|
|
|
|
|
for(;iterMultiAxis != mapMultiGraph.end();iterMultiAxis++){
|
|
|
|
|
|
QMap<QString,QCPAxis*>::Iterator iterAxis = iterMultiAxis.value().begin();
|
|
|
|
|
|
for(;iterAxis != iterMultiAxis.value().end();iterAxis++){
|
|
|
|
|
|
if(iterAxis.key() == listChannelID.at(i)){
|
|
|
|
|
|
qDebug() << iterAxis.key() << endl;
|
|
|
|
|
|
SecondData(listChannelID.at(i),iterWaveData.value()[position],waveShowData);
|
|
|
|
|
|
graph = ui->widget->addGraph(ui->widget->xAxis,iterAxis.value());
|
|
|
|
|
|
iterAxis.value()->setLabel(waveShowData.channelType + "(" + waveShowData.sensorEngineeringUnit+")");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(m_bRpm){
|
|
|
|
|
|
CalculateRPM();
|
|
|
|
|
|
}
|
|
|
|
|
|
if(m_bIntegration || m_bDoubleIntegration){
|
|
|
|
|
|
if(m_bIntegration)
|
|
|
|
|
|
CalculateIntegration(false);
|
|
|
|
|
|
else if(m_bDoubleIntegration)
|
|
|
|
|
|
CalculateIntegration(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(m_bDifferentiation || m_bDoubleDifferentiation){
|
|
|
|
|
|
if(m_bDifferentiation)
|
|
|
|
|
|
CalculateDifferentiation(false);
|
|
|
|
|
|
else if(m_bDoubleDifferentiation)
|
|
|
|
|
|
CalculateDifferentiation(true);
|
|
|
|
|
|
}else
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_bDC){
|
|
|
|
|
|
graph->setData(waveShowData.Key, waveShowData.wavedata_DC);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
if(m_iFormType == EnvChartPlot){
|
|
|
|
|
|
graph->setData(waveShowData.Key, waveShowData.wavedataEnv);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
graph->setData(waveShowData.Key, waveShowData.wavedata);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
graph->rescaleValueAxis();
|
|
|
|
|
|
xRange = waveShowData.Key.size();
|
|
|
|
|
|
graph->setName(waveShowData.channleName);
|
|
|
|
|
|
QPen pen;
|
|
|
|
|
|
pen.setColor(waveShowData.linColor);
|
|
|
|
|
|
pen.setStyle(Qt::SolidLine);
|
|
|
|
|
|
pen.setWidth(0);
|
|
|
|
|
|
graph->setPen(pen);
|
|
|
|
|
|
if(m_iFormType == FrequencyDomainPlot || m_iFormType == EnvChartPlot){
|
|
|
|
|
|
ui->widget->xAxis->setRange(0, 1000);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
waveGraph.insert(listChannelID.at(i),graph);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}else if(m_iFormType == OrbitPlot){
|
|
|
|
|
|
ui->widget->clearPlottables();
|
|
|
|
|
|
if(listChannelID.size() < 1)
|
|
|
|
|
|
return;
|
|
|
|
|
|
if(OrbitXWave.size() < 1 || OrbitYWave.size() < 1)
|
|
|
|
|
|
return;
|
|
|
|
|
|
double gap = (double)1/(double)OrbitXWave[position].SamleRate;
|
|
|
|
|
|
double f = 0.0;
|
|
|
|
|
|
qDebug() << "OrbitXWave" << OrbitXWave.size();
|
|
|
|
|
|
QVector<QCPGraphData> vecmainGraph1(OrbitXWave[position].waveData.size()),vecmainGraph2(OrbitYWave[position].waveData.size());
|
|
|
|
|
|
for(int i = 0 ; i < OrbitXWave[position].waveData.size(); i++){
|
|
|
|
|
|
f += gap;
|
|
|
|
|
|
vecmainGraph1[i].key = f;
|
|
|
|
|
|
vecmainGraph1[i].value = OrbitXWave[position].waveData[i]-OrbitXWave[position].mean;
|
|
|
|
|
|
}
|
|
|
|
|
|
mainGraph1 = ui->widget->addGraph(wideAxisRect1->axis(QCPAxis::atBottom), wideAxisRect1->axis(QCPAxis::atLeft));
|
|
|
|
|
|
mainGraph1->data()->set(vecmainGraph1);
|
|
|
|
|
|
mainGraph1->rescaleAxes();
|
|
|
|
|
|
mainGraph1->setPen(QPen(QColor(OrbitYWave[0].linColor), 2));
|
|
|
|
|
|
|
|
|
|
|
|
gap = (double)1/(double)OrbitYWave[position].SamleRate;
|
|
|
|
|
|
f = 0.0;
|
|
|
|
|
|
for(int i = 0 ; i < OrbitYWave[position].waveData.size(); i++){
|
|
|
|
|
|
f += gap;
|
|
|
|
|
|
vecmainGraph2[i].key = f;
|
|
|
|
|
|
vecmainGraph2[i].value = OrbitYWave[position].waveData[i]-OrbitYWave[position].mean;
|
|
|
|
|
|
}
|
|
|
|
|
|
mainGraph2 = ui->widget->addGraph(wideAxisRect2->axis(QCPAxis::atBottom), wideAxisRect2->axis(QCPAxis::atLeft));
|
|
|
|
|
|
mainGraph2->data()->set(vecmainGraph2);
|
|
|
|
|
|
mainGraph2->rescaleAxes();
|
|
|
|
|
|
mainGraph2->setPen(QPen(QColor(OrbitXWave[0].linColor), 2));
|
|
|
|
|
|
|
|
|
|
|
|
fermatSpiral1 = new QCPCurve(wideAxisRectOrbit->axis(QCPAxis::atBottom), wideAxisRectOrbit->axis(QCPAxis::atLeft));
|
|
|
|
|
|
int pointCount = OrbitXWave[0].wavesize;
|
|
|
|
|
|
QVector<QCPCurveData> dataSpiral1(pointCount); //元素数组
|
|
|
|
|
|
for (int i = 0; i<pointCount; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
dataSpiral1[i] = QCPCurveData(i, OrbitXWave[position].waveData.at(i)-OrbitXWave[position].mean,\
|
|
|
|
|
|
OrbitYWave[position].waveData.at(i)-OrbitYWave[position].mean);
|
|
|
|
|
|
}
|
|
|
|
|
|
fermatSpiral1->data()->set(dataSpiral1, true);
|
|
|
|
|
|
fermatSpiral1->setPen(QPen(OrbitYWave[0].linColor));
|
|
|
|
|
|
fermatSpiral1->rescaleAxes();
|
|
|
|
|
|
QCPGraph* dwPoints = new QCPGraph(wideAxisRectOrbit->axis(QCPAxis::atBottom), wideAxisRectOrbit->axis(QCPAxis::atLeft));
|
|
|
|
|
|
dwPoints->setAdaptiveSampling(false);
|
|
|
|
|
|
dwPoints->setLineStyle(QCPGraph::lsNone);
|
|
|
|
|
|
dwPoints->setScatterStyle(QCPScatterStyle::ssDot);
|
|
|
|
|
|
dwPoints->setPen(QPen(QBrush(Qt::white), 2));
|
|
|
|
|
|
dwPoints->addData(vecKeyPhasor[position].key, vecKeyPhasor[position].value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
ZoomBtnSlot_XY();
|
|
|
|
|
|
ui->widget->replot(QCustomPlot::rpImmediateRefresh);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
QPixmap ChildForm::GetSerise(QString& strImagePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
QPixmap pixmap = ui->widget->toPixmap(600,400);
|
|
|
|
|
|
QString PicName = "";
|
|
|
|
|
|
switch(m_iFormType){
|
|
|
|
|
|
case TimeDomainPlot:
|
|
|
|
|
|
PicName = "TimeDomain";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case FrequencyDomainPlot:
|
|
|
|
|
|
PicName = "FrequencyDomain";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case TrendChartPlot:
|
|
|
|
|
|
PicName = "TrendChart";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case SpecChartPlot:
|
|
|
|
|
|
PicName = "SpecChart";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EnvChartPlot:
|
|
|
|
|
|
PicName = "EnvChart";
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
strImagePath = QCoreApplication::applicationDirPath() + "\\report\\" + PicName + ".png";
|
|
|
|
|
|
ui->widget->savePng(strImagePath,600,400);
|
|
|
|
|
|
// =QWidget::grab(QRect(ui->widget->x(),ui->widget->y(),ui->widget->frameGeometry().width(),ui->widget->frameGeometry().height()));
|
|
|
|
|
|
return pixmap;
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::AddShaftCenterlineSeries(QString strID, const QVector<WAVE_DATA>& wavexData,const QVector<WAVE_DATA>& waveyData)
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->widget->clearGraphs();
|
|
|
|
|
|
foreach (auto ID, listChannelID){
|
|
|
|
|
|
if(ID != strID){
|
|
|
|
|
|
m_mapChannelIDtoLabel[ID]->setCheckState(Qt::Unchecked);
|
|
|
|
|
|
m_mapChannelIDtoLabel[ID]->setSelected(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
QVector<double> key,value;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < wavexData.size(); ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
double sum1 = std::accumulate(std::begin(wavexData[i].waveData), std::end(wavexData[i].waveData), 0.0);
|
|
|
|
|
|
double mean1 = sum1/(double)wavexData[i].waveData.size();
|
|
|
|
|
|
key.push_back(mean1 - wavexData[0].sensorGapVoltage * 1000/wavexData[0].sensorSensitivity);
|
|
|
|
|
|
//qDebug() << sum1 << wavexData[i].waveData.size() << mean1 << key[0] << endl;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < waveyData.size(); ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
double sum1 = std::accumulate(std::begin(waveyData[i].waveData), std::end(waveyData[i].waveData), 0.0);
|
|
|
|
|
|
double mean1 = sum1/(double)waveyData[i].waveData.size();
|
|
|
|
|
|
value.push_back(mean1 - waveyData[0].sensorGapVoltage*1000/waveyData[0].sensorSensitivity);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
qDebug() << "AddShaftCenterlineSeries" << key.size() << value.size() << endl;
|
|
|
|
|
|
|
|
|
|
|
|
QCPCurve* ShaftCenterline = new QCPCurve(ui->widget->xAxis, ui->widget->yAxis);
|
|
|
|
|
|
|
|
|
|
|
|
/*QVector<double> x(251), y0(251), y1(251);
|
|
|
|
|
|
for (int i=0; i<251; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
x[i] = i;
|
|
|
|
|
|
y0[i] = qExp(-i/150.0)*qCos(i/10.0); // exponentially decaying cosine
|
|
|
|
|
|
y1[i] = qExp(-i/150.0); // exponential envelope
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
QVector<QCPCurveData> dataSpiral1(value.size());
|
|
|
|
|
|
for (int i = 0; i < value.size(); ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
dataSpiral1[i] = QCPCurveData(i, key[i], value[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
ShaftCenterline->data()->set(dataSpiral1,true);
|
|
|
|
|
|
ShaftCenterline->setPen(QPen(wavexData[0].linColor));
|
|
|
|
|
|
//ShaftCenterline->setBrush(QBrush(QColor(0, 0, 255, 20)));
|
|
|
|
|
|
|
|
|
|
|
|
ShaftCenterline->rescaleAxes();
|
|
|
|
|
|
ui->widget->xAxis->setLabel(wavexData[0].sensorEngineeringUnit);
|
|
|
|
|
|
ui->widget->yAxis->setLabel(waveyData[0].sensorEngineeringUnit);
|
|
|
|
|
|
// ui->widget->xAxis->setRange(-1,1);
|
|
|
|
|
|
//ui->widget->yAxis->setRange(-1,1);
|
|
|
|
|
|
ShaftCenterline->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, QPen(Qt::red, 1.5), QBrush(Qt::red), 3));//散列点
|
|
|
|
|
|
ui->widget->replot(QCustomPlot::rpImmediateRefresh);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ChildForm::AddBodeSeries(QString strID, const QVector<WAVE_DATA>& waveData,const QVector<WAVE_DATA>& waveSpeedData)
|
|
|
|
|
|
{
|
|
|
|
|
|
/*mapBodeData.insert(strID,waveData);
|
|
|
|
|
|
if(mapBodeData.size() < 2){
|
|
|
|
|
|
MyMsgBox(QMessageBox::Warning,"警告","请选择两条通道进行伯德图分析!");
|
|
|
|
|
|
return ;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QVector<WAVE_DATA> waveSpeedData; //转速
|
|
|
|
|
|
QVector<WAVE_DATA> waveVibrateData; //振动
|
|
|
|
|
|
QMap<QString,QVector<WAVE_DATA>>::Iterator iter = mapBodeData.begin();
|
|
|
|
|
|
for (;iter != mapBodeData.end() ; iter++) {
|
|
|
|
|
|
if(iter.value()[0].sensorType != "ACCELEROMETER" && iter.value()[0].sensorType != "TACHOMETER"){
|
|
|
|
|
|
MyMsgBox(QMessageBox::Warning,"警告","请选择转速和振动通道进行伯德图分析");
|
|
|
|
|
|
}
|
|
|
|
|
|
if(iter.value()[0].sensorType == "TACHOMETER"){
|
|
|
|
|
|
waveSpeedData = iter.value();
|
|
|
|
|
|
}
|
|
|
|
|
|
if(iter.value()[0].sensorType == "ACCELEROMETER"){
|
|
|
|
|
|
waveVibrateData = iter.value();
|
|
|
|
|
|
}
|
|
|
|
|
|
}*/
|
|
|
|
|
|
foreach (auto ID, listChannelID){
|
|
|
|
|
|
if(ID != strID){
|
|
|
|
|
|
m_mapChannelIDtoLabel[ID]->setCheckState(Qt::Unchecked);
|
|
|
|
|
|
m_mapChannelIDtoLabel[ID]->setSelected(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->plotLayout()->clear();
|
|
|
|
|
|
ui->widget->clearGraphs();
|
|
|
|
|
|
ui->widget->clearPlottables();
|
|
|
|
|
|
|
|
|
|
|
|
QCPAxisRect *wideAxisRect1 = new QCPAxisRect(ui->widget);
|
|
|
|
|
|
QCPAxisRect *wideAxisRect2 = new QCPAxisRect(ui->widget);
|
|
|
|
|
|
wideAxisRect1->axis(QCPAxis::atLeft, 0)->setTickLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRect1->axis(QCPAxis::atLeft, 0)->setLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRect1->axis(QCPAxis::atLeft, 0)->setBasePen(QPen(Qt::white, 1));
|
|
|
|
|
|
|
|
|
|
|
|
wideAxisRect1->axis(QCPAxis::atBottom, 0)->setTickLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRect1->axis(QCPAxis::atBottom, 0)->setLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRect1->axis(QCPAxis::atBottom, 0)->setBasePen(QPen(Qt::white, 1));
|
|
|
|
|
|
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atLeft, 0)->setTickLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atLeft, 0)->setLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atLeft, 0)->setBasePen(QPen(Qt::white, 1));
|
|
|
|
|
|
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atBottom, 0)->setTickLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atBottom, 0)->setLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atBottom, 0)->setBasePen(QPen(Qt::white, 1));
|
|
|
|
|
|
|
|
|
|
|
|
//wideAxisRect1->axis(QCPAxis::atBottom, 0)->setLabel("");
|
|
|
|
|
|
wideAxisRect1->axis(QCPAxis::atLeft, 0)->setLabel("Degree Lag");
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atBottom, 0)->setLabel("RPM");
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atLeft, 0)->setLabel("mils(p-p)");
|
|
|
|
|
|
|
|
|
|
|
|
wideAxisRect1->axis(QCPAxis::atLeft, 0)->setRange(-360,360);
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atLeft, 0)->setRange(0,8);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->widget->plotLayout()->addElement(0, 0, wideAxisRect1); // insert axis rect in first row
|
|
|
|
|
|
ui->widget->plotLayout()->addElement(1, 0, wideAxisRect2);
|
|
|
|
|
|
|
|
|
|
|
|
QCPMarginGroup *marginGroup = new QCPMarginGroup(ui->widget);
|
|
|
|
|
|
wideAxisRect1->setMarginGroup(QCP::msLeft, marginGroup);
|
|
|
|
|
|
wideAxisRect2->setMarginGroup(QCP::msLeft, marginGroup);
|
|
|
|
|
|
|
|
|
|
|
|
QCPGraph *mainGraph1 = ui->widget->addGraph(wideAxisRect1->axis(QCPAxis::atBottom), wideAxisRect1->axis(QCPAxis::atLeft));
|
|
|
|
|
|
mainGraph1->rescaleAxes();
|
|
|
|
|
|
mainGraph1->setPen(QPen(QColor(Qt::green), 2));
|
|
|
|
|
|
|
|
|
|
|
|
QCPGraph *mainGraph2 = ui->widget->addGraph(wideAxisRect2->axis(QCPAxis::atBottom), wideAxisRect2->axis(QCPAxis::atLeft));
|
|
|
|
|
|
mainGraph2->rescaleAxes();
|
|
|
|
|
|
mainGraph2->setPen(QPen(QColor(Qt::green), 2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QVector<int> vecSpeedTime;
|
|
|
|
|
|
|
|
|
|
|
|
/*for(int i = 0; i < waveSpeedData[0].Time;i++){
|
|
|
|
|
|
|
|
|
|
|
|
for(int j = 1; j < waveSpeedData.at(i).waveData.size();j++){
|
|
|
|
|
|
if(waveSpeedData.at(i).waveData[j-1] < -18 && waveSpeedData.at(i).waveData[j] > -18 && \
|
|
|
|
|
|
waveSpeedData.at(i).waveData[j-1] > -21){
|
|
|
|
|
|
vecSpeedTime.push_back(j + (waveSpeedData[0].SamleRate * i));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}*/
|
|
|
|
|
|
for(int i = 0; i < waveSpeedData[0].Time;i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
QVector<double> vecTemp;
|
|
|
|
|
|
int flag = 0;
|
|
|
|
|
|
//qDebug() << "=====size====="<< waveSpeedData.at(i).waveData.size() << endl;
|
|
|
|
|
|
for(int j = 1; j < waveSpeedData.at(0).waveData.size();j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(waveSpeedData.at(0).iTrigger == 0){
|
|
|
|
|
|
if(waveSpeedData.at(i).waveData[j-1] > waveSpeedData.at(0).iTriggerValue && flag == 0){
|
|
|
|
|
|
|
|
|
|
|
|
flag = 1;
|
|
|
|
|
|
}else if(waveSpeedData.at(i).waveData[j-1] < (waveSpeedData.at(0).iTriggerValue-waveSpeedData.at(0).iHysteresis) && flag == 1){
|
|
|
|
|
|
|
|
|
|
|
|
flag = 0;
|
|
|
|
|
|
double time = (double)j/(double)waveSpeedData.at(0).SamleRate;
|
|
|
|
|
|
vecSpeedTime.push_back(j + (waveSpeedData[0].SamleRate * i));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QVector<QCPGraphData> vecmainGraph1;
|
|
|
|
|
|
QVector<QCPGraphData> vecmainGraph2;
|
|
|
|
|
|
QVector<RPM> vecSpeed;
|
|
|
|
|
|
double sum = 0.0;
|
|
|
|
|
|
qDebug() << "=====Speed=====" << vecSpeedTime[99] << vecSpeedTime[100] << endl;
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
for(int j = 1;j < vecSpeedTime.size();j++){
|
|
|
|
|
|
float Speed = float((vecSpeedTime[j]-vecSpeedTime[j-1])/(float)waveSpeedData[0].SamleRate);
|
|
|
|
|
|
Speed = (1/Speed * 60)/waveSpeedData[0].iKeyCount;//键齿数
|
|
|
|
|
|
|
|
|
|
|
|
/*QCPGraphData data;
|
|
|
|
|
|
data.key = j-1;
|
|
|
|
|
|
data.value = Speed;
|
|
|
|
|
|
vecmainGraph1.push_back(data);*/
|
|
|
|
|
|
|
|
|
|
|
|
RPM rpmData;
|
|
|
|
|
|
rpmData.key1 = vecSpeedTime[j-1];
|
|
|
|
|
|
rpmData.key2 = vecSpeedTime[j];
|
|
|
|
|
|
rpmData.fSpeed = Speed;
|
|
|
|
|
|
vecSpeed.push_back(rpmData);
|
|
|
|
|
|
//qDebug() << "=====Speed=====" << Speed << vecSpeedTime.at(j) << vecSpeedTime.at(j-1) << endl;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QVector<RPM> vecIncreaseSpeed;
|
|
|
|
|
|
for(int i = 1; i <vecSpeed.size();i++ ){
|
|
|
|
|
|
// qDebug() << "=====iter=====" << vecSpeed[i].key <<vecSpeed[i].fSpeed<< endl;
|
|
|
|
|
|
float value = vecSpeed[i].fSpeed - vecSpeed[i-1].fSpeed;
|
|
|
|
|
|
//qDebug() << "=====value=====" << value << endl;
|
|
|
|
|
|
if(value > 10){//增速
|
|
|
|
|
|
RPM rpmData;
|
|
|
|
|
|
rpmData.key1 = vecSpeed[i-1].key1;
|
|
|
|
|
|
rpmData.key2 = vecSpeed[i-1].key2;
|
|
|
|
|
|
rpmData.fSpeed = vecSpeed[i-1].fSpeed;
|
|
|
|
|
|
vecIncreaseSpeed.push_back(rpmData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
QVector<float> VibrateData;//(waveVibrateData.size() * waveVibrateData[0].SamleRate);
|
|
|
|
|
|
VibrateData.reserve(waveData.size() * waveData[0].SamleRate);
|
|
|
|
|
|
for(int i = 0; i < waveData.size();i++){
|
|
|
|
|
|
for(int j = 0 ;j < waveData[i].waveData.size();j++){
|
|
|
|
|
|
VibrateData.push_back(waveData[i].waveData[j] - waveData[i].mean);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
qDebug()<< "vecIncreaseSpeed"<< vecIncreaseSpeed.size() << endl;
|
|
|
|
|
|
for(int i = 0; i <vecIncreaseSpeed.size();i++ ){//每圈
|
|
|
|
|
|
QVector<double> vecPP;
|
|
|
|
|
|
int Time1 = (float) vecIncreaseSpeed[i].key1/(waveSpeedData[0].SamleRate * waveSpeedData[0].Time) * waveData[0].SamleRate;
|
|
|
|
|
|
int Time2 = (float)(vecIncreaseSpeed[i].key2)/(waveSpeedData[0].SamleRate * waveSpeedData[0].Time)* waveData[0].SamleRate;
|
|
|
|
|
|
for (int i = Time1; i < Time2 ; i++) {
|
|
|
|
|
|
vecPP.push_back(VibrateData[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
qDebug() << "pp" << vecPP.size() << endl;
|
|
|
|
|
|
auto p1 = std::max_element(std::begin(vecPP), std::end(vecPP));
|
|
|
|
|
|
auto p2 = std::min_element(std::begin(vecPP), std::end(vecPP));
|
|
|
|
|
|
float Max = *p1;
|
|
|
|
|
|
float Min = *p2;
|
|
|
|
|
|
qDebug() << "=====Max====="<< *p1 << "===Min===" << *p2 << endl;
|
|
|
|
|
|
QCPGraphData data;
|
|
|
|
|
|
data.key = vecIncreaseSpeed[i].fSpeed;
|
|
|
|
|
|
data.value = Max - Min;
|
|
|
|
|
|
vecmainGraph2.push_back(data);
|
|
|
|
|
|
double Phase = pCalculation->Phase(vecPP);
|
|
|
|
|
|
qDebug() << "=====Phase1====="<< Phase << endl;
|
|
|
|
|
|
QCPGraphData data1;
|
|
|
|
|
|
data1.key = vecIncreaseSpeed[i].fSpeed;
|
|
|
|
|
|
data1.value = Phase;
|
|
|
|
|
|
vecmainGraph1.push_back(data1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mainGraph1 = ui->widget->addGraph(wideAxisRect1->axis(QCPAxis::atBottom), wideAxisRect1->axis(QCPAxis::atLeft));
|
|
|
|
|
|
mainGraph1->data()->set(vecmainGraph1);
|
|
|
|
|
|
mainGraph1->rescaleKeyAxis();
|
|
|
|
|
|
mainGraph1->setPen(QPen(QColor(waveData[0].linColor), 1));
|
|
|
|
|
|
mainGraph1->setName("1");
|
|
|
|
|
|
|
|
|
|
|
|
mainGraph2 = ui->widget->addGraph(wideAxisRect2->axis(QCPAxis::atBottom), wideAxisRect2->axis(QCPAxis::atLeft));
|
|
|
|
|
|
mainGraph2->data()->set(vecmainGraph2);
|
|
|
|
|
|
mainGraph2->rescaleKeyAxis();
|
|
|
|
|
|
mainGraph2->setPen(QPen(QColor(waveData[0].linColor), 1));
|
|
|
|
|
|
mainGraph2->setName("2");
|
|
|
|
|
|
ui->widget->replot();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::AddOrbitSeries(QString strID, const QVector<WAVE_DATA>& wavexData,const QVector<WAVE_DATA>& waveyData,\
|
|
|
|
|
|
const QVector<WAVE_DATA>& waveSpeedData)
|
|
|
|
|
|
{
|
|
|
|
|
|
QVector<WAVE_DATA>().swap(OrbitXWave);
|
|
|
|
|
|
QVector<WAVE_DATA>().swap(OrbitYWave);
|
|
|
|
|
|
QVector<KeyPhasor>().swap(vecKeyPhasor);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (auto ID, listChannelID){
|
|
|
|
|
|
if(ID != strID){
|
|
|
|
|
|
m_mapChannelIDtoLabel[ID]->setCheckState(Qt::Unchecked);
|
|
|
|
|
|
m_mapChannelIDtoLabel[ID]->setSelected(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OrbitXWave = wavexData;
|
|
|
|
|
|
OrbitYWave = waveyData;
|
|
|
|
|
|
ui->widget->plotLayout()->clear();
|
|
|
|
|
|
|
|
|
|
|
|
wideAxisRect1 = new QCPAxisRect(ui->widget);
|
|
|
|
|
|
wideAxisRect2 = new QCPAxisRect(ui->widget);
|
|
|
|
|
|
wideAxisRectOrbit = new QCPAxisRect(ui->widget);
|
|
|
|
|
|
|
|
|
|
|
|
wideAxisRect1->axis(QCPAxis::atLeft, 0)->setTickLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRect1->axis(QCPAxis::atLeft, 0)->setLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRect1->axis(QCPAxis::atLeft, 0)->setBasePen(QPen(Qt::white, 1));
|
|
|
|
|
|
|
|
|
|
|
|
wideAxisRect1->axis(QCPAxis::atBottom, 0)->setTickLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRect1->axis(QCPAxis::atBottom, 0)->setLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRect1->axis(QCPAxis::atBottom, 0)->setBasePen(QPen(Qt::white, 1));
|
|
|
|
|
|
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atLeft, 0)->setTickLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atLeft, 0)->setLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atLeft, 0)->setBasePen(QPen(Qt::white, 1));
|
|
|
|
|
|
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atBottom, 0)->setTickLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atBottom, 0)->setLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atBottom, 0)->setBasePen(QPen(Qt::white, 1));
|
|
|
|
|
|
|
|
|
|
|
|
wideAxisRectOrbit->axis(QCPAxis::atLeft, 0)->setTickLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRectOrbit->axis(QCPAxis::atLeft, 0)->setLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRectOrbit->axis(QCPAxis::atLeft, 0)->setBasePen(QPen(Qt::white, 1));
|
|
|
|
|
|
|
|
|
|
|
|
wideAxisRectOrbit->axis(QCPAxis::atBottom, 0)->setTickLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRectOrbit->axis(QCPAxis::atBottom, 0)->setLabelColor(Qt::white);
|
|
|
|
|
|
wideAxisRectOrbit->axis(QCPAxis::atBottom, 0)->setBasePen(QPen(Qt::white, 1));
|
|
|
|
|
|
|
|
|
|
|
|
wideAxisRect1->axis(QCPAxis::atBottom, 0)->setLabel("Time(s)");
|
|
|
|
|
|
wideAxisRect1->axis(QCPAxis::atLeft, 0)->setLabel(wavexData[0].sensorEngineeringUnit);
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atBottom, 0)->setLabel("Time(s)");
|
|
|
|
|
|
wideAxisRect2->axis(QCPAxis::atLeft, 0)->setLabel(waveyData[0].sensorEngineeringUnit);
|
|
|
|
|
|
wideAxisRectOrbit->axis(QCPAxis::atBottom, 0)->setLabel(wavexData[0].sensorEngineeringUnit);
|
|
|
|
|
|
wideAxisRectOrbit->axis(QCPAxis::atLeft, 0)->setLabel(waveyData[0].sensorEngineeringUnit);
|
|
|
|
|
|
|
|
|
|
|
|
QCPLayoutGrid *subLayout = new QCPLayoutGrid;
|
|
|
|
|
|
ui->widget->plotLayout()->addElement(0, 1, subLayout); // insert axis rect in first row
|
|
|
|
|
|
ui->widget->plotLayout()->addElement(0, 0, wideAxisRectOrbit);
|
|
|
|
|
|
subLayout->addElement(0, 0, wideAxisRect1);
|
|
|
|
|
|
subLayout->addElement(1, 0, wideAxisRect2);
|
|
|
|
|
|
double gap = (double)1/(double)wavexData[0].SamleRate;
|
|
|
|
|
|
double f = 0.0;
|
|
|
|
|
|
QVector<QCPGraphData> vecmainGraph1(wavexData[0].waveData.size()),vecmainGraph2(waveyData[0].waveData.size());
|
|
|
|
|
|
for(int i = 0 ; i < wavexData[0].waveData.size(); i++){
|
|
|
|
|
|
f += gap;
|
|
|
|
|
|
vecmainGraph1[i].key = f;
|
|
|
|
|
|
vecmainGraph1[i].value = wavexData[0].waveData[i]-wavexData[0].mean;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mainGraph1 = ui->widget->addGraph(wideAxisRect1->axis(QCPAxis::atBottom), wideAxisRect1->axis(QCPAxis::atLeft));
|
|
|
|
|
|
mainGraph1->data()->set(vecmainGraph1);
|
|
|
|
|
|
mainGraph1->rescaleAxes();
|
|
|
|
|
|
mainGraph1->setPen(QPen(QColor(waveyData[0].linColor), 2));
|
|
|
|
|
|
|
|
|
|
|
|
gap = (double)1/(double)waveyData[0].SamleRate;
|
|
|
|
|
|
f = 0.0;
|
|
|
|
|
|
for(int i = 0 ; i < waveyData[0].waveData.size(); i++){
|
|
|
|
|
|
f += gap;
|
|
|
|
|
|
vecmainGraph2[i].key = f;
|
|
|
|
|
|
vecmainGraph2[i].value = waveyData[0].waveData[i]-waveyData[0].mean;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mainGraph2 = ui->widget->addGraph(wideAxisRect2->axis(QCPAxis::atBottom), wideAxisRect2->axis(QCPAxis::atLeft));
|
|
|
|
|
|
mainGraph2->data()->set(vecmainGraph2);
|
|
|
|
|
|
mainGraph2->rescaleAxes();
|
|
|
|
|
|
mainGraph2->setPen(QPen(QColor(wavexData[0].linColor), 2));
|
|
|
|
|
|
|
|
|
|
|
|
fermatSpiral1 = new QCPCurve(wideAxisRectOrbit->axis(QCPAxis::atBottom), wideAxisRectOrbit->axis(QCPAxis::atLeft));
|
|
|
|
|
|
int pointCount = wavexData[0].wavesize;
|
|
|
|
|
|
QVector<QCPCurveData> dataSpiral1(pointCount); //元素数组
|
|
|
|
|
|
qDebug() << wavexData[0].waveData.at(10) << waveyData[0].waveData.at(10) << endl;
|
|
|
|
|
|
for (int i=0; i<pointCount; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
dataSpiral1[i] = QCPCurveData(i, wavexData[0].waveData.at(i)-wavexData[0].mean, waveyData[0].waveData.at(i)-waveyData[0].mean);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fermatSpiral1->data()->set(dataSpiral1, true);
|
|
|
|
|
|
fermatSpiral1->setPen(QPen(waveyData[0].linColor));
|
|
|
|
|
|
fermatSpiral1->rescaleAxes();
|
|
|
|
|
|
|
|
|
|
|
|
QVector<QVector<double>> vecSpeedTime;
|
|
|
|
|
|
qDebug() << "=====Time====="<< waveSpeedData[0].Time << endl;
|
|
|
|
|
|
qDebug() << "=====wavexData size====="<< wavexData.size() << endl;
|
|
|
|
|
|
int iTime = 0;
|
|
|
|
|
|
if(wavexData.size() <= waveSpeedData[0].Time)//防止Dat文件数据丢失,取实际读到的秒数
|
|
|
|
|
|
iTime = wavexData.size();
|
|
|
|
|
|
for(int i = 0; i < iTime;i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
QVector<double> vecTemp;
|
|
|
|
|
|
int flag = 0;
|
|
|
|
|
|
qDebug() << "=====size====="<< waveSpeedData.at(i).waveData.size() << endl;
|
|
|
|
|
|
for(int j = 1; j < waveSpeedData.at(0).waveData.size();j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(waveSpeedData.at(0).iTrigger == 0){
|
|
|
|
|
|
if(waveSpeedData.at(i).waveData[j-1] > waveSpeedData.at(0).iTriggerValue && flag == 0){
|
|
|
|
|
|
|
|
|
|
|
|
flag = j;
|
|
|
|
|
|
}else if(waveSpeedData.at(i).waveData[j-1] < (waveSpeedData.at(0).iTriggerValue-waveSpeedData.at(0).iHysteresis) && flag > 0){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double time = (double)flag/(double)waveSpeedData.at(0).SamleRate;
|
|
|
|
|
|
vecTemp.push_back(time);
|
|
|
|
|
|
flag = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
vecSpeedTime.push_back(vecTemp);
|
|
|
|
|
|
qDebug() << "=====vecSpeedTime====="<< vecSpeedTime.size()<< endl;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
qDebug() << "=====vecSpeedTime====="<< vecSpeedTime[10][10]<< endl;
|
|
|
|
|
|
QVector<double> key,value;
|
|
|
|
|
|
for(int j = 0;j < vecSpeedTime.size();j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
KeyPhasor keyphasor;
|
|
|
|
|
|
for(int i = 0 ;i < vecSpeedTime[j].size();i++){
|
|
|
|
|
|
keyphasor.key.push_back(OrbitXWave[j].waveData[vecSpeedTime[j][i]*OrbitXWave[0].SamleRate]-OrbitXWave[0].mean);
|
|
|
|
|
|
keyphasor.value.push_back(OrbitYWave[j].waveData[vecSpeedTime[j][i]*OrbitYWave[0].SamleRate]-OrbitYWave[0].mean);
|
|
|
|
|
|
}
|
|
|
|
|
|
vecKeyPhasor.push_back(keyphasor);
|
|
|
|
|
|
}
|
|
|
|
|
|
qDebug() << "=====vecKeyPhasor====="<< vecKeyPhasor.size()<< endl;
|
|
|
|
|
|
|
|
|
|
|
|
//保留
|
|
|
|
|
|
/*keyPhasor = ui->widget->addGraph(wideAxisRectOrbit->axis(QCPAxis::atBottom), wideAxisRectOrbit->axis(QCPAxis::atLeft));
|
|
|
|
|
|
keyPhasor->data()->set(vecKeyPhasor);
|
|
|
|
|
|
keyPhasor->rescaleAxes();
|
|
|
|
|
|
QPen drawPen;
|
|
|
|
|
|
drawPen.setColor(Qt::red);
|
|
|
|
|
|
drawPen.setWidth(4);
|
|
|
|
|
|
keyPhasor->setPen(drawPen);
|
|
|
|
|
|
keyPhasor->setLineStyle(QCPGraph::lsNone);
|
|
|
|
|
|
keyPhasor->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 2));*/
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
QCPGraph* dwPoints = new QCPGraph(wideAxisRectOrbit->axis(QCPAxis::atBottom), wideAxisRectOrbit->axis(QCPAxis::atLeft));
|
|
|
|
|
|
dwPoints->setAdaptiveSampling(false);
|
|
|
|
|
|
dwPoints->setLineStyle(QCPGraph::lsNone);
|
|
|
|
|
|
dwPoints->setScatterStyle(QCPScatterStyle::ssDot);
|
|
|
|
|
|
dwPoints->setPen(QPen(QBrush(Qt::white), 2));
|
|
|
|
|
|
|
|
|
|
|
|
dwPoints->addData(vecKeyPhasor[0].key, vecKeyPhasor[0].value);
|
|
|
|
|
|
//dwPoints->rescaleAxes();
|
|
|
|
|
|
|
|
|
|
|
|
ui->widget->replot();
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::AddPolarPlotSeries(QString strID, const QVector<WAVE_DATA>& wavexData,const QVector<WAVE_DATA>& waveSpeedData)
|
|
|
|
|
|
{
|
|
|
|
|
|
qDebug() << "=====AddPolarPlotSeries=====" <<endl;
|
|
|
|
|
|
foreach (auto ID, listChannelID){
|
|
|
|
|
|
if(ID != strID){
|
|
|
|
|
|
m_mapChannelIDtoLabel[ID]->setCheckState(Qt::Unchecked);
|
|
|
|
|
|
m_mapChannelIDtoLabel[ID]->setSelected(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->plotLayout()->clear();
|
|
|
|
|
|
|
|
|
|
|
|
QVector<double> vecMeanRPM;
|
|
|
|
|
|
QVector<double> ValueAmp;
|
|
|
|
|
|
QVector<double> keyPhase;
|
|
|
|
|
|
qDebug() << "=====waveSpeedData time=====" <<waveSpeedData[0].Time<< endl;
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < waveSpeedData[0].Time;i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
QVector<double> vecTemp;
|
|
|
|
|
|
QVector<int> vecSpeedTime;
|
|
|
|
|
|
int flag = 0;
|
|
|
|
|
|
for(int j = 1; j < waveSpeedData.at(i).waveData.size();j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(waveSpeedData.at(0).iTrigger == 0){
|
|
|
|
|
|
if(waveSpeedData.at(i).waveData[j-1] > waveSpeedData.at(0).iTriggerValue && flag == 0){
|
|
|
|
|
|
|
|
|
|
|
|
flag = 1;
|
|
|
|
|
|
}else if(waveSpeedData.at(i).waveData[j-1] < (waveSpeedData.at(0).iTriggerValue-waveSpeedData.at(0).iHysteresis) && flag == 1){
|
|
|
|
|
|
|
|
|
|
|
|
flag = 0;
|
|
|
|
|
|
vecSpeedTime.push_back(j + (waveSpeedData[0].SamleRate * i));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QVector<RPM> vecSpeed;
|
|
|
|
|
|
double SumRPM = 0.0;
|
|
|
|
|
|
for(int j = 1;j < vecSpeedTime.size();j++){
|
|
|
|
|
|
float Speed = float((vecSpeedTime[j]-vecSpeedTime[j-1])/(float)waveSpeedData[0].SamleRate);
|
|
|
|
|
|
Speed = (1/Speed * 60)/waveSpeedData[0].iKeyCount;//键齿数
|
|
|
|
|
|
|
|
|
|
|
|
/*QCPGraphData data;
|
|
|
|
|
|
data.key = j-1;
|
|
|
|
|
|
data.value = Speed;
|
|
|
|
|
|
vecmainGraph1.push_back(data);*/
|
|
|
|
|
|
|
|
|
|
|
|
RPM rpmData;
|
|
|
|
|
|
rpmData.key1 = vecSpeedTime[j-1];
|
|
|
|
|
|
rpmData.key2 = vecSpeedTime[j];
|
|
|
|
|
|
rpmData.fSpeed = Speed;
|
|
|
|
|
|
vecSpeed.push_back(rpmData);
|
|
|
|
|
|
SumRPM += Speed;
|
|
|
|
|
|
qDebug() << "=====Speed=====" << Speed << vecSpeedTime.at(j) << vecSpeedTime.at(j-1) << endl;
|
|
|
|
|
|
}
|
|
|
|
|
|
double MeanRPM = SumRPM/(double)vecSpeed.size();
|
|
|
|
|
|
vecMeanRPM.push_back(MeanRPM);
|
|
|
|
|
|
}
|
|
|
|
|
|
qDebug() << "=====vecMeanRPM=====" <<vecMeanRPM.size()<< endl;
|
|
|
|
|
|
|
|
|
|
|
|
//1倍频(a) = 平均转速/60
|
|
|
|
|
|
//滤波范围 = (a - a*0.5),(a+a*0.5)
|
|
|
|
|
|
for(int k = 0;k < vecMeanRPM.size();k++){
|
|
|
|
|
|
QVector<double> vecEnvSpecData;
|
|
|
|
|
|
QVector<double> vecData;
|
|
|
|
|
|
|
|
|
|
|
|
double hz = (double)vecMeanRPM[k]/(double)60;
|
|
|
|
|
|
|
|
|
|
|
|
for(int j = 0; j < wavexData[k].SamleRate;j++){
|
|
|
|
|
|
|
|
|
|
|
|
float fData = wavexData[k].waveData.at(j)-wavexData[k].mean;
|
|
|
|
|
|
vecData.push_back(fData);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int start = hz-hz*0.05;
|
|
|
|
|
|
int end = hz+hz*0.05;
|
|
|
|
|
|
|
|
|
|
|
|
pCalculation->envSpec(vecData,vecEnvSpecData,start,end,true);
|
|
|
|
|
|
|
|
|
|
|
|
double Sum = 0.0;
|
|
|
|
|
|
double DataSum = std::accumulate(std::begin(vecEnvSpecData), std::end(vecEnvSpecData), 0.0);
|
|
|
|
|
|
double Datamean = DataSum/(double)vecEnvSpecData.size();
|
|
|
|
|
|
for(int j = 0; j < vecEnvSpecData.size();j++){
|
|
|
|
|
|
double fData = vecEnvSpecData.at(j) - Datamean;
|
|
|
|
|
|
fData = fData*fData;
|
|
|
|
|
|
Sum += fData;
|
|
|
|
|
|
}
|
|
|
|
|
|
double rms = sqrt(Sum/(double)vecEnvSpecData.size()); //加速度有效值
|
|
|
|
|
|
|
|
|
|
|
|
QVector<double> vecFFTrealData,vecFFTimageData;
|
|
|
|
|
|
QVector<double> vecData1;
|
|
|
|
|
|
for(int i = 0; i < wavexData[k].SamleRate;i++){
|
|
|
|
|
|
vecData1.push_back(wavexData[k].waveData[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
pCalculation->_FFT(vecData1,vecFFTrealData,vecFFTimageData);
|
|
|
|
|
|
|
|
|
|
|
|
double real = vecFFTrealData[(int)hz];
|
|
|
|
|
|
double image = vecFFTimageData[(int)hz];
|
|
|
|
|
|
|
|
|
|
|
|
double phase = atan2(image,real)*180/3.14;
|
|
|
|
|
|
ValueAmp.push_back(rms);
|
|
|
|
|
|
keyPhase.push_back(phase);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QCPPolarAxisAngular *angularAxis = new QCPPolarAxisAngular(ui->widget);
|
|
|
|
|
|
ui->widget->plotLayout()->addElement(0, 0, angularAxis);
|
|
|
|
|
|
/* This is how we could set the angular axis to show pi symbols instead of degree numbers:
|
|
|
|
|
|
QSharedPointer<QCPAxisTickerPi> ticker(new QCPAxisTickerPi);
|
|
|
|
|
|
ticker->setPiValue(180);
|
|
|
|
|
|
ticker->setTickCount(8);
|
|
|
|
|
|
polarAxis->setTicker(ticker);
|
|
|
|
|
|
*/
|
|
|
|
|
|
ui->widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
|
|
|
|
|
|
angularAxis->setRangeDrag(false);
|
|
|
|
|
|
angularAxis->setTickLabelMode(QCPPolarAxisAngular::lmUpright);
|
|
|
|
|
|
|
|
|
|
|
|
// angularAxis->radialAxis()->setTickLabelMode(QCPPolarAxisRadial::lmUpright);
|
|
|
|
|
|
// angularAxis->radialAxis()->setTickLabelRotation(0);
|
|
|
|
|
|
// angularAxis->radialAxis()->setAngle(45);
|
|
|
|
|
|
|
|
|
|
|
|
// angularAxis->grid()->setAngularPen(QPen(QColor(200, 200, 200), 0, Qt::SolidLine));
|
|
|
|
|
|
// angularAxis->grid()->setSubGridType(QCPPolarGrid::gtAll);
|
|
|
|
|
|
|
|
|
|
|
|
QCPPolarGraph *g1 = new QCPPolarGraph(angularAxis, angularAxis->radialAxis());
|
|
|
|
|
|
// QCPPolarGraph *g2 = new QCPPolarGraph(angularAxis, angularAxis->radialAxis());
|
|
|
|
|
|
// g2->setPen(QPen(QColor(255, 150, 20)));
|
|
|
|
|
|
// g2->setBrush(QColor(255, 150, 20, 50));
|
|
|
|
|
|
// g1->setScatterStyle(QCPScatterStyle::ssDisc);
|
|
|
|
|
|
// for (int i=0; i<100; ++i)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// g1->addData(i/100.0*360.0, qSin(i/100.0*M_PI*8)*8+1);
|
|
|
|
|
|
// g2->addData(i/100.0*360.0, qSin(i/100.0*M_PI*6)*2);
|
|
|
|
|
|
// }
|
|
|
|
|
|
QPen pen;
|
|
|
|
|
|
pen.setColor(wavexData.at(0).linColor);
|
|
|
|
|
|
pen.setStyle(Qt::SolidLine);
|
|
|
|
|
|
|
|
|
|
|
|
pen.setWidth(2);
|
|
|
|
|
|
g1->setPen(pen);
|
|
|
|
|
|
g1->addData(keyPhase,ValueAmp);
|
|
|
|
|
|
angularAxis->setRange(0, 360);
|
|
|
|
|
|
angularAxis->radialAxis()->setRange(-10, 10);
|
|
|
|
|
|
//坐标轴为白色
|
|
|
|
|
|
angularAxis->setBasePen(QPen(Qt::white, 1));
|
|
|
|
|
|
|
|
|
|
|
|
//坐标轴的提示信息为白色
|
|
|
|
|
|
angularAxis->setTickLabelColor(Qt::white);
|
|
|
|
|
|
|
|
|
|
|
|
angularAxis->setLabelColor(Qt::white);
|
|
|
|
|
|
angularAxis->radialAxis()->setLabelColor(Qt::white);
|
|
|
|
|
|
angularAxis->radialAxis()->setTickLabelColor(Qt::white);
|
|
|
|
|
|
|
|
|
|
|
|
g1->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, QPen(Qt::red, 1.5), QBrush(Qt::red), 3));//散列点
|
|
|
|
|
|
ui->widget->replot();
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::ChannelBtnSlot()
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->ChannelWgt->setVisible(!ui->ChannelWgt->isVisible());
|
|
|
|
|
|
QString strStyle;
|
|
|
|
|
|
if(ui->ChannelWgt->isVisible())
|
|
|
|
|
|
{
|
|
|
|
|
|
strStyle = "#ChannelBtn{border-image:url(:/images/images/hideChannel.png);}";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
strStyle = "#ChannelBtn{border-image:url(:/images/images/showChannel.png);}";
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->ChannelBtn->setStyleSheet(strStyle);
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::ClearTable()
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < ui->tableWidget->rowCount(); ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
QTableWidgetItem *pItem = ui->tableWidget->itemAt(i, 0);
|
|
|
|
|
|
QTableWidgetItem *pItem1 = ui->tableWidget->itemAt(i, 1);
|
|
|
|
|
|
|
|
|
|
|
|
if(pItem) delete pItem;
|
|
|
|
|
|
if(pItem1) delete pItem1;
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->tableWidget->clearContents();
|
|
|
|
|
|
ui->tableWidget->setRowCount(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::ClearAllSerise()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!m_pChart)
|
|
|
|
|
|
return;
|
|
|
|
|
|
m_pChart->removeAllSeries();
|
|
|
|
|
|
qDebug()<<"ChildForm::ClearAllSerise()" << m_pChart->axes().size();
|
|
|
|
|
|
|
|
|
|
|
|
while (m_pChart->axes().size())
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pChart->removeAxis(m_pChart->axes().at(0));
|
|
|
|
|
|
}
|
|
|
|
|
|
QValueAxis *axisX = new QValueAxis;
|
|
|
|
|
|
axisX->setLinePenColor(Qt::gray);
|
|
|
|
|
|
m_pChart->addAxis(axisX, Qt::AlignBottom);
|
|
|
|
|
|
|
|
|
|
|
|
QValueAxis *axisY = new QValueAxis;
|
|
|
|
|
|
axisY->setLinePenColor(Qt::gray);
|
|
|
|
|
|
m_pChart->addAxis(axisX, Qt::AlignLeft);
|
|
|
|
|
|
|
|
|
|
|
|
m_bAttach = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
QTableWidgetItem * ChildForm::AddTableWgtItem(QString strText, QString clolor, QString strID)
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1);
|
|
|
|
|
|
ui->tableWidget->setColumnWidth(0, 226);
|
|
|
|
|
|
ui->tableWidget->setColumnWidth(1, 20);
|
|
|
|
|
|
QTableWidgetItem *pItemName = new QTableWidgetItem();
|
|
|
|
|
|
pItemName->setText(strText);
|
|
|
|
|
|
pItemName->setCheckState(Qt::Unchecked);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QWidget *pWgt = new QWidget;
|
|
|
|
|
|
QVBoxLayout *pLayout = new QVBoxLayout(pWgt);
|
|
|
|
|
|
QLabel *pLabel = new QLabel(ui->tableWidget);
|
|
|
|
|
|
pLabel->setFixedSize(20, 20);
|
|
|
|
|
|
pLabel->setStyleSheet(QString("QLabel{background: rgb(%1)}").arg(clolor));
|
|
|
|
|
|
pLayout->addWidget(pLabel);
|
|
|
|
|
|
pLayout->setMargin(0); //设置边缘距离 否则会很难看
|
|
|
|
|
|
pLayout->setAlignment(pLabel, Qt::AlignCenter);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->tableWidget->setItem(ui->tableWidget->rowCount() - 1, 0, pItemName);
|
|
|
|
|
|
ui->tableWidget->setCellWidget(ui->tableWidget->rowCount() - 1, 1, pWgt);
|
|
|
|
|
|
|
|
|
|
|
|
m_mapChannelIDtoLabel[strID] = pItemName;
|
|
|
|
|
|
return pItemName;
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::SetDataIDs(const QStringList &strIDList, QString strTitle,const QStringList& strChannleTypeList,\
|
|
|
|
|
|
const QStringList& strChannleNameList)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_pLegendForm) m_pLegendForm->SetChannelIDs(strIDList);
|
|
|
|
|
|
|
|
|
|
|
|
ui->label_title->setText(strTitle);
|
|
|
|
|
|
disconnect(ui->tableWidget, SIGNAL(itemPressed(QTableWidgetItem *)), this, SLOT(ItemPressSlot(QTableWidgetItem *)));
|
|
|
|
|
|
disconnect(ui->tableWidget, SIGNAL(itemChanged(QTableWidgetItem *)), this, SLOT(ItemChangedSlot(QTableWidgetItem *)));
|
|
|
|
|
|
m_listChannelID = strIDList;
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
for(int j = 0; j < strIDList.size();j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
QString strNum1 = strIDList[j].right(2).left(1);
|
|
|
|
|
|
QString strNum2 = strIDList[j].right(1);
|
|
|
|
|
|
QString strChannleType = "";
|
|
|
|
|
|
if(strChannleTypeList[j] == "ACCELEROMETER")
|
|
|
|
|
|
{
|
|
|
|
|
|
strChannleType = "加速度";
|
|
|
|
|
|
}else if(strChannleTypeList[j] == "PROXIMETER"){
|
|
|
|
|
|
strChannleType = "径向位移";
|
|
|
|
|
|
}else if(strChannleTypeList[j] == "VELOCITY"){
|
|
|
|
|
|
strChannleType = "速度";
|
|
|
|
|
|
}else if(strChannleTypeList[j] == "SLOW_CURRENT"){
|
|
|
|
|
|
strChannleType = "电流";
|
|
|
|
|
|
}else if(strChannleTypeList[j] == "THRUST"){
|
|
|
|
|
|
strChannleType = "轴向位移";
|
|
|
|
|
|
}else if(strChannleTypeList[j] == "TACHOMETER"){
|
|
|
|
|
|
strChannleType = "转速";
|
|
|
|
|
|
}else if(strChannleTypeList[j] == "MICROPHONE"){
|
|
|
|
|
|
strChannleType = "声音";
|
|
|
|
|
|
}else if(strChannleTypeList[j] == "FAST_VOLTAGE"){
|
|
|
|
|
|
strChannleType = "动态电压";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString strText = QStringLiteral("%1-%2%3 (%4)").arg(strChannleNameList[j]).arg(strNum1).arg(strNum2).arg(strChannleType);
|
|
|
|
|
|
//QString strText = QStringLiteral("%1").arg(strChannleType[j]);
|
|
|
|
|
|
QString strColor = "0,255,0";
|
|
|
|
|
|
switch(i){
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
strColor = "0,255,0";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
strColor = "30,144,255";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
strColor = "255,182,193";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
strColor = "0, 255, 255";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
strColor = "255, 0, 255";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 5:
|
|
|
|
|
|
strColor = "255, 255, 0";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 6:
|
|
|
|
|
|
strColor = "255,69,0";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 7:
|
|
|
|
|
|
strColor = "0, 255, 127";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 8:
|
|
|
|
|
|
strColor = "255,140,0";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 9:
|
|
|
|
|
|
strColor = "0, 191, 255";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 10:
|
|
|
|
|
|
strColor = "139, 0, 139";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 11:
|
|
|
|
|
|
strColor = "211, 211, 211";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 12:
|
|
|
|
|
|
strColor = "205, 205, 0";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 13:
|
|
|
|
|
|
strColor = "198, 226, 255";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 14:
|
|
|
|
|
|
strColor = "255, 218, 185";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 15:
|
|
|
|
|
|
strColor = "255, 20, 147";
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
i++;
|
|
|
|
|
|
QTableWidgetItem *pItem = AddTableWgtItem(strText, strColor, strIDList[j]);
|
|
|
|
|
|
pItem->setData(CHANNELID_ROLE, strIDList[j]);
|
|
|
|
|
|
pItem->setData(CHANNELTYPE_ROLE, strChannleTypeList[j]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
connect(ui->tableWidget, SIGNAL(itemPressed(QTableWidgetItem *)), this, SLOT(ItemPressSlot(QTableWidgetItem *)));
|
|
|
|
|
|
connect(ui->tableWidget, SIGNAL(itemChanged(QTableWidgetItem *)), this, SLOT(ItemChangedSlot(QTableWidgetItem *)));
|
|
|
|
|
|
m_mapChannelIDtoLabel[strIDList[0]]->setSelected(true);
|
|
|
|
|
|
m_mapChannelIDtoLabel[strIDList[0]]->setCheckState(Qt::Checked);
|
|
|
|
|
|
|
|
|
|
|
|
listChannelID.push_back(strIDList[0]);
|
|
|
|
|
|
emit ItemCheckStateSignal(strIDList[0], true);
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::RemoveSeries(QString strID)
|
|
|
|
|
|
{
|
|
|
|
|
|
qDebug()<<"::ChildForm::RemoveSeries" <<strID;
|
|
|
|
|
|
qDebug()<<"::ChildForm::waveGraph" <<waveGraph.count();
|
|
|
|
|
|
|
|
|
|
|
|
m_isStop = true;
|
2022-08-02 10:19:41 +08:00
|
|
|
|
InitIntegration();
|
2022-07-30 11:50:01 +08:00
|
|
|
|
InitRpmDisPaly();
|
|
|
|
|
|
if(m_iFormType == WaterFallPlot || m_iFormType == ShaftCenterline || m_iFormType == OrbitPlot || m_iFormType == PolarPlot){//瀑布图
|
|
|
|
|
|
|
|
|
|
|
|
foreach (auto ID, listChannelID){
|
|
|
|
|
|
if(ID != strID){
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->clearGraphs();
|
|
|
|
|
|
ui->widget->clearPlottables();
|
|
|
|
|
|
qDebug() << ui->widget->graphCount() << endl;
|
|
|
|
|
|
line = 0;
|
|
|
|
|
|
}else if(m_iFormType == TrendChartPlot || m_iFormType == TimeDomainPlot || m_iFormType == FrequencyDomainPlot || m_iFormType == EnvChartPlot){
|
|
|
|
|
|
QMap<QString,QMap<QString,QCPAxis*>>::Iterator itermultiGraph = mapMultiGraph.begin();
|
|
|
|
|
|
|
|
|
|
|
|
for(;itermultiGraph != mapMultiGraph.end();itermultiGraph++){
|
|
|
|
|
|
int flag = 0;
|
|
|
|
|
|
QMap<QString,QCPAxis*>::Iterator iterGraph = itermultiGraph.value().begin();
|
|
|
|
|
|
for(;iterGraph != itermultiGraph.value().end();iterGraph++){
|
|
|
|
|
|
if(iterGraph.key() == strID){
|
|
|
|
|
|
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(strID == iter.key()){
|
|
|
|
|
|
qDebug() << strID << endl;
|
|
|
|
|
|
ui->widget->removeGraph(iter.value());
|
|
|
|
|
|
line --;
|
|
|
|
|
|
qDebug() << "line" << line << endl;
|
|
|
|
|
|
int graphCount = ui->widget->graphCount();
|
|
|
|
|
|
qDebug() << "graphCount" << graphCount<< endl;
|
|
|
|
|
|
|
|
|
|
|
|
QMap<QString,WAVE_DISPALYDATA>::Iterator iter1 = mapWaveDisplayData.begin();
|
|
|
|
|
|
for(iter1 = mapWaveDisplayData.begin();iter1 != mapWaveDisplayData.end();iter1++){
|
|
|
|
|
|
if(strID == iter1.key())
|
|
|
|
|
|
mapWaveDisplayData.erase(iter1);
|
|
|
|
|
|
if(mapWaveDisplayData.size() == 0)
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
waveGraph.erase(iter);
|
|
|
|
|
|
if(m_bRealTime){
|
|
|
|
|
|
QString topicPub = QString("up/%1/recive/waveserver").arg(m_DeviceInfo->DeviceMac);//推送
|
|
|
|
|
|
QJsonArray channel_Arr;
|
|
|
|
|
|
QJsonObject root_Obj;
|
|
|
|
|
|
QJsonObject item_Obj;
|
|
|
|
|
|
item_Obj.insert("channelId",strID);
|
|
|
|
|
|
item_Obj.insert("flag",1);
|
|
|
|
|
|
channel_Arr.insert(0,item_Obj);
|
|
|
|
|
|
root_Obj.insert("type","STOP");
|
|
|
|
|
|
root_Obj.insert("channelArray",channel_Arr);
|
|
|
|
|
|
QJsonDocument root_Doc;
|
|
|
|
|
|
root_Doc.setObject(root_Obj);
|
|
|
|
|
|
QByteArray root_str = root_Doc.toJson(QJsonDocument::Compact);
|
|
|
|
|
|
QString strJson(root_str);
|
|
|
|
|
|
qDebug() << strJson << endl;
|
|
|
|
|
|
QMQTT::Message message(136,topicPub,strJson.toUtf8());
|
|
|
|
|
|
mqttclient->Push(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(waveGraph.size() == 0){
|
|
|
|
|
|
m_bRealTime = false;
|
|
|
|
|
|
ui->realTimeDataBtn->setChecked(false);
|
|
|
|
|
|
EnableBtn();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
|
|
|
|
QMap<QString,QCPGraph*>::Iterator iter = waveGraph.begin();
|
|
|
|
|
|
for(iter = waveGraph.begin();iter != waveGraph.end();iter++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(strID == iter.key()){
|
|
|
|
|
|
qDebug() << strID << endl;
|
|
|
|
|
|
ui->widget->removeGraph(iter.value());
|
|
|
|
|
|
line --;
|
|
|
|
|
|
int graphCount = ui->widget->graphCount();
|
|
|
|
|
|
qDebug() << "graphCount" << graphCount<< endl;
|
|
|
|
|
|
|
|
|
|
|
|
QMap<QString,WAVE_DISPALYDATA>::Iterator iter1 = mapWaveDisplayData.begin();
|
|
|
|
|
|
for(iter1 = mapWaveDisplayData.begin();iter1 != mapWaveDisplayData.end();iter1++){
|
|
|
|
|
|
if(strID == iter1.key())
|
|
|
|
|
|
mapWaveDisplayData.erase(iter1);
|
|
|
|
|
|
}
|
|
|
|
|
|
waveGraph.erase(iter);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
QMap<QString,QVector<WAVE_DATA>>::Iterator iter1 = mapBodeData.begin();
|
|
|
|
|
|
for (;iter1 != mapBodeData.end() ; iter1++) {
|
|
|
|
|
|
if(strID == iter1.key()){
|
|
|
|
|
|
QVector<WAVE_DATA>().swap(iter1.value());
|
|
|
|
|
|
mapBodeData.erase(iter1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(m_bIntegration)
|
|
|
|
|
|
m_bIntegration = false;
|
|
|
|
|
|
|
|
|
|
|
|
if(m_bDifferentiation)
|
|
|
|
|
|
m_bDifferentiation = false;
|
|
|
|
|
|
|
|
|
|
|
|
if(m_bRpm)
|
|
|
|
|
|
m_bRpm = false;
|
|
|
|
|
|
|
|
|
|
|
|
ui->widget->replot();
|
|
|
|
|
|
|
|
|
|
|
|
if(tracerLabel->visible())
|
|
|
|
|
|
tracerLabel->setVisible(false);
|
|
|
|
|
|
if(tracerLabel2->visible())
|
|
|
|
|
|
tracerLabel2->setVisible(false);
|
|
|
|
|
|
if(tracerLabel3->visible())
|
|
|
|
|
|
tracerLabel3->setVisible(false);
|
|
|
|
|
|
if(tracerLabel4->visible())
|
|
|
|
|
|
tracerLabel4->setVisible(false);
|
|
|
|
|
|
if(tracerLabel5->visible())
|
|
|
|
|
|
tracerLabel5->setVisible(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//disconnect(dismove);
|
|
|
|
|
|
disconnect(disPress);
|
|
|
|
|
|
ZoomBtnSlot_XY();
|
|
|
|
|
|
UpdateDiffMenu();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::ItemPressSlot(QTableWidgetItem *item)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_bRealTime){
|
|
|
|
|
|
realTimeData();
|
|
|
|
|
|
MyMsgBox(QMessageBox::Information,"提示","请先暂停实时数据播放!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!item) return;
|
|
|
|
|
|
if(item->column() != 0) return;
|
|
|
|
|
|
|
|
|
|
|
|
QString strID = item->data(CHANNELID_ROLE).toString();
|
|
|
|
|
|
if(item->isSelected() && !item->checkState())
|
|
|
|
|
|
{
|
|
|
|
|
|
if(ui->widget->graphCount() == 3){
|
|
|
|
|
|
|
|
|
|
|
|
item->setCheckState(Qt::Unchecked);
|
|
|
|
|
|
item->setSelected(false);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
item->setCheckState(Qt::Checked);
|
|
|
|
|
|
emit ItemCheckStateSignal(strID, true);
|
|
|
|
|
|
listChannelID.push_back(strID);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(item->checkState() && !item->isSelected())
|
|
|
|
|
|
{
|
|
|
|
|
|
item->setCheckState(Qt::Unchecked);
|
|
|
|
|
|
emit ItemCheckStateSignal(strID, false);
|
|
|
|
|
|
listChannelID.removeOne(strID);
|
|
|
|
|
|
RemoveSeries(strID);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::ItemChangedSlot(QTableWidgetItem *item)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_bRealTime){
|
|
|
|
|
|
realTimeData();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!item) return;
|
|
|
|
|
|
if(item->column() != 0) return;
|
|
|
|
|
|
|
|
|
|
|
|
QString strID = item->data(CHANNELID_ROLE).toString();
|
|
|
|
|
|
QString strType = item->data(CHANNELTYPE_ROLE).toString();
|
|
|
|
|
|
if(item->checkState() && !item->isSelected())
|
|
|
|
|
|
{
|
|
|
|
|
|
if(ui->widget->graphCount() == 3 && m_iFormType != OrbitPlot){
|
|
|
|
|
|
MyMsgBox(QMessageBox::Information,"提示","最大支持三条曲线");
|
|
|
|
|
|
item->setCheckState(Qt::Unchecked);
|
|
|
|
|
|
item->setSelected(false);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
item->setCheckState(Qt::Checked);
|
|
|
|
|
|
item->setSelected(true);
|
|
|
|
|
|
emit ItemCheckStateSignal(strID, true);
|
|
|
|
|
|
listChannelID.push_back(strID);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(!item->checkState() && item->isSelected())
|
|
|
|
|
|
{
|
|
|
|
|
|
item->setCheckState(Qt::Unchecked);
|
|
|
|
|
|
item->setSelected(false);
|
|
|
|
|
|
emit ItemCheckStateSignal(strID, false);
|
|
|
|
|
|
listChannelID.removeOne(strID);
|
|
|
|
|
|
RemoveSeries(strID);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::mouseMoveEvent(QMouseEvent *event)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
//将像素点转换成qcustomplot中的坐标值,并通过setGraphKey将锚点值设为真实数据值。tracer->setGraphKey(xAxis->pixelToCoord(event->pos().x()));
|
|
|
|
|
|
int graphCount = ui->widget->graphCount();
|
|
|
|
|
|
if(graphCount < 1)
|
|
|
|
|
|
return;
|
|
|
|
|
|
//获得鼠标位置处对应的横坐标数据x
|
|
|
|
|
|
double x = 0.0;
|
|
|
|
|
|
if(m_iFormType == BodePlot){
|
|
|
|
|
|
|
|
|
|
|
|
x = ui->widget->axisRect(1)->axis(QCPAxis::atBottom,0)->pixelToCoord(event->pos().x());
|
|
|
|
|
|
//遍历曲线
|
|
|
|
|
|
//for (int i = 0; i < graphCount; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
//显示锚点
|
|
|
|
|
|
QCPGraph *mGraph = ui->widget->graph(0);
|
|
|
|
|
|
tracer->setVisible(true);
|
|
|
|
|
|
tracerLabel->setVisible(true);
|
|
|
|
|
|
tracerLabel->setPositionAlignment(Qt::AlignLeft);
|
|
|
|
|
|
tracerLabel->position->setType(QCPItemPosition::ptAxisRectRatio);//位置类型(当前轴范围的比例为单位/实际坐标为单位)
|
|
|
|
|
|
tracerLabel->position->setCoords(0, 0);
|
|
|
|
|
|
tracer->setGraph(mGraph);//将锚点设置到被选中的曲线上
|
|
|
|
|
|
{
|
|
|
|
|
|
tracer->setGraphKey(x);
|
|
|
|
|
|
//tracer->setInterpolating(true); //游标的纵坐标可以通过曲线数据线性插值自动获得
|
|
|
|
|
|
tracer->updatePosition(); //使得刚设置游标的横纵坐标位置生效
|
|
|
|
|
|
|
|
|
|
|
|
double y = ui->widget->axisRect(0)->axis(QCPAxis::atLeft)->pixelToCoord(event->pos().y());
|
|
|
|
|
|
|
|
|
|
|
|
double xValue = tracer->position->key();
|
|
|
|
|
|
double yValue = y;
|
|
|
|
|
|
//显示tip框
|
|
|
|
|
|
QCPDataContainer<QCPGraphData>::const_iterator coorPoint = ui->widget->graph(0)->data().data()->findBegin(x, true);//true代表向左搜索
|
|
|
|
|
|
tracer->setGraphKey(coorPoint->key);
|
|
|
|
|
|
//tracer->setInterpolating(true); //游标的纵坐标可以通过曲线数据线性插值自动获得
|
|
|
|
|
|
tracer->updatePosition(); //使得刚设置游标的横纵坐标位置生效
|
|
|
|
|
|
|
|
|
|
|
|
tracerLabel->setText(QString("%1 X: %2 Y: %3").arg(mGraph->name()).arg( QString::number(x)).arg(QString::number(yValue)));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//显示锚点
|
|
|
|
|
|
QCPGraph *mGraph2 = ui->widget->graph(1);
|
|
|
|
|
|
tracerLabel3->setVisible(true);
|
|
|
|
|
|
tracerLabel3->setPositionAlignment(Qt::AlignVCenter);
|
|
|
|
|
|
tracerLabel3->position->setType(QCPItemPosition::ptAxisRectRatio);//位置类型(当前轴范围的比例为单位/实际坐标为单位)
|
|
|
|
|
|
tracerLabel3->position->setCoords(10, 20);
|
|
|
|
|
|
tracer->setGraph(mGraph2);//将锚点设置到被选中的曲线上
|
|
|
|
|
|
{
|
|
|
|
|
|
tracer->setGraphKey(x);
|
|
|
|
|
|
//tracer->setInterpolating(true); //游标的纵坐标可以通过曲线数据线性插值自动获得
|
|
|
|
|
|
tracer->updatePosition(); //使得刚设置游标的横纵坐标位置生效
|
|
|
|
|
|
|
|
|
|
|
|
double y2 = ui->widget->axisRect(1)->axis(QCPAxis::atLeft)->pixelToCoord(event->pos().y());
|
|
|
|
|
|
|
|
|
|
|
|
double xValue = tracer->position->key();
|
|
|
|
|
|
double yValue2 = y2;
|
|
|
|
|
|
//显示tip框
|
|
|
|
|
|
QCPDataContainer<QCPGraphData>::const_iterator coorPoint = ui->widget->graph(1)->data().data()->findBegin(x, true);//true代表向左搜索
|
|
|
|
|
|
tracer->setGraphKey(coorPoint->key);
|
|
|
|
|
|
//tracer->setInterpolating(true); //游标的纵坐标可以通过曲线数据线性插值自动获得
|
|
|
|
|
|
tracer->updatePosition(); //使得刚设置游标的横纵坐标位置生效
|
|
|
|
|
|
|
|
|
|
|
|
tracerLabel3->setText(QString("%1 X: %2 Y: %3").arg(mGraph2->name()).arg( QString::number(x)).arg(QString::number(yValue2)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
x = ui->widget->xAxis->pixelToCoord(event->pos().x());
|
|
|
|
|
|
|
|
|
|
|
|
//遍历曲线
|
|
|
|
|
|
for (int i = 0; i < graphCount; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
//显示锚点
|
|
|
|
|
|
QCPGraph *mGraph = ui->widget->graph(i);
|
|
|
|
|
|
tracer->setVisible(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tracer->setGraph(mGraph);//将锚点设置到被选中的曲线上
|
|
|
|
|
|
tracer->setGraphKey(x); //将游标横坐标设置成刚获得的横坐标数据x
|
|
|
|
|
|
//tracer->setInterpolating(true); //游标的纵坐标可以通过曲线数据线性插值自动获得
|
|
|
|
|
|
tracer->updatePosition(); //使得刚设置游标的横纵坐标位置生效
|
|
|
|
|
|
double xValue = tracer->position->key();
|
|
|
|
|
|
double yValue = tracer->position->value();
|
|
|
|
|
|
if( i == 0){
|
|
|
|
|
|
tracerLabel->setVisible(true);
|
|
|
|
|
|
tracerLabel->setText(QString("%1 X: %2 Y: %3").arg(mGraph->name()).arg( QString::number(xValue)).arg(QString::number(yValue)));
|
|
|
|
|
|
}
|
|
|
|
|
|
else if( i == 1){
|
|
|
|
|
|
tracerLabel3->setVisible(true);
|
|
|
|
|
|
tracerLabel3->setText(QString("%1 X: %2 Y: %3").arg(mGraph->name()).arg( QString::number(xValue)).arg(QString::number(yValue)));
|
|
|
|
|
|
}else if( i == 2){
|
|
|
|
|
|
tracerLabel4->setVisible(true);
|
|
|
|
|
|
tracerLabel4->setText(QString("%1 X: %2 Y: %3").arg(mGraph->name()).arg( QString::number(xValue)).arg(QString::number(yValue)));
|
|
|
|
|
|
}else if( i == 3){
|
|
|
|
|
|
tracerLabel5->setVisible(true);
|
|
|
|
|
|
tracerLabel5->setText(QString("%1 X: %2 Y: %3").arg(mGraph->name()).arg( QString::number(xValue)).arg(QString::number(yValue)));
|
|
|
|
|
|
}
|
|
|
|
|
|
//显示tip框
|
|
|
|
|
|
QCPDataContainer<QCPGraphData>::const_iterator coorPoint = ui->widget->graph(i)->data().data()->findBegin(xValue, true);//true代表向左搜索
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//重绘
|
|
|
|
|
|
ui->widget->replot();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ChildForm::mouseDoubleClickEvent(QMouseEvent *event)
|
|
|
|
|
|
{
|
|
|
|
|
|
int graphCount = ui->widget->graphCount();
|
|
|
|
|
|
if(graphCount < 1)
|
|
|
|
|
|
return;
|
|
|
|
|
|
qDebug()<<"mouseDoubleClickEvent" << endl;
|
|
|
|
|
|
double x = ui->widget->xAxis->pixelToCoord(event->pos().x());
|
|
|
|
|
|
//遍历曲线
|
|
|
|
|
|
for (int i = 0; i < graphCount; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(ui->widget->graph(i)->selected()){
|
|
|
|
|
|
QCPGraph *mGraph = ui->widget->graph(i);
|
|
|
|
|
|
tracer2->setVisible(true);
|
|
|
|
|
|
tracerLabel2->setVisible(true);
|
|
|
|
|
|
mGraph = ui->widget->graph(i);
|
|
|
|
|
|
double x = ui->widget->xAxis->pixelToCoord(event->pos().x());
|
|
|
|
|
|
tracer2->setGraph(mGraph);//将锚点设置到被选中的曲线上
|
|
|
|
|
|
tracer2->setGraphKey(x); //将游标横坐标设置成刚获得的横坐标数据x
|
|
|
|
|
|
//tracer2->setInterpolating(true); //游标的纵坐标可以通过曲线数据线性插值自动获得
|
|
|
|
|
|
tracer2->updatePosition(); //使得刚设置游标的横纵坐标位置生效
|
|
|
|
|
|
tracerLabel2->position->setParentAnchor(tracer2->position);
|
|
|
|
|
|
double xValue = tracer2->position->key();
|
|
|
|
|
|
double yValue = tracer2->position->value();
|
|
|
|
|
|
//显示tip框
|
|
|
|
|
|
tracerLabel2->setText(QString("%1 \n X: %2 \n Y: %3").arg(mGraph->name()).arg( QString::number(xValue)).arg(QString::number(yValue)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::mouseWheelEvent(QWheelEvent *event)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
int graphCount = ui->widget->graphCount();
|
|
|
|
|
|
QCPRange range = ui->widget->xAxis->range();
|
|
|
|
|
|
//qDebug() << range.size() << endl;
|
|
|
|
|
|
for (int i = 0; i < graphCount; ++i){
|
|
|
|
|
|
switch (m_iFormType) {
|
|
|
|
|
|
case TimeDomainPlot:
|
|
|
|
|
|
if(range.size() < 0.01){
|
|
|
|
|
|
ui->widget->graph(i)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, QPen(Qt::red, 1.5), QBrush(Qt::red), 3));//散列点
|
|
|
|
|
|
}else if(range.size() > 0.01){
|
|
|
|
|
|
ui->widget->graph(i)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssNone, QPen(Qt::blue, 1.5), QBrush(Qt::blue), 3));//散列点
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case FrequencyDomainPlot:
|
|
|
|
|
|
case TrendChartPlot:
|
|
|
|
|
|
case EnvChartPlot:
|
|
|
|
|
|
if(range.size() < 100){
|
|
|
|
|
|
ui->widget->graph(i)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, QPen(Qt::red, 1.5), QBrush(Qt::red), 3));//散列点
|
|
|
|
|
|
}else if(range.size() > 100){
|
|
|
|
|
|
ui->widget->graph(i)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssNone, QPen(Qt::blue, 1.5), QBrush(Qt::blue), 3));//散列点
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->replot();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ChildForm::CalculateRPM()
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->widget->clearGraphs();
|
|
|
|
|
|
QMap<QString,QCPGraph*>().swap(waveGraph);
|
|
|
|
|
|
QMap<QString,WAVE_DISPALYDATA>::iterator iter = mapWaveDisplayData.begin();
|
|
|
|
|
|
for(; iter != mapWaveDisplayData.end();iter++){
|
|
|
|
|
|
if(iter.value().channelType == "TACHOMETER"){
|
|
|
|
|
|
|
|
|
|
|
|
QVector<WAVE_DISPALYDATA> vecWaveDisplay;
|
|
|
|
|
|
|
|
|
|
|
|
// QString filename = QString("e://Speed.csv");
|
|
|
|
|
|
// QFile file(filename);
|
|
|
|
|
|
// qDebug()<< "filename = "<<filename << endl;
|
|
|
|
|
|
// if (!file.open(QIODevice::WriteOnly))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// qDebug() << "::ToRpm cannot open file for read";
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// QTextStream out(&file); // 输入流
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QVector<int> vecSpeedTime;
|
|
|
|
|
|
int flag = 0;
|
|
|
|
|
|
qDebug() << "wavedata.size()" << iter.value().wavedata_DC.size();
|
|
|
|
|
|
for(int i = 0; i < iter.value().wavedata_DC.size();i++){
|
|
|
|
|
|
|
|
|
|
|
|
if(iter.value().iTrigger == 0){//上升沿
|
|
|
|
|
|
|
|
|
|
|
|
if((iter.value().wavedata_DC[i]) > iter.value().iTriggerValue && flag == 0){
|
|
|
|
|
|
|
|
|
|
|
|
flag = i;
|
|
|
|
|
|
|
|
|
|
|
|
}else if (iter.value().wavedata_DC[i] < (iter.value().iTriggerValue - iter.value().iHysteresis) && flag > 0){
|
|
|
|
|
|
|
|
|
|
|
|
vecSpeedTime.push_back(flag);
|
|
|
|
|
|
flag = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}/*else if(iter.value()[j].iTrigger == 1){//下降沿
|
|
|
|
|
|
if((iter.value()[j].waveData[i-1])> iter.value()[j].iTriggerValue &&\
|
|
|
|
|
|
(iter.value()[j].waveData[i]) < iter.value()[j].iTriggerValue && \
|
|
|
|
|
|
(iter.value()[j].waveData[i-1]) < (iter.value()[j].iTriggerValue + iter.value()[j].iHysteresis)){
|
|
|
|
|
|
|
|
|
|
|
|
vecSpeedTime.push_back(i);
|
|
|
|
|
|
}
|
|
|
|
|
|
}*/
|
|
|
|
|
|
}
|
|
|
|
|
|
WAVE_DISPALYDATA WaveDisplay;
|
|
|
|
|
|
qDebug() << "vecSpeedTime " << vecSpeedTime.size() << endl;
|
|
|
|
|
|
double sum = 0.0;
|
|
|
|
|
|
double gap = (double)1/(double)vecSpeedTime.size();
|
|
|
|
|
|
double key = 0.0;
|
|
|
|
|
|
for(int jj = 1;jj < vecSpeedTime.size();jj++){
|
|
|
|
|
|
//out << (float)vecSpeedTime[jj-1]/(float)SamleRate + j << ",";
|
|
|
|
|
|
//out << "\n";
|
|
|
|
|
|
float Speed = float((vecSpeedTime[jj]-vecSpeedTime[jj-1])/(float)iter.value().SamleRate);
|
|
|
|
|
|
Speed = (1/Speed * 60)/iter.value().iKeyCount;//键齿数 计算每分钟转速
|
|
|
|
|
|
key += gap;
|
|
|
|
|
|
WaveDisplay.Key.push_back(key);
|
|
|
|
|
|
WaveDisplay.wavedata.push_back(Speed);
|
|
|
|
|
|
sum += Speed;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WaveDisplay.meanRpm = sum/(double)WaveDisplay.wavedata.size();
|
|
|
|
|
|
WaveDisplay.linColor = iter.value().linColor;
|
|
|
|
|
|
WaveDisplay.channelType = iter.value().channelType;
|
|
|
|
|
|
WaveDisplay.sensorEngineeringUnit = iter.value().sensorEngineeringUnit;
|
|
|
|
|
|
WaveDisplay.SamleRate = iter.value().SamleRate;
|
|
|
|
|
|
|
|
|
|
|
|
//file.close();
|
|
|
|
|
|
mapWaveDisplayData_RPM.insert(iter.key(),WaveDisplay);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
qDebug() << " _RPM"<< mapWaveDisplayData_RPM.size() << endl;
|
|
|
|
|
|
QMap<QString,WAVE_DISPALYDATA>::Iterator iter1 = mapWaveDisplayData_RPM.begin();
|
|
|
|
|
|
for (int i = 0; i < listChannelID.size(); ++i){
|
|
|
|
|
|
for(iter1 = mapWaveDisplayData_RPM.begin();iter1 != mapWaveDisplayData_RPM.end();iter1++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(listChannelID.at(i) == iter1.key()){
|
|
|
|
|
|
QCPGraph* graph = ui->widget->addGraph();
|
|
|
|
|
|
ui->widget->graph(i)->setData(iter1.value().Key, iter1.value().wavedata);
|
|
|
|
|
|
ui->widget->graph(i)->rescaleValueAxis();
|
|
|
|
|
|
ui->widget->graph(i)->setName(iter1.key());
|
|
|
|
|
|
QPen pen;
|
|
|
|
|
|
pen.setColor(iter1.value().linColor);
|
|
|
|
|
|
pen.setStyle(Qt::SolidLine);
|
|
|
|
|
|
pen.setWidth(0);
|
|
|
|
|
|
ui->widget->graph(i)->setPen(pen);
|
|
|
|
|
|
ui->widget->replot(QCustomPlot::rpImmediateRefresh);
|
|
|
|
|
|
waveGraph.insert(iter1.key(),graph);
|
|
|
|
|
|
QString xAxis = "";
|
|
|
|
|
|
xAxis = QString("Time(s) 平均转速:%1").arg(iter1.value().meanRpm);
|
|
|
|
|
|
ui->widget->xAxis->setLabel(xAxis);
|
|
|
|
|
|
ui->widget->yAxis->setLabel(iter1.value().channelType + "(" + iter1.value().sensorEngineeringUnit+")");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->xAxis->setRange(0, 1, Qt::AlignLeft);
|
|
|
|
|
|
ui->widget->replot(QCustomPlot::rpImmediateRefresh);
|
|
|
|
|
|
ZoomBtnSlot_XY();
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::ToRpm()
|
|
|
|
|
|
{
|
|
|
|
|
|
/*if(global::rotatingSpeed.iTriggerValue == 0 ||\
|
|
|
|
|
|
global::rotatingSpeed.iKeyCount == 0 ||\
|
|
|
|
|
|
global::rotatingSpeed.iHysteresis == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
MyMsgBox(QMessageBox::Question,"警告","请先设置转速参数!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(listChannelID.size() > 1)
|
|
|
|
|
|
return;
|
|
|
|
|
|
qDebug() << global::rotatingSpeed.iTriggerValue << global::rotatingSpeed.iKeyCount \
|
|
|
|
|
|
<< global::rotatingSpeed.iHysteresis<< global::rotatingSpeed.iTrigger << endl;
|
|
|
|
|
|
ui->widget->clearGraphs();
|
|
|
|
|
|
QMap<QString,QCPGraph*>().swap(waveGraph);
|
|
|
|
|
|
if(m_bRpm){
|
|
|
|
|
|
m_bRpm = false;
|
|
|
|
|
|
handlePlayWave(m_position);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
m_bRpm = true;
|
|
|
|
|
|
// if(mapWaveDisplayData_RPM.size() == mapWaveDisplayData.size() && \
|
|
|
|
|
|
// mapWaveDisplayData_RPM.size() > 0 /*&& \
|
|
|
|
|
|
// _rotatingSpeed.iHysteresis == global::rotatingSpeed.iHysteresis && \
|
|
|
|
|
|
// _rotatingSpeed.iTriggerValue == global::rotatingSpeed.iTriggerValue && \
|
|
|
|
|
|
// _rotatingSpeed.iKeyCount == global::rotatingSpeed.iKeyCount && \
|
|
|
|
|
|
// _rotatingSpeed.iTrigger == global::rotatingSpeed.iTrigger*/ ){
|
|
|
|
|
|
// handlePlayWave(m_position);
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
CalculateRPM();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::ZoomBtnSlot_X()
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmNone);
|
|
|
|
|
|
int graphCount = ui->widget->graphCount();
|
|
|
|
|
|
// for(int i = 0; i < graphCount; i++){
|
|
|
|
|
|
// ui->widget->graph(i)->rescaleKeyAxis(true);
|
|
|
|
|
|
// }
|
|
|
|
|
|
if(graphCount > 0){
|
|
|
|
|
|
ui->widget->graph(0)->rescaleKeyAxis();
|
|
|
|
|
|
for(int i = 1; i < graphCount; i++){
|
|
|
|
|
|
ui->widget->graph(i)->rescaleKeyAxis(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ui->widget->replot();
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->replot();
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::ZoomBtnSlot_Y()
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmNone);
|
|
|
|
|
|
int graphCount = ui->widget->graphCount();
|
|
|
|
|
|
// for(int i = 0; i < graphCount; i++){
|
|
|
|
|
|
// ui->widget->graph(i)->rescaleValueAxis(true);
|
|
|
|
|
|
// }
|
|
|
|
|
|
if(graphCount > 0){
|
|
|
|
|
|
ui->widget->graph(0)->rescaleValueAxis();
|
|
|
|
|
|
for(int i = 1; i < graphCount; i++){
|
|
|
|
|
|
ui->widget->graph(i)->rescaleValueAxis(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ui->widget->replot();
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->replot();
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::ZoomBtnSlot_XY()
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmNone);
|
|
|
|
|
|
int graphCount = ui->widget->graphCount();
|
|
|
|
|
|
if(graphCount > 0){
|
|
|
|
|
|
ui->widget->graph(0)->rescaleValueAxis();
|
|
|
|
|
|
for(int i = 1; i < graphCount; i++){
|
|
|
|
|
|
ui->widget->graph(i)->rescaleValueAxis(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ui->widget->replot();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::ZoomBtnSlot_Hand()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ui->widget->setMultiSelectModifier(Qt::ControlModifier);// 使用ctrl键来多选
|
|
|
|
|
|
// ui->widget->xAxis->setSelectableParts(QCPAxis::spAxis | QCPAxis::spAxisLabel | QCPAxis::spTickLabels); // 轴的三个部分都可以被选择
|
|
|
|
|
|
// ui->widget->yAxis->setSelectableParts(QCPAxis::spAxis | QCPAxis::spAxisLabel | QCPAxis::spTickLabels);
|
|
|
|
|
|
|
|
|
|
|
|
// ui->widget->legend->setSelectableParts(QCPLegend::spItems);// 图例本身不能被选择,只有里面的项可以被选择
|
|
|
|
|
|
// ui->widget->legend->setSelectedIconBorderPen(Qt::NoPen);// 设置图例里的项被选择时不显示Icon的边框
|
|
|
|
|
|
|
|
|
|
|
|
// ui->widget->selectionRect()->setPen(QPen(Qt::black,1,Qt::DashLine));//设置选框的样式:虚线
|
|
|
|
|
|
// ui->widget->selectionRect()->setBrush(QBrush(QColor(0,0,100,50)));//设置选框的样式:半透明浅蓝
|
|
|
|
|
|
|
|
|
|
|
|
// ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmZoom);//被框选的曲线放大
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmNone);
|
|
|
|
|
|
if(ui->zoomBtn_hand->isChecked()){
|
|
|
|
|
|
//交互设置
|
|
|
|
|
|
ui->widget->setInteractions(QCP::iRangeDrag | QCP::iSelectAxes | QCP::iSelectLegend | QCP::iMultiSelect);
|
|
|
|
|
|
//ui->widget->setInteractions(QCP::iRangeDrag);
|
|
|
|
|
|
}else if(!ui->zoomBtn_hand->isChecked()){
|
|
|
|
|
|
ui->widget->setInteractions(QCP::iNone);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::Btn_ZoomSlot()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(ui->Btn_Zoom->isChecked()){
|
|
|
|
|
|
ui->widget->setInteractions(QCP::iRangeDrag);
|
|
|
|
|
|
ui->widget->axisRect()->setRangeZoomFactor(1.2,1.2);
|
|
|
|
|
|
}else if(!ui->Btn_Zoom->isChecked()){
|
|
|
|
|
|
ui->widget->setInteractions(QCP::iNone);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::ScalesX()
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmNone);
|
|
|
|
|
|
ui->widget->setInteractions(QCP::iRangeZoom|QCP::iRangeDrag);
|
|
|
|
|
|
ui->widget->axisRect()->setRangeZoomFactor(1.2,1);
|
|
|
|
|
|
|
|
|
|
|
|
ui->widget->axisRect()->setRangeZoomAxes(ui->widget->xAxis,ui->widget->yAxis);
|
|
|
|
|
|
}
|
|
|
|
|
|
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]);
|
|
|
|
|
|
}
|
|
|
|
|
|
//ui->widget->axisRect()->setRangeZoomAxes(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]);
|
|
|
|
|
|
}
|
|
|
|
|
|
//ui->widget->axisRect()->setRangeZoomAxes(ui->widget->xAxis,ui->widget->yAxis);
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::ScalesBox()
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmZoom);
|
|
|
|
|
|
ui->widget->selectionRect()->setPen(QPen(Qt::black,1,Qt::DashLine));//虚线
|
|
|
|
|
|
ui->widget->selectionRect()->setBrush(QBrush(QColor(255, 222, 173,50)));//NavajoWhite
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::Cursor()
|
|
|
|
|
|
{
|
|
|
|
|
|
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*)));
|
|
|
|
|
|
disPress = connect(ui->widget, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheelEvent(QWheelEvent*)));
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::SetScales()
|
|
|
|
|
|
{
|
|
|
|
|
|
pSetScales = new SetScalesForm(this); //将类指针实例化
|
|
|
|
|
|
connect(pSetScales, SIGNAL(sgSetScales(QString)), this, SLOT(slotSetScales(QString)));
|
|
|
|
|
|
pSetScales->setWindowModality(Qt::ApplicationModal);
|
|
|
|
|
|
pSetScales->show();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ui->widget->replot(QCustomPlot::rpImmediateRefresh);
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::slotSetFilter(QString str)
|
|
|
|
|
|
{
|
|
|
|
|
|
QStringList strList = str.split(",");
|
|
|
|
|
|
UpdateEnvSerises(strList[0],strList[1]);
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::SetFilter()
|
|
|
|
|
|
{
|
|
|
|
|
|
pSetFilter = new FilterForm(this); //将类指针实例化
|
|
|
|
|
|
connect(pSetFilter, SIGNAL(sgSetFilter(QString)), this, SLOT(slotSetFilter(QString)));
|
|
|
|
|
|
pSetFilter->setWindowModality(Qt::ApplicationModal);
|
|
|
|
|
|
pSetFilter->show();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ChildForm::RealTimeWave(QByteArray payLoad)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
WAVE_CONTAIN waveContain;
|
|
|
|
|
|
char *buf;
|
|
|
|
|
|
buf = payLoad.data();
|
|
|
|
|
|
qDebug() << "payLoad.len" << payLoad.length() << endl;
|
|
|
|
|
|
for(int i = 0; i < listChannelID.size();i++){
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(&waveContain,buf + (i*sizeof (WAVE_CONTAIN)),sizeof(WAVE_CONTAIN));
|
|
|
|
|
|
qDebug() << "channelId"<<waveContain.channelId << endl;
|
|
|
|
|
|
qDebug() << "total" <<waveContain.total << endl;
|
|
|
|
|
|
|
|
|
|
|
|
qDebug() << "number" << waveContain.number<< endl;
|
|
|
|
|
|
QVector<double> vecRealTimeWave;
|
|
|
|
|
|
|
|
|
|
|
|
// QString filename = QString("e://RealTime.csv");
|
|
|
|
|
|
// QFile file(filename);
|
|
|
|
|
|
// qDebug()<< "filename = "<<filename << endl;
|
|
|
|
|
|
// if (!file.open(QIODevice::WriteOnly))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// qDebug() << ":: cannot open file for read";
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// QTextStream out(&file); // 输入流
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < waveContain.number;i++){
|
|
|
|
|
|
float f;
|
|
|
|
|
|
memcpy(&f,&waveContain.waveData[i],4);
|
|
|
|
|
|
vecRealTimeWave.push_back(f);
|
|
|
|
|
|
// out << f;
|
|
|
|
|
|
// out << "\n";
|
|
|
|
|
|
//qDebug() << "f" << f << endl;
|
|
|
|
|
|
}
|
|
|
|
|
|
// file.close();
|
|
|
|
|
|
qDebug() << "vecRealTimeWave"<<vecRealTimeWave.size() << endl;
|
|
|
|
|
|
QMap<QString,QCPGraph*>::Iterator iter = waveGraph.begin();
|
|
|
|
|
|
for(;iter != waveGraph.end();iter++){
|
|
|
|
|
|
if(iter.key() == QString(waveContain.channelId)){
|
|
|
|
|
|
ui->widget->removeGraph(iter.value());
|
|
|
|
|
|
waveGraph.erase(iter);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QMap<QString,QVector<WAVE_DATA>>::Iterator iterWave = mapWaveData.begin();
|
|
|
|
|
|
for(;iterWave != mapWaveData.end();iterWave++){
|
|
|
|
|
|
if(iterWave.key() == QString(waveContain.channelId)){
|
|
|
|
|
|
iterWave.value()[m_position].waveDataRealTime = vecRealTimeWave;
|
|
|
|
|
|
iterWave.value()[m_position].SamleRateRealTime = waveContain.number;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QCPGraph* graph = NULL;
|
|
|
|
|
|
WAVE_DISPALYDATA waveShowData;
|
|
|
|
|
|
QMap<QString,QMap<QString,QCPAxis*>>::Iterator iterMultiAxis = mapMultiGraph.begin();
|
|
|
|
|
|
for(;iterMultiAxis != mapMultiGraph.end();iterMultiAxis++){
|
|
|
|
|
|
QMap<QString,QCPAxis*>::Iterator iterAxis = iterMultiAxis.value().begin();
|
|
|
|
|
|
for(;iterAxis != iterMultiAxis.value().end();iterAxis++){
|
|
|
|
|
|
if(iterAxis.key() == QString(waveContain.channelId)){
|
|
|
|
|
|
qDebug() << iterAxis.key() << endl;
|
|
|
|
|
|
SecondData(iterAxis.key(),iterWave.value()[m_position],waveShowData);
|
|
|
|
|
|
graph = ui->widget->addGraph(ui->widget->xAxis,iterAxis.value());
|
|
|
|
|
|
iterAxis.value()->setLabel(waveShowData.channelType + "(" + waveShowData.sensorEngineeringUnit+")");
|
|
|
|
|
|
if(m_iFormType == TimeDomainPlot){
|
|
|
|
|
|
//if(iterWave.value()[m_position].sensorType == "ACCELEROMETER" || iterWave.value()[m_position].sensorType == "MICROPHONE")
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_bDC)
|
|
|
|
|
|
graph->setData(waveShowData.Key, waveShowData.wavedata_DC);
|
|
|
|
|
|
else
|
|
|
|
|
|
graph->setData(waveShowData.Key, waveShowData.wavedata);
|
|
|
|
|
|
}
|
|
|
|
|
|
}else if(m_iFormType == FrequencyDomainPlot){
|
|
|
|
|
|
graph->setData(waveShowData.Key, waveShowData.wavedata);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-08-02 10:19:41 +08:00
|
|
|
|
QString strRMS = QString("Time(s) %1: %2 mm/s").arg( "RMS " ).arg(waveShowData.RMS);
|
|
|
|
|
|
|
|
|
|
|
|
if(m_bIntegration){
|
|
|
|
|
|
ui->widget->yAxis->setLabel("Velocity(mm/s)");
|
|
|
|
|
|
ui->widget->xAxis->setLabel(strRMS);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-07-30 11:50:01 +08:00
|
|
|
|
graph->rescaleValueAxis();
|
|
|
|
|
|
graph->setName(waveShowData.channleName);
|
|
|
|
|
|
QPen pen;
|
|
|
|
|
|
pen.setColor(waveShowData.linColor);
|
|
|
|
|
|
pen.setStyle(Qt::SolidLine);
|
|
|
|
|
|
pen.setWidth(0);
|
|
|
|
|
|
graph->setPen(pen);
|
|
|
|
|
|
if(m_iFormType == FrequencyDomainPlot || m_iFormType == EnvChartPlot){
|
|
|
|
|
|
ui->widget->xAxis->setRange(0, 1000);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
waveGraph.insert(QString(waveContain.channelId),graph);
|
|
|
|
|
|
ui->widget->replot(QCustomPlot::rpImmediateRefresh);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ChildForm::PlaySoundThread()
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->widget->clearGraphs();
|
|
|
|
|
|
PaStreamParameters outputParameters;
|
|
|
|
|
|
PaStream *stream;
|
|
|
|
|
|
PaError err;
|
|
|
|
|
|
QVector<float> f;
|
|
|
|
|
|
int SAMPLE_RATE = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// int NUM_SECONDS = 0;
|
|
|
|
|
|
// int FRAMES_PER_BUFFER = 1024;
|
|
|
|
|
|
int NUM_SECONDS = 0;
|
|
|
|
|
|
int bufferCount = 0;
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
int a,b;
|
|
|
|
|
|
float buffer[FRAMES_PER_BUFFER][2]; /* stereo output buffer */
|
|
|
|
|
|
err = Pa_Initialize();
|
|
|
|
|
|
if( err != paNoError ) goto error;
|
|
|
|
|
|
|
|
|
|
|
|
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
|
|
|
|
|
|
if (outputParameters.device == paNoDevice) {
|
|
|
|
|
|
fprintf(stderr,"Error: No default output device.\n");
|
|
|
|
|
|
goto error;
|
|
|
|
|
|
}
|
|
|
|
|
|
outputParameters.channelCount = 2; /* stereo output */
|
|
|
|
|
|
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
|
|
|
|
|
|
outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency; // Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
|
|
|
|
|
|
outputParameters.hostApiSpecificStreamInfo = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < listChannelID.size();i++){
|
|
|
|
|
|
QMap<QString,QVector<WAVE_DATA>>::Iterator iterWaveData = mapWaveData.begin();
|
|
|
|
|
|
for(;iterWaveData != mapWaveData.end();iterWaveData++){
|
|
|
|
|
|
if(listChannelID[i] == iterWaveData.key()){
|
|
|
|
|
|
SAMPLE_RATE = iterWaveData.value()[0].SamleRate;
|
|
|
|
|
|
NUM_SECONDS = iterWaveData.value().size();
|
|
|
|
|
|
for(int ii = 0; ii < iterWaveData.value().size();ii++){
|
|
|
|
|
|
for(int j = 0 ; j < iterWaveData.value()[ii].waveData.size(); j++){
|
|
|
|
|
|
|
|
|
|
|
|
f.push_back((iterWaveData.value()[ii].waveData[j]-iterWaveData.value()[ii].mean)/1000);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
qDebug() << "f" << f.size() << endl;
|
|
|
|
|
|
|
|
|
|
|
|
err = Pa_OpenStream(
|
|
|
|
|
|
&stream,
|
|
|
|
|
|
NULL, /* no input */
|
|
|
|
|
|
&outputParameters,
|
|
|
|
|
|
SAMPLE_RATE,
|
|
|
|
|
|
1024,
|
|
|
|
|
|
paClipOff, /* we won't output out of range samples so don't bother clipping them */
|
|
|
|
|
|
NULL, /* no callback, use blocking API */
|
|
|
|
|
|
NULL ); /* no callback, so no callback userData */
|
|
|
|
|
|
if( err != paNoError ) goto error;
|
|
|
|
|
|
|
|
|
|
|
|
err = Pa_StartStream( stream );
|
|
|
|
|
|
if( err != paNoError ) goto error;
|
|
|
|
|
|
|
|
|
|
|
|
qDebug()<<"NUM_SECONDS " << NUM_SECONDS << endl;
|
|
|
|
|
|
|
|
|
|
|
|
bufferCount = ((NUM_SECONDS * SAMPLE_RATE) / FRAMES_PER_BUFFER);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qDebug()<<"bufferCount " << bufferCount << endl;
|
|
|
|
|
|
for(a =0; a < bufferCount; a++ )
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_isStop)
|
|
|
|
|
|
break;
|
|
|
|
|
|
for(b =0; b < FRAMES_PER_BUFFER; b++ )
|
|
|
|
|
|
{
|
|
|
|
|
|
count = b + a*FRAMES_PER_BUFFER;
|
|
|
|
|
|
buffer[b][0] = f[count]; /* left */
|
|
|
|
|
|
buffer[b][1] = f[count]; /* right */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
err = Pa_WriteStream( stream, buffer, FRAMES_PER_BUFFER );
|
|
|
|
|
|
if( err != paNoError ) goto error;
|
|
|
|
|
|
if( ((a+1) * FRAMES_PER_BUFFER % SAMPLE_RATE == 0)){
|
|
|
|
|
|
emit PlayWaveSig();
|
|
|
|
|
|
}
|
|
|
|
|
|
std::unique_lock<std::mutex> lock(mu);
|
|
|
|
|
|
m_cv.wait(lock, [this] {return !m_isPause; });
|
|
|
|
|
|
}
|
|
|
|
|
|
qDebug()<<"count " << count << endl;
|
|
|
|
|
|
err = Pa_StopStream( stream );
|
|
|
|
|
|
if( err != paNoError ) goto error;
|
|
|
|
|
|
Pa_Sleep( 1000 );
|
|
|
|
|
|
err = Pa_CloseStream( stream );
|
|
|
|
|
|
if( err != paNoError ) goto error;
|
|
|
|
|
|
|
|
|
|
|
|
Pa_Terminate();
|
|
|
|
|
|
printf("Test finished.\n");
|
|
|
|
|
|
ui->Btn_Sound->setChecked(false);
|
|
|
|
|
|
EnableBtn();
|
|
|
|
|
|
error:
|
|
|
|
|
|
fprintf( stderr, "An error occurred while using the portaudio stream\n" );
|
|
|
|
|
|
fprintf( stderr, "Error number: %d\n", err );
|
|
|
|
|
|
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
|
|
|
|
|
|
// Print more information about the error.
|
|
|
|
|
|
if( err == paUnanticipatedHostError )
|
|
|
|
|
|
{
|
|
|
|
|
|
const PaHostErrorInfo *hostErrorInfo = Pa_GetLastHostErrorInfo();
|
|
|
|
|
|
fprintf( stderr, "Host API error = #%ld, hostApiType = %d\n", hostErrorInfo->errorCode, hostErrorInfo->hostApiType );
|
|
|
|
|
|
fprintf( stderr, "Host API error = %s\n", hostErrorInfo->errorText );
|
|
|
|
|
|
}
|
|
|
|
|
|
Pa_Terminate();
|
|
|
|
|
|
qDebug() << "PlayWaveSound end" << endl;
|
|
|
|
|
|
ui->Btn_Sound->setChecked(false);
|
|
|
|
|
|
EnableBtn();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ChildForm::OnPlayWaveSound()
|
|
|
|
|
|
{
|
|
|
|
|
|
qDebug() << "PlayWaveSound" << endl;
|
|
|
|
|
|
QMap<QString,WAVE_DISPALYDATA>::Iterator iter1 = mapWaveDisplayData.begin();
|
|
|
|
|
|
for(iter1 = mapWaveDisplayData.begin();iter1 != mapWaveDisplayData.end();iter1++){
|
|
|
|
|
|
qDebug() << iter1.value().channelType << endl;
|
|
|
|
|
|
if(iter1.value().channelType == "ACCELEROMETER" || iter1.value().channelType == "MICROPHONE"){
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
MyMsgBox(QMessageBox::Warning,"警告","支持加速度和声音通道进行播放!");
|
|
|
|
|
|
ui->Btn_Sound->setChecked(false);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!ui->Btn_Sound->isChecked()){
|
|
|
|
|
|
ui->Btn_Sound->setChecked(false);
|
|
|
|
|
|
std::unique_lock<std::mutex> lock(mu);
|
|
|
|
|
|
m_isPause = true;
|
|
|
|
|
|
m_cv.notify_one();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(m_isPause){
|
|
|
|
|
|
std::unique_lock<std::mutex> lock(mu);
|
|
|
|
|
|
m_isPause = false;
|
|
|
|
|
|
m_cv.notify_one();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(listChannelID.size() > 2)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
EnableBtn();
|
|
|
|
|
|
emit InitWaveSig();
|
|
|
|
|
|
m_isStop = false;
|
|
|
|
|
|
// m_pPlaySound = new PlayWaveSound();
|
|
|
|
|
|
// m_pThread = new QThread;
|
|
|
|
|
|
// //移动到另一线程
|
|
|
|
|
|
// m_pPlaySound->moveToThread(m_pThread);
|
|
|
|
|
|
// m_pThread->start();
|
|
|
|
|
|
// QCoreApplication::processEvents();
|
|
|
|
|
|
|
|
|
|
|
|
std::thread t1(&ChildForm::PlaySoundThread,this);
|
|
|
|
|
|
t1.detach();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ChildForm::realTimeData()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
QString topicPub = QString("up/%1/recive/waveserver").arg(m_DeviceInfo->DeviceMac);//推送
|
|
|
|
|
|
QString topicSub = QString("up/%1/waveserver").arg(m_DeviceInfo->DeviceMac);//订阅
|
|
|
|
|
|
|
|
|
|
|
|
QJsonArray channel_Arr;
|
|
|
|
|
|
QJsonObject root_Obj;
|
|
|
|
|
|
QJsonObject item_Obj;
|
|
|
|
|
|
for(int i = 0; i < listChannelID.size();i++){
|
|
|
|
|
|
item_Obj.insert("channelId",listChannelID[i]);
|
|
|
|
|
|
item_Obj.insert("flag",1);
|
|
|
|
|
|
channel_Arr.insert(i,item_Obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
root_Obj.insert("cmd","09");
|
|
|
|
|
|
if(!m_bRealTime){
|
|
|
|
|
|
m_bRealTime = true;
|
|
|
|
|
|
root_Obj.insert("type","GET");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
root_Obj.insert("type","STOP");
|
|
|
|
|
|
m_bRealTime = false;
|
|
|
|
|
|
//handlePlayWave(m_position);
|
|
|
|
|
|
}
|
|
|
|
|
|
root_Obj.insert("channelArray",channel_Arr);
|
|
|
|
|
|
QJsonDocument root_Doc;
|
|
|
|
|
|
root_Doc.setObject(root_Obj);
|
|
|
|
|
|
QByteArray root_str = root_Doc.toJson(QJsonDocument::Compact);
|
|
|
|
|
|
QString strJson(root_str);
|
|
|
|
|
|
qDebug() << strJson << endl;
|
|
|
|
|
|
QMQTT::Message message(136,topicPub,strJson.toUtf8());
|
|
|
|
|
|
mqttclient->Push(message);
|
|
|
|
|
|
mqttclient->subscribed(topicSub);
|
|
|
|
|
|
connect(mqttclient, SIGNAL(WaveData_sig(QByteArray)), this, SLOT(RealTimeWave(QByteArray)));
|
|
|
|
|
|
EnableBtn();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int graphCount = ui->widget->clearGraphs();
|
|
|
|
|
|
QMap<QString,QCPGraph*>().swap(waveGraph);
|
|
|
|
|
|
qDebug() << "graphCount" << graphCount<< endl;
|
|
|
|
|
|
|
|
|
|
|
|
if(!ui->Btn_AC_DC->isChecked()){
|
|
|
|
|
|
m_bDC = false;
|
|
|
|
|
|
}else if(ui->Btn_AC_DC->isChecked()){
|
|
|
|
|
|
m_bDC = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
handlePlayWave(m_position);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ChildForm::CalculateIntegration(bool isDoubleIntegration)
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->widget->clearGraphs();
|
|
|
|
|
|
QMap<QString,QCPGraph*>().swap(waveGraph);
|
2022-08-02 10:19:41 +08:00
|
|
|
|
QVector<double> x,y;
|
2022-07-30 11:50:01 +08:00
|
|
|
|
QVector<double> temDCWave;
|
|
|
|
|
|
QMap<QString,WAVE_DISPALYDATA>::Iterator iter = mapWaveDisplayData.begin();
|
|
|
|
|
|
for (int i = 0; i < listChannelID.size(); ++i){
|
|
|
|
|
|
for(;iter != mapWaveDisplayData.end();iter++){
|
|
|
|
|
|
if(listChannelID.at(i) == iter.key()){
|
|
|
|
|
|
QVector<double>().swap(x);
|
|
|
|
|
|
QVector<double>().swap(y);
|
|
|
|
|
|
QVector<double>().swap(temDCWave);
|
|
|
|
|
|
for(int j = 0; j < iter.value().SamleRate;j++){
|
|
|
|
|
|
temDCWave.push_back(iter.value().wavedata.at(j) - iter.value().mean);
|
|
|
|
|
|
}
|
2022-08-02 10:19:41 +08:00
|
|
|
|
double rms = 0.0;
|
2022-07-30 11:50:01 +08:00
|
|
|
|
double f = 0.0;
|
2022-08-02 10:19:41 +08:00
|
|
|
|
pCalculation->_Integration(temDCWave,y,rms);
|
2022-07-30 11:50:01 +08:00
|
|
|
|
|
|
|
|
|
|
if(isDoubleIntegration){
|
|
|
|
|
|
m_bDoubleIntegration = true;
|
2022-08-02 10:19:41 +08:00
|
|
|
|
QVector<double> key,Proximeter;
|
|
|
|
|
|
pCalculation->_Integration(y,Proximeter,rms);
|
2022-07-30 11:50:01 +08:00
|
|
|
|
double gap = (double)1/(double)Proximeter.size();
|
|
|
|
|
|
for(int ii = 0; ii < Proximeter.size();ii++){
|
2022-08-02 10:19:41 +08:00
|
|
|
|
f += gap;
|
|
|
|
|
|
key.push_back(f);
|
2022-07-30 11:50:01 +08:00
|
|
|
|
}
|
2022-08-02 10:19:41 +08:00
|
|
|
|
|
2022-07-30 11:50:01 +08:00
|
|
|
|
ui->widget->xAxis->setRange(0, 1);
|
|
|
|
|
|
QCPGraph* graph = ui->widget->addGraph();
|
|
|
|
|
|
ui->widget->graph(i)->setData(key, Proximeter);
|
|
|
|
|
|
// let the ranges scale themselves so graph 0 fits perfectly in the visible area:
|
|
|
|
|
|
ui->widget->graph(i)->rescaleValueAxis();
|
|
|
|
|
|
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:
|
|
|
|
|
|
ui->widget->xAxis->setLabel("Time(s)");
|
|
|
|
|
|
if(iter.value().channelType =="ACCELEROMETER"){
|
|
|
|
|
|
ui->widget->yAxis->setLabel("PROXIMETER(um)");
|
|
|
|
|
|
}
|
|
|
|
|
|
waveGraph.insert(listChannelID.at(i), graph);
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
2022-08-02 10:19:41 +08:00
|
|
|
|
|
2022-07-30 11:50:01 +08:00
|
|
|
|
double gap = (double)1/(double)y.size();
|
|
|
|
|
|
for(int ii = 0; ii < y.size();ii++){
|
|
|
|
|
|
f += gap;
|
|
|
|
|
|
x.push_back(f);
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->xAxis->setRange(0, 1);
|
|
|
|
|
|
QCPGraph* graph = ui->widget->addGraph();
|
|
|
|
|
|
ui->widget->graph(i)->setData(x, y);
|
|
|
|
|
|
// let the ranges scale themselves so graph 0 fits perfectly in the visible area:
|
|
|
|
|
|
ui->widget->graph(i)->rescaleValueAxis();
|
|
|
|
|
|
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:
|
2022-08-02 10:19:41 +08:00
|
|
|
|
// QString strRMS = QString("Time(s) %1: %2").arg( "RMS" ).arg(rms);
|
|
|
|
|
|
|
2022-07-30 11:50:01 +08:00
|
|
|
|
ui->widget->xAxis->setLabel("Time(s)");
|
|
|
|
|
|
if(iter.value().channelType =="VELOCITY"){
|
|
|
|
|
|
ui->widget->yAxis->setLabel("PROXIMETER(um)");
|
|
|
|
|
|
}else if(iter.value().channelType =="ACCELEROMETER"){
|
|
|
|
|
|
ui->widget->yAxis->setLabel("Velocity(mm/s)");
|
|
|
|
|
|
}
|
|
|
|
|
|
waveGraph.insert(listChannelID.at(i), graph);
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->replot(QCustomPlot::rpImmediateRefresh);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ChildForm::CalculateDifferentiation(bool isDoubleDifferentiation)
|
|
|
|
|
|
{
|
|
|
|
|
|
QVector<double> key,value,yValue,key2,yValue2;
|
2022-08-02 10:19:41 +08:00
|
|
|
|
QVector<double> temDCWave,diffValue,diffValue2;
|
2022-07-30 11:50:01 +08:00
|
|
|
|
QMap<QString,WAVE_DISPALYDATA>::Iterator iter = mapWaveDisplayData.begin();
|
|
|
|
|
|
for (int i = 0; i < listChannelID.size(); ++i){
|
|
|
|
|
|
for(;iter != mapWaveDisplayData.end();iter++){
|
|
|
|
|
|
if(listChannelID.at(i) == iter.key()){
|
|
|
|
|
|
double gap,f;
|
2022-08-02 10:19:41 +08:00
|
|
|
|
f= 0.0;
|
|
|
|
|
|
QVector<double>().swap(temDCWave);
|
|
|
|
|
|
QVector<double>().swap(diffValue);
|
2022-07-30 11:50:01 +08:00
|
|
|
|
gap = (double)1/(double)iter.value().SamleRate;
|
2022-08-02 10:19:41 +08:00
|
|
|
|
for(int j = 0; j < iter.value().SamleRate;j++){
|
|
|
|
|
|
temDCWave.push_back(iter.value().wavedata.at(j) - iter.value().mean);
|
2022-07-30 11:50:01 +08:00
|
|
|
|
}
|
2022-08-02 10:19:41 +08:00
|
|
|
|
pCalculation->_Differentiation(temDCWave,diffValue);
|
2022-07-30 11:50:01 +08:00
|
|
|
|
|
2022-08-02 10:19:41 +08:00
|
|
|
|
for(int i = 0 ; i < diffValue.size();i++){
|
|
|
|
|
|
yValue.push_back(diffValue[i]/(double)10000);
|
2022-07-30 11:50:01 +08:00
|
|
|
|
f += gap;
|
|
|
|
|
|
key.push_back(f);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QCPGraph* graph = ui->widget->addGraph();
|
|
|
|
|
|
|
|
|
|
|
|
if(isDoubleDifferentiation){//二次微分
|
|
|
|
|
|
m_bDoubleDifferentiation = true;
|
2022-08-02 10:19:41 +08:00
|
|
|
|
QVector<double>().swap(diffValue2);
|
|
|
|
|
|
f = 0.0;
|
|
|
|
|
|
pCalculation->_Differentiation(yValue,diffValue2);
|
2022-07-30 11:50:01 +08:00
|
|
|
|
|
2022-08-02 10:19:41 +08:00
|
|
|
|
for(int i = 0 ; i < diffValue2.size();i++){
|
|
|
|
|
|
yValue2.push_back(diffValue2[i]/(double)10000);
|
2022-07-30 11:50:01 +08:00
|
|
|
|
f += gap;
|
|
|
|
|
|
key2.push_back(f);
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->xAxis->setRange(0, 1);
|
|
|
|
|
|
ui->widget->graph(i)->setData(key2, yValue2);
|
|
|
|
|
|
ui->widget->yAxis->setLabel("ACCELEROMETER(m/s^2)");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
ui->widget->xAxis->setRange(0, 1);
|
|
|
|
|
|
ui->widget->graph(i)->setData(key, yValue);
|
2022-08-02 10:19:41 +08:00
|
|
|
|
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)");
|
2022-07-30 11:50:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
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:
|
2022-08-02 10:19:41 +08:00
|
|
|
|
ui->widget->xAxis->setLabel("Time(s)");
|
2022-07-30 11:50:01 +08:00
|
|
|
|
|
|
|
|
|
|
ui->widget->replot(QCustomPlot::rpImmediateRefresh);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::DoubleDifferentiationSlot()
|
|
|
|
|
|
{
|
|
|
|
|
|
qDebug() << "DoubleDifferentiationSlot" << endl;
|
|
|
|
|
|
|
|
|
|
|
|
if(listChannelID.size() > 1)
|
|
|
|
|
|
return;
|
|
|
|
|
|
ui->widget->clearGraphs();
|
|
|
|
|
|
if(m_bDoubleDifferentiation){
|
|
|
|
|
|
m_bDoubleDifferentiation = false;
|
|
|
|
|
|
handlePlayWave(m_position);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
m_bDoubleDifferentiation = true;
|
|
|
|
|
|
m_bDifferentiation = false;
|
|
|
|
|
|
if(m_iFormType == TimeDomainPlot){
|
|
|
|
|
|
CalculateDifferentiation(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
void ChildForm::DifferentiationSlot()
|
|
|
|
|
|
{
|
|
|
|
|
|
qDebug() << "differentiationSlot" << endl;
|
|
|
|
|
|
|
|
|
|
|
|
if(listChannelID.size() > 1)
|
|
|
|
|
|
return;
|
|
|
|
|
|
ui->widget->clearGraphs();
|
|
|
|
|
|
if(m_bDifferentiation){
|
|
|
|
|
|
m_bDifferentiation = false;
|
|
|
|
|
|
handlePlayWave(m_position);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
m_bDifferentiation = true;
|
|
|
|
|
|
m_bDoubleDifferentiation = false;
|
|
|
|
|
|
if(m_iFormType == TimeDomainPlot){
|
|
|
|
|
|
CalculateDifferentiation();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ChildForm::DoubleIntegrationSlot(){
|
|
|
|
|
|
|
|
|
|
|
|
qDebug() << "DoubleIntegrationSlot" << endl;
|
|
|
|
|
|
if(listChannelID.size() > 1)
|
|
|
|
|
|
return;
|
|
|
|
|
|
ui->widget->clearGraphs();
|
|
|
|
|
|
if(m_bDoubleIntegration){
|
|
|
|
|
|
m_bDoubleIntegration = false;
|
|
|
|
|
|
handlePlayWave(m_position);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
m_bDoubleIntegration = true;
|
|
|
|
|
|
m_bIntegration = false;
|
|
|
|
|
|
if(m_iFormType == TimeDomainPlot){
|
|
|
|
|
|
CalculateIntegration(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ChildForm::IntegrationSlot()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(listChannelID.size() > 1)
|
|
|
|
|
|
return;
|
|
|
|
|
|
ui->widget->clearGraphs();
|
|
|
|
|
|
if(m_bIntegration){
|
|
|
|
|
|
m_bIntegration = false;
|
|
|
|
|
|
handlePlayWave(m_position);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
m_bIntegration = true;
|
|
|
|
|
|
m_bDoubleIntegration = 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){
|
|
|
|
|
|
QMap<QString,WAVE_DISPALYDATA>::Iterator iter = mapWaveDisplayData.begin();
|
|
|
|
|
|
for (int i = 0; i < listChannelID.size(); ++i){
|
|
|
|
|
|
for(;iter != mapWaveDisplayData.end();iter++){
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->xAxis->setRange(0, realvalue.size());
|
|
|
|
|
|
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();
|
|
|
|
|
|
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:
|
|
|
|
|
|
ui->widget->xAxis->setLabel("Frequency(Hz)");
|
|
|
|
|
|
ui->widget->yAxis->setLabel("Velocity(mm/s)");
|
|
|
|
|
|
ui->widget->replot(QCustomPlot::rpImmediateRefresh);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->widget->replot(QCustomPlot::rpImmediateRefresh);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ChildForm::EnableBtn()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_iFormType == TimeDomainPlot){
|
|
|
|
|
|
if(ui->Btn_Sound->isChecked()){
|
|
|
|
|
|
ui->Btn_Zoom->setEnabled(false);
|
|
|
|
|
|
ui->Btn_ZoomMenu->setEnabled(false);
|
|
|
|
|
|
ui->Btn_setScales->setEnabled(false);
|
|
|
|
|
|
ui->measureBtn->setEnabled(false);
|
|
|
|
|
|
ui->Btn_Hz->setEnabled(false);
|
|
|
|
|
|
ui->Btn_AC_DC->setEnabled(false);
|
|
|
|
|
|
ui->Btn_differentiation->setEnabled(false);
|
|
|
|
|
|
ui->temBtn_4->setEnabled(false);
|
|
|
|
|
|
ui->temBtn_5->setEnabled(false);
|
|
|
|
|
|
ui->Btn_Cursor->setEnabled(false);
|
|
|
|
|
|
ui->Btn_Annotation->setEnabled(false);
|
|
|
|
|
|
ui->realTimeDataBtn->setEnabled(false);
|
|
|
|
|
|
}else if(ui->realTimeDataBtn->isChecked()){
|
|
|
|
|
|
ui->zoomBtn_hand->setEnabled(false);
|
|
|
|
|
|
ui->Btn_Zoom->setEnabled(false);
|
|
|
|
|
|
ui->Btn_ZoomMenu->setEnabled(false);
|
|
|
|
|
|
ui->Btn_setScales->setEnabled(false);
|
|
|
|
|
|
ui->measureBtn->setEnabled(false);
|
|
|
|
|
|
ui->Btn_Hz->setEnabled(false);
|
|
|
|
|
|
ui->Btn_AC_DC->setEnabled(false);
|
|
|
|
|
|
ui->Btn_differentiation->setEnabled(false);
|
|
|
|
|
|
ui->temBtn_4->setEnabled(false);
|
|
|
|
|
|
ui->temBtn_5->setEnabled(false);
|
|
|
|
|
|
ui->Btn_Cursor->setEnabled(false);
|
|
|
|
|
|
ui->Btn_Annotation->setEnabled(false);
|
|
|
|
|
|
ui->Btn_Sound->setEnabled(false);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
ui->zoomBtn_hand->setEnabled(true);
|
|
|
|
|
|
ui->Btn_Zoom->setEnabled(true);
|
|
|
|
|
|
ui->Btn_ZoomMenu->setEnabled(true);
|
|
|
|
|
|
ui->Btn_setScales->setEnabled(true);
|
|
|
|
|
|
ui->Btn_AC_DC->setEnabled(true);
|
|
|
|
|
|
ui->Btn_differentiation->setEnabled(true);
|
|
|
|
|
|
ui->Btn_Cursor->setEnabled(true);
|
|
|
|
|
|
ui->realTimeDataBtn->setEnabled(true);
|
|
|
|
|
|
ui->Btn_Sound->setEnabled(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//选点处理函数
|
|
|
|
|
|
void ChildForm::OnPlotClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event)
|
|
|
|
|
|
{
|
|
|
|
|
|
//先获取点击的绘图层名称,然后通过名称找到图层ID,再找到对应的数据点
|
|
|
|
|
|
int graphId = 0;
|
|
|
|
|
|
const QCPGraphData *ghd = ui->widget->graph(graphId)->data()->at(dataIndex);
|
|
|
|
|
|
qDebug() << ghd->key << ghd->value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|