-
Notifications
You must be signed in to change notification settings - Fork 0
/
SNRTool.h
154 lines (124 loc) · 4.27 KB
/
SNRTool.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
//
// SNRTool.h: description
// Copyright (C) 2023 Gonzalo José Carracedo Carballal
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program. If not, see
// <http://www.gnu.org/licenses/>
//
#ifndef SNRTOOL_H
#define SNRTOOL_H
#include <SNRToolFactory.h>
#include <QWidget>
#include <WFHelpers.h>
namespace Ui {
class SNRTool;
}
namespace Suscan {
class AnalyzerRequestTracker;
class AnalyzerRequest;
}
namespace SigDigger {
class PowerProcessor;
class MainSpectrum;
class SNRToolConfig : public Suscan::Serializable {
public:
float tau = 1;
bool collapsed = false;
bool normalize = true;
float refbw = 1;
bool bpe = false;
// Overriden methods
void deserialize(Suscan::Object const &conf) override;
Suscan::Object &&serialize() override;
};
class SNRTool : public ToolWidget
{
Q_OBJECT
Suscan::Analyzer *m_analyzer = nullptr;
MainSpectrum *m_spectrum = nullptr;
// SNR state
bool m_haveSignalNoise = false;
bool m_haveNoise = false;
qreal m_currentSignalNoise = -1;
qreal m_currentNoise = -1;
qreal m_currentSignalNoiseDensity = -1;
qreal m_currentNoiseDensity = -1;
qreal m_widthRatio = +1;
qreal m_signalNoiseWidth = +1;
qreal m_noiseWidth = +1;
NamedChannelSetIterator m_signalNoiseNamChan;
bool m_haveSignalNoiseNamChan = false;
NamedChannelSetIterator m_noiseNamChan;
bool m_haveNoiseNamChan = false;
PowerProcessor *m_signalNoiseProcessor = nullptr;
PowerProcessor *m_noiseProcessor = nullptr;
SNRToolConfig *m_panelConfig = nullptr;
QString m_clipBoardText;
// In hold mode:
// We set the integration time to T_i = MAX(100 ms, 1 / equiv_fs)
// We configure the alpha to tau / T_i
// For each sample, we update and refresh measurements
// In single shot mode:
// We set the integration time to MAX(tau, equiv_fs)
// We wait for a sample (maybe skip the first one?)
// After the sample, close the tracker and update
// In all cases, we display the status
void openSignalNoiseProbe(bool hold = false);
void openNoiseProbe(bool hold = false);
void cancelSignalNoiseProbe();
void cancelNoiseProbe();
void refreshUi();
void connectAll();
void refreshMeasurements();
bool isFrozen() const;
void refreshSignalNoiseNamedChannel();
void refreshNoiseNamedChannel();
void refreshNamedChannels();
void applySpectrumState();
public:
explicit SNRTool(SNRToolFactory *, UIMediator *, QWidget *parent = nullptr);
~SNRTool() override;
// Configuration methods
Suscan::Serializable *allocConfig() override;
void applyConfig() override;
bool event(QEvent *) override;
// Overriden methods
void setState(int, Suscan::Analyzer *) override;
void setQth(Suscan::Location const &) override;
void setColorConfig(ColorConfig const &) override;
void setTimeStamp(struct timeval const &) override;
void setProfile(Suscan::Source::Config &) override;
public slots:
void onSpectrumFrequencyChanged(qint64 freq);
void onSignalNoiseCont();
void onSignalNoiseSingle();
void onSignalNoiseCancel();
void onSignalNoiseAdjust();
void onSignalNoiseStateChanged(int, QString const &);
void onSignalNoiseMeasurement(qreal);
void onNoiseCont();
void onNoiseSingle();
void onNoiseCancel();
void onNoiseAdjust();
void onNoiseStateChanged(int, QString const &);
void onNoiseMeasurement(qreal);
void onTauChanged(qreal, qreal);
void onConfigChanged();
void onResetBpe();
void onCopyAll();
private:
Ui::SNRTool *ui;
};
}
#endif // SNRTOOL_H