-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsweeper.h
executable file
·74 lines (65 loc) · 2.2 KB
/
sweeper.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
#ifndef SWEEPER_H
#define SWEEPER_H
#include <QObject>
#include <SoapySDR/Device.hpp>
#include <SoapySDR/Types.hpp>
#include <SoapySDR/Formats.hpp>
#include <string> // std::string
#include <vector> // std::vector<...>
#include <map> // std::map< ... , ... >
#include <pthread.h>
#include <iostream>
#include <fft_hist.h>
#include <fft_fftw.h>
#include <sdr_device.h>
/*
This class holds FFT data for a single line swept from low to high
so, for a sweep of a 100Mhz bandwidth:
flow = 800Mhz
fhigh = 900Mhz
sweep_bw = (900 - 800) = 100Mhz
sdr_bw = 20Mhz
fstart = flow + (sdr_bw / 2)
fstart = 800 + ( 20 / 2) = 810
choosing a bin size of 4096 per fft:
rbw = sdr_bw / binsize
rbw = 20Mhz / 4096 = 4882.8125 Hz
total bins needed for sweep bandwidth =
tbins = sweep_bw / rbw
tbins = 100Mhz / 4882.8125 = 20480 bins
*/
//#define DEFAULT_SETTLE_TIME 5000
#define DEFAULT_SETTLE_TIME 2000
class SweepDataLine;
class Sweeper : public QObject
{
Q_OBJECT
public:
explicit Sweeper(QObject *parent = nullptr);
SDR_Device *m_radio;
void SetRadio(SDR_Device *radio){m_radio = radio;}
void StartSweep(double flow,double fhigh, int nBinsPerFFT, int overlappercent);
void StopSweep();
void Sweep();
bool IsSweeping(){return m_sweeping;}
void SetCorrectIQDrop(bool val){m_correctIQDrop = val;}
bool GetCorrectIQDrop(){return m_correctIQDrop;}
void SetViewRange(double lower, double upper);
void EatSamples();
double m_freq_low,m_freq_high; // the low and high freqs that we're scanning across
double m_viewfreqlow,m_viewfreqhigh;// where the user is actually looking at in Mhz
int m_nBinsPerFFT; // the FFT resolution per segment (the SDR bandwidth, not the sweepline bins)
int m_overlappercent; // the % of overlap of the individual FFT segments
FFT_Hist *m_ffthist; // place to gather the lines of FFT data
SweepDataLine *m_sweepline;
fft_fftw *m_fftw; // the algorithm used to calculate the fft
bool m_correctIQDrop;
long long m_settletime_uS; // the time to allow to settle after changing frequencies
private:
volatile bool m_sweeping;
pthread_t rst; // thread
signals:
void SweepCompleted(); // a single sweep was completed
public slots:
};
#endif // SWEEPER_H