SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
dspdevicesourceengine.h
Go to the documentation of this file.
1 // Copyright (C) 2015 F4EXB //
3 // written by Edouard Griffiths //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #ifndef INCLUDE_DSPDEVICEENGINE_H
20 #define INCLUDE_DSPDEVICEENGINE_H
21 
22 #include <QThread>
23 #include <QTimer>
24 #include <QMutex>
25 #include <QWaitCondition>
26 #include "dsp/dsptypes.h"
27 #include "dsp/fftwindow.h"
28 #include "util/messagequeue.h"
29 #include "util/syncmessenger.h"
30 #include "export.h"
31 #include "util/movingaverage.h"
32 
33 class DeviceSampleSource;
34 class BasebandSampleSink;
36 
37 class SDRBASE_API DSPDeviceSourceEngine : public QThread {
38  Q_OBJECT
39 
40 public:
41  enum State {
46  StError
47  };
48 
49  DSPDeviceSourceEngine(uint uid, QObject* parent = NULL);
51 
52  uint getUID() const { return m_uid; }
53 
54  MessageQueue* getInputMessageQueue() { return &m_inputMessageQueue; }
55 
56  void start();
57  void stop();
58 
59  bool initAcquisition();
60  bool startAcquisition();
61  void stopAcquistion();
62 
63  void setSource(DeviceSampleSource* source);
64  void setSourceSequence(int sequence);
65  DeviceSampleSource *getSource() { return m_deviceSampleSource; }
66 
67  void addSink(BasebandSampleSink* sink);
68  void removeSink(BasebandSampleSink* sink);
69 
70  void addThreadedSink(ThreadedBasebandSampleSink* sink);
71  void removeThreadedSink(ThreadedBasebandSampleSink* sink);
72 
73  void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection);
74 
75  State state() const { return m_state; }
76 
77  QString errorMessage();
78  QString sourceDeviceDescription();
79 
80 private:
81  uint m_uid;
82 
83  MessageQueue m_inputMessageQueue; //<! Input message queue. Post here.
85 
87 
88  QString m_errorMessage;
90 
93 
94  typedef std::list<BasebandSampleSink*> BasebandSampleSinks;
95  BasebandSampleSinks m_basebandSampleSinks;
96 
97  typedef std::list<ThreadedBasebandSampleSink*> ThreadedBasebandSampleSinks;
98  ThreadedBasebandSampleSinks m_threadedBasebandSampleSinks;
99 
102 
105  double m_iOffset, m_qOffset;
106 
109 
110 #if IMBALANCE_INT
111  // Fixed point DC + IQ corrections
118 
119 #else
120  // Floating point DC + IQ corrections
127 #endif
128 
129  qint32 m_iRange;
130  qint32 m_qRange;
131  qint32 m_imbalance;
132 
133  void run();
134 
135  void iqCorrections(SampleVector::iterator begin, SampleVector::iterator end, bool imbalanceCorrection);
136  void dcOffset(SampleVector::iterator begin, SampleVector::iterator end);
137  void imbalance(SampleVector::iterator begin, SampleVector::iterator end);
138  void work();
139 
140  State gotoIdle();
141  State gotoInit();
142  State gotoRunning();
143  State gotoError(const QString& errorMsg);
144 
145  void handleSetSource(DeviceSampleSource* source);
146 
147 private slots:
148  void handleData();
149  void handleInputMessages();
150  void handleSynchronousMessages();
151 };
152 
153 #endif // INCLUDE_DSPDEVICEENGINE_H
MovingAverageUtil< float, double, 128 > m_avgIQ
MovingAverageUtil< double, double, 128 > m_avgAmp
std::list< BasebandSampleSink * > BasebandSampleSinks
engine is before initialization
BasebandSampleSinks m_basebandSampleSinks
sample sinks within main thread (usually spectrum, file output)
DeviceSampleSource * getSource()
DeviceSampleSource * m_deviceSampleSource
MovingAverageUtil< float, double, 128 > m_avgQQ2
MovingAverageUtil< float, double, 128 > m_avgII2
MovingAverageUtil< double, double, 128 > m_avgPhi
MovingAverageUtil< int32_t, int64_t, 1024 > m_iBeta
State state() const
Return DSP engine current state.
std::list< ThreadedBasebandSampleSink * > ThreadedBasebandSampleSinks
ThreadedBasebandSampleSinks m_threadedBasebandSampleSinks
sample sinks on their own threads (usually channels)
#define SDRBASE_API
Definition: export.h:40
MovingAverageUtil< float, double, 128 > m_avgII
SyncMessenger m_syncMessenger
Used to process messages synchronously with the thread.
MessageQueue * getInputMessageQueue()
MovingAverageUtil< int32_t, int64_t, 1024 > m_qBeta