-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformscope.h
142 lines (95 loc) · 2.49 KB
/
formscope.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
#ifndef FORMSCOPE_H
#define FORMSCOPE_H
#include <QWidget>
#include "iscope.h"
#include <QVector>
#include <QThread>
#include <QTimer>
namespace Ui
{
class FormScope;
}
class AnalogSignal;
class AnalogPlot;
class QMutex;
class QTimer;
class MainWindow;
class QSettings;
class FormScope;
class ScopeWorkerThread : public QThread
{
Q_OBJECT
public:
ScopeWorkerThread( FormScope* formScope )
:m_formScope(formScope),m_run(true)
{
}
void run();
void stop()
{
m_run = false;
}
protected:
FormScope* m_formScope;
bool m_run;
};
class FormScope : public QWidget, IScope
{
Q_OBJECT
public:
explicit FormScope( QSettings* settings, QWidget *parent = 0 );
~FormScope();
virtual void insertScopeData( const QVector<double>& channel1, const QVector<double>& channel2 );
virtual void setSampleTime( double time );
virtual void connectToScope();
virtual void disconnectFromScope();
void processScopeData();
protected:
virtual void closeEvent(QCloseEvent *e);
virtual void resizeEvent(QResizeEvent *);
protected slots:
void amplitudeChannelOneChanged( int value );
void amplitudeChannelTwoChanged( int value );
void triggerSourceChanged( int value );
void amplitudeSpinChannelOneChanged( double value );
void amplitudeSpinChannelTwoChanged( double value );
void triggerLevelChanged( double value );
void channelOneEnable( bool enabled );
void channelTwoEnable( bool enabled );
void timeChanged( int value );
void refreshTimerExpired();
private:
void setDefaults();
private:
ScopeWorkerThread * workerThread;
Ui::FormScope *ui;
AnalogPlot* m_plot;
QMutex* m_mutex;
QTimer* m_refreshTimer;
bool m_channelOneEnabled;
bool m_channelTwoEnabled;
int m_timeBase; //in uS
bool m_connected;
double m_sampleTime;
bool m_triggered;
double m_triggerLevel;
bool m_waitTrigger;
unsigned int m_triggerSource;
unsigned int m_currentSample;
unsigned int m_numOfSamples;
bool m_dataChanged;
unsigned int m_refCounter;
double m_ampCh1;
double m_ampCh2;
QMutex* m_mutexExchange;
QVector<double> m_channel1;
QVector<double> m_channel2;
AnalogSignal* m_pAnalogSignalChannel1;
AnalogSignal* m_pAnalogSignalChannel2;
QVector<double> timeValues;
QVector<double> yValuesChannel1;
QVector<double> yValuesChannel2;
MainWindow* m_mainWindow;
QSettings* m_settings;
};
#endif // FORMSCOPE_H