-
Notifications
You must be signed in to change notification settings - Fork 63
/
ofdm-handler.h
executable file
·175 lines (171 loc) · 5.19 KB
/
ofdm-handler.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
#
/*
* Copyright (C) 2015 .. 2023
* Jan van Katwijk ([email protected])
* Lazy Chair Computing
*
* This file is part of Qt-DAB
*
* Qt-DAB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Qt-DAB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Qt-DAB; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#
#pragma once
/*
* the ofdmHandler is the embodying of all functionality related
* to the ofdm processing and preparation for further decoding
*/
#include "dab-constants.h"
#include <QThread>
#include <QObject>
#include <QByteArray>
#include <QStringList>
#include <QSettings>
#include <vector>
#include <cstdint>
#include "sample-reader.h"
#include "fic-handler.h"
#include "msc-handler.h"
#include "ofdm-decoder.h"
#include "device-handler.h"
#include "ringbuffer.h"
#include "tii-detector.h"
#include "eti-generator.h"
class RadioInterface;
class dabParams;
class processParams;
class logger;
class ofdmHandler: public QThread {
Q_OBJECT
public:
ofdmHandler (RadioInterface *,
deviceHandler *,
processParams *,
QSettings *,
logger *);
~ofdmHandler ();
void start ();
// void start (int32_t);
void stop ();
void start_dumping (const QString &, int);
void stop_dumping ();
bool start_etiGenerator (const QString &);
void stop_etiGenerator ();
void reset_etiGenerator ();
void set_scanMode (bool);
void get_frameQuality (int *, int*, int *);
// servicing our subordinates
// for the ficHandler:
QString find_service (uint32_t, int);
void get_parameters (const QString &,
uint32_t *, int *);
std::vector<serviceId> get_services (int);
void data_for_audioservice (const QString &,
audiodata &);
void data_for_packetservice (const QString &,
packetdata &, int16_t);
int get_nrComps (uint32_t);
uint8_t get_ecc ();
int32_t get_ensembleId ();
QString get_ensembleName ();
void set_epgData (int32_t, int32_t,
const QString &,
const QString &);
bool has_timeTable (uint32_t);
std::vector<epgElement> find_epgData (uint32_t);
uint32_t julianDate ();
QStringList basicPrint ();
int scanWidth ();
void start_ficDump (FILE *);
void stop_ficDump ();
//
// for the tiiHhandlers
void set_tiiThreshold (int);
// for the mscHandler
void reset_services ();
void stop_service (descriptorType *, int);
void stop_service (int, int);
bool set_audioChannel (audiodata &,
RingBuffer<std::complex<int16_t>> *,
FILE *, int);
bool set_dataChannel (packetdata &,
RingBuffer<uint8_t> *, int);
// void set_tiiDetectorMode (bool);
void handle_iqSelector ();
void handle_decoderSelector (int);
void set_correlationOrder (bool);
void set_dxMode (bool);
private:
RadioInterface *radioInterface_p;
processParams *p;
// deviceHandler *device_p;
dabParams params;
QSettings *settings_p;
logger *theLogger;
sampleReader theReader;
ficHandler theFicHandler;
etiGenerator theEtiGenerator;
TII_Detector theTIIDetector;
ofdmDecoder theOfdmDecoder;
mscHandler theMscHandler;
// deviceHandler *inputDevice;
int decoder;
int threshold;
int totalFrames;
int goodFrames;
int badFrames;
bool tiiSwitch;
int16_t tii_depth;
int16_t echo_depth;
RingBuffer<Complex > *tiiBuffer_p;
RingBuffer<Complex > *nullBuffer_p;
RingBuffer<float> *snrBuffer_p;
RingBuffer<Complex> *channelBuffer_p;
int16_t tii_delay;
int16_t tii_counter;
bool eti_on;
int16_t attempts;
bool scanMode;
int32_t T_null;
int32_t T_u;
int32_t T_s;
int32_t T_g;
int32_t T_F;
int32_t nrBlocks;
int32_t carriers;
int32_t carrierDiff;
int16_t fineOffset;
int32_t coarseOffset;
QByteArray transmitters;
bool correctionNeeded;
std::vector<Complex> ofdmBuffer;
bool isEvenFrame (int16_t, dabParams *);
bool correlationOrder;
bool dxMode;
virtual void run ();
signals:
void set_synced (bool);
void no_signal_found ();
void set_sync_lost ();
void show_tiiData (QVector<tiiData>, int);
void show_tii_spectrum ();
void show_spectrum (int);
void show_snr (float);
void show_snr (float, float, float,
float, float);
void show_clock_error (int);
void show_null (int, int);
void show_channel (int);
void show_Corrector (int, float);
};