254 lines
7.5 KiB
C++
254 lines
7.5 KiB
C++
#ifndef CHILDFORM_H
|
||
#define CHILDFORM_H
|
||
|
||
#include <QWidget>
|
||
#include "BaseWgt.h"
|
||
#include <QtCharts>
|
||
#include <QChartView>
|
||
#include <QVector>
|
||
#include <QTableWidgetItem>
|
||
#include <QTimerEvent>
|
||
#include "ChartView.h"
|
||
#include "global.h"
|
||
#include <qmath.h>
|
||
#include "Calculation.hpp"
|
||
#include "qcustomplot.h"
|
||
#include "SetScalesform.h"
|
||
#include "FilterForm.h"
|
||
#include "Mqttclient.h"
|
||
#include "PlayWaveSound.h"
|
||
|
||
|
||
enum FormType
|
||
{
|
||
TimeDomainPlot, //时域图
|
||
FrequencyDomainPlot, //频域图
|
||
TrendChartPlot, //趋势图
|
||
SpecChartPlot, //频谱图
|
||
EnvChartPlot, //包络图
|
||
WaterFallPlot, //瀑布图
|
||
OrbitPlot, //轴心轨迹
|
||
PolarPlot, //极坐标
|
||
BodePlot, //伯德图
|
||
ShaftCenterline, //轴心位置图
|
||
AllWavePlot //全谱图
|
||
};
|
||
|
||
|
||
typedef struct {
|
||
int key1;
|
||
int key2;
|
||
float fSpeed;
|
||
}RPM;
|
||
typedef struct _ChannelData
|
||
{
|
||
QString ChannelId;
|
||
}ChannelData;
|
||
|
||
class ChartView;
|
||
class Chart;
|
||
class QAbstractAxis;
|
||
class LegendForm;
|
||
|
||
namespace Ui {
|
||
class ChildForm;
|
||
}
|
||
class ChildForm : public BaseWgt
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
explicit ChildForm(FormType iType,QString m_strName = "",DEVICE_INFO* DeviceInfo = NULL, QWidget *parent = nullptr);
|
||
~ChildForm();
|
||
|
||
void SetName(QString strName)
|
||
{
|
||
m_strName = strName;
|
||
}
|
||
|
||
QString GetName()
|
||
{
|
||
return m_strName;
|
||
}
|
||
QHBoxLayout *pLayout;
|
||
Calculation *pCalculation;
|
||
QMetaObject::Connection dismove;
|
||
QMetaObject::Connection disDoubleclick;
|
||
QMetaObject::Connection disPress;
|
||
QMetaObject::Connection dis1;
|
||
WAVE_DATA m_waveData;
|
||
FormType m_iFormType;
|
||
void InitDisPaly();
|
||
void InitRpmDisPaly();
|
||
void ShowCharts();
|
||
void SetFormType(FormType iType) {m_iFormType = iType;}
|
||
FormType GetFormType() { return m_iFormType;}
|
||
void SetWaveData(QString strID, QVector<WAVE_DATA>& waveData);
|
||
void SetDataIDs(const QStringList &strIDList, QString strTitle,const QStringList& strChannleTypeList,\
|
||
const QStringList& strChannleNameList);
|
||
void handlePlayWave(double position = 0,double size = 131072); //
|
||
void AddOrbitSeries(QString strID, const QVector<WAVE_DATA>& wavexData,const QVector<WAVE_DATA>& waveyData,\
|
||
const QVector<WAVE_DATA>& waveSpeedData);
|
||
void AddBodeSeries(QString strID, const QVector<WAVE_DATA>& wavexData,const QVector<WAVE_DATA>& waveSpeedData);
|
||
void AddShaftCenterlineSeries(QString strID, const QVector<WAVE_DATA>& wavexData,const QVector<WAVE_DATA>& waveData);
|
||
void AddPolarPlotSeries(QString strID, const QVector<WAVE_DATA>& wavexData,const QVector<WAVE_DATA>& waveSpeedData);
|
||
void UpdateEnvSerises(QString Start,QString End);
|
||
QPixmap GetSerise(QString& strImagePath);
|
||
void AddSeries(QString strID, QVector<WAVE_DATA>& waveData);
|
||
QCPGraph* MultiyAxis(QString strID,QString sensorType,QString sensorEngineeringUnit);
|
||
void SecondData(const QString& strID,WAVE_DATA& waveData,WAVE_DISPALYDATA& waveShowData);
|
||
void CalculateRPM();
|
||
void CalculateIntegration(bool isDoubleIntegration = false);
|
||
void CalculateDifferentiation(bool isDoubleDifferentiation = false);
|
||
void EnableBtn();
|
||
void UpdateDiffMenu();
|
||
void InitIntegration();
|
||
QVector<WAVE_DATA> childWave;
|
||
QVector<WAVE_DATA> OrbitXWave,OrbitYWave;
|
||
QVector<KeyPhasor> vecKeyPhasor;
|
||
QList<QString> listChannelID;
|
||
QCPGraph *mainGraph1,*mainGraph2,*keyPhasor;
|
||
QCPCurve *fermatSpiral1;
|
||
QCPAxisRect *wideAxisRect1;
|
||
QCPAxisRect *wideAxisRect2;
|
||
QCPAxisRect *wideAxisRectOrbit;
|
||
QMap<QString,QVector<WAVE_DATA>> mapBodeData;
|
||
|
||
PlayWaveSound *m_pPlaySound;
|
||
QThread *m_pThread;
|
||
signals:
|
||
void ItemCheckStateSignal(QString strID, bool bChecked);
|
||
void OutSig();
|
||
void ReturnSig();
|
||
void PlayWaveSig();
|
||
void InitWaveSig();
|
||
|
||
protected:
|
||
|
||
public slots:
|
||
void ZoomBtnSlot_X();
|
||
void ZoomBtnSlot_Y();
|
||
void ZoomBtnSlot_XY();
|
||
void ZoomBtnSlot_Hand();
|
||
void ToRpm();
|
||
void Btn_ZoomSlot();
|
||
void IntegrationSlot();
|
||
void DoubleIntegrationSlot();
|
||
void DifferentiationSlot();
|
||
void DoubleDifferentiationSlot();
|
||
void ScalesBox();
|
||
void ScalesX();
|
||
void ScalesY();
|
||
void ScalesXY();
|
||
void Cursor();
|
||
void SetScales();
|
||
void SetFilter();
|
||
void SetDC();
|
||
void realTimeData();
|
||
void mouseMoveEvent(QMouseEvent *event);
|
||
void mouseDoubleClickEvent(QMouseEvent *event);
|
||
void mouseWheelEvent(QWheelEvent *event);
|
||
void ChannelBtnSlot();
|
||
void ItemChangedSlot(QTableWidgetItem *item);
|
||
void ItemPressSlot(QTableWidgetItem *item);
|
||
void slotSetScales(QString str);
|
||
void slotSetFilter(QString str);
|
||
void OnPlotClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event);
|
||
void RealTimeWave(QByteArray payLoad);
|
||
void OnPlayWaveSound();
|
||
void PlaySoundThread();
|
||
|
||
private:
|
||
bool m_bDC;
|
||
bool m_bRpm;
|
||
bool m_bIntegration;
|
||
bool m_bDifferentiation;
|
||
bool m_bDoubleIntegration;
|
||
bool m_bDoubleDifferentiation;
|
||
bool m_isPause;
|
||
bool m_isStop;
|
||
std::condition_variable m_cv;
|
||
std::mutex mu;
|
||
WAVE_CSVDATA m_vecCsvData[32];
|
||
|
||
int m_nStart;
|
||
int m_nEnd;
|
||
QMenu *remove_menu;
|
||
QAction *remove_selected_action;
|
||
QAction *remove_all_action;
|
||
QAction *Hz;
|
||
QAction *Ord;
|
||
QAction *Rad;
|
||
|
||
QCPAxis *yAxis3;
|
||
QList<QCPAxis*> Axis;
|
||
QCPItemTracer *tracer; //游标
|
||
QCPItemTracer *tracer2; //游标
|
||
|
||
QMap<QString,QCPItemText*> maptracerLabel;
|
||
QCPItemText *tracerLabel; //游标标签
|
||
QCPItemText *tracerLabel2; //游标标签
|
||
|
||
QCPItemText *tracerLabel3; //游标标签
|
||
QCPItemText *tracerLabel4; //游标标签
|
||
QCPItemText *tracerLabel5; //游标标签
|
||
QCPItemText *tracerLabel6; //游标标签
|
||
QCPItemText *tracerLabel7; //游标标签
|
||
QCPItemText *tracerLabel8; //游标标签
|
||
|
||
QMap<QString,WAVE_DISPALYDATA> mapWaveDisplayData;
|
||
QMap<QString,WAVE_DISPALYDATA> mapWaveDisplayData_RPM;
|
||
QMap<QString,QVector<WAVE_DATA>> mapWaveData;
|
||
QMap<QString,QVector<double>> waveTrendData;
|
||
QMap<QString,QVector<QVector<double>>> waveDataDC;
|
||
|
||
QMap<QString,QCPGraph*> waveGraph;
|
||
QMap<QString,QCPAxis*> waveYAxis;
|
||
QList<QString> listChannelType;
|
||
QMap<QString,QMap<QString,QCPAxis*>> mapMultiGraph; //<通道类型,<通道ID,Y轴>>
|
||
RotatingSpeed _rotatingSpeed;
|
||
QVector<double> x,y;
|
||
SetScalesForm *pSetScales;
|
||
FilterForm *pSetFilter;
|
||
MqttClient *mqttclient;
|
||
void InitWidget();
|
||
void ClearAllSerise();
|
||
void ClearTable();
|
||
void RemoveSeries(QString strID);
|
||
|
||
int m_position;
|
||
QTableWidgetItem * AddTableWgtItem(QString strText, QString clolor, QString strID);
|
||
|
||
QMenu *differentiationMenu;
|
||
QAction *Integration;
|
||
QAction *doubleIntegration;
|
||
QAction *differentiation;
|
||
QAction *doubleDifferentiation;
|
||
|
||
|
||
private:
|
||
Ui::ChildForm *ui;
|
||
int line ;
|
||
QString m_strName;
|
||
|
||
ChartView *m_pChartView;
|
||
QChart *m_pChart;
|
||
QLineSeries *series;
|
||
QStringList m_listChannelID;
|
||
|
||
|
||
QMap<QString, QTableWidgetItem *> m_mapChannelIDtoLabel;
|
||
|
||
bool m_bAttach;
|
||
DEVICE_INFO *m_DeviceInfo;
|
||
LegendForm *m_pLegendForm;
|
||
QTimer *m_pTimer;
|
||
int m_iRealTimer; //实时数据定时器ID
|
||
QString m_sServer; // 服务器地址
|
||
QString m_sEquipNo; // 终端号
|
||
//QMqttClient *m_client;
|
||
bool m_isconnect; // 是否已连接服务器
|
||
bool m_bRealTime;
|
||
};
|
||
#endif // CHILDFORM_H
|