-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformanalyzer.h
194 lines (144 loc) · 4.26 KB
/
formanalyzer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#ifndef FORMANALYZER_H
#define FORMANALYZER_H
#include "window.h"
#include "IAnalyzer.h"
#include "FrequencyPlot.h"
#include "signalgenerator.h"
#include <QWidget>
#include <QVector>
#include <QThread>
namespace Ui {
class FormAnalyzer;
}
class QSettings;
class MainWindow;
class QMutex;
class QTimer;
class FreqValues;
class AnalyzerWorkerThread;
class WeightingFilter;
class FormAnalyzer : public QWidget, IAnalyzer
{
Q_OBJECT
public:
explicit FormAnalyzer( QSettings* settings, QWidget *parent = 0);
~FormAnalyzer();
virtual void insertAnalyzerData( const QVector<double>& channel1, const QVector<double>& channel2 );
inline void setSamplingRate( unsigned int samplingRate )
{
m_samplingRate = samplingRate;
}
void processAnalyzerData();
inline void setSigGenParameters( SignalGenerator::SignalType sigType, unsigned int sigGenFreq1, unsigned int sigGenFreq2 )
{
m_sigType = sigType;
m_sigGenFreq1 = sigGenFreq1;
m_sigGenFreq2 = sigGenFreq2;
}
inline void resetSigGenParameters()
{
m_sigType = SignalGenerator::eEnd;
m_sigGenFreq1 = 0;
m_sigGenFreq2 = 0;
}
enum Scale
{
Logarithmic = 0,
Linear = 1
};
enum DistorsionType
{
Harmonic = 0,
Intermodulation = 1
};
enum WeightingFilterType
{
noFilter = 0,
ituR468 = 1
};
private slots:
void channelChanged(int index);
void fStartChanged(int value);
void fStopChanged(int value);
void windowLenChanged(int value);
void scaleChanged(int index);
void windowChanged(int index);
void attenuationChanged(int value);
void distorsionTypeChanged(int index);
void weightingFilterTypeChanged(int index);
void numHarmonicsChanged(int value);
void fftPointsChanged( int index );
void triggerLevelChanged( double value );
void refreshTimerExpired();
protected:
virtual void closeEvent(QCloseEvent *e);
virtual void resizeEvent(QResizeEvent *);
void readConfig();
int fillNumFFTPointsCombo( int minPoints );
void recomputeAll();
void computeTimesAndRefresh();
void showHideDistMeasurementWidgets();
private:
Ui::FormAnalyzer *ui;
QSettings* m_settings;
MainWindow* m_mainWindow;
QMutex* m_mutex;
QTimer* m_refreshTimer;
FrequencyPlot* m_plot;
FreqValues* m_pFreqValues;
unsigned int m_channel;
unsigned int m_fStart;
unsigned int m_fStop;
unsigned int m_windowLen; //in Hz
Scale m_scale;
BaseWindow::Window m_window;
unsigned int m_attenuation;
unsigned int m_numHarmonics;
unsigned int m_numFFTPoints;
DistorsionType m_distorsionType;
WeightingFilterType m_weightingFilter;
unsigned int m_samplingRate;
double m_triggerLevel;
bool m_triggered;
bool m_waitTrigger;
unsigned int m_currentSample;
bool m_dataChanged;
unsigned int m_refreshEveryms;
BaseWindow* m_pWindow;
double* m_fftValues;
double* m_valuesBuffer;
double* m_valNoWindowBuffer;
QMutex* m_mutexExchange;
QVector<double> m_channel1;
QVector<double> m_channel2;
double* m_averagesBuffer;
unsigned int m_currentAverage;
unsigned int m_numberOfAverages;
AnalyzerWorkerThread * workerThread;
SignalGenerator::SignalType m_sigType;
unsigned int m_sigGenFreq1;
unsigned int m_sigGenFreq2;
QString m_thdGoertzel;
WeightingFilter* m_pWeightingFilter;
QString m_Imd3;
double m_baseF1;
double m_baseF2;
};
class AnalyzerWorkerThread : public QThread
{
Q_OBJECT
public:
AnalyzerWorkerThread( FormAnalyzer* formAnalyzer )
:m_formAnalyzer(formAnalyzer),m_run(true)
{
}
void run();
inline void stop()
{
m_run = false;
}
protected:
FormAnalyzer* m_formAnalyzer;
bool m_run;
};
#endif // FORMANALYZER_H