-
Notifications
You must be signed in to change notification settings - Fork 0
/
PhasePlotPage.h
168 lines (140 loc) · 4.65 KB
/
PhasePlotPage.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
//
// PhasePlotPage.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 PHASEPLOTPAGE_H
#define PHASEPLOTPAGE_H
#include <TabWidgetFactory.h>
#include <QShowEvent>
#include <list>
#include "CoherentDetector.h"
namespace Ui {
class PhasePlotPage;
}
namespace SigDigger {
class PhaseComparator;
class PhasePlotPageConfig : public Suscan::Serializable {
public:
bool autoFit = true;
bool autoScroll = true;
bool doPlot = true;
float gainDb = 0;
float phaseOrigin = 0;
bool logEvents = false;
float measurementTime = .2;
float coherenceThreshold = 10.;
double maxAlloc = 256 * (1 << 20);
float dipoleSep = 1.1; // meters
bool angleOfArrival = false;
bool autoSave = false;
std::string saveDir = "";
// Overriden methods
void deserialize(Suscan::Object const &conf) override;
Suscan::Object &&serialize() override;
};
class PhasePlotPage : public TabWidget
{
Q_OBJECT
bool m_paramsSet = false;
PhaseComparator *m_owner = nullptr;
CoherentDetector *m_detector = nullptr;
PhasePlotPageConfig *m_config = nullptr;
std::vector<SUCOMPLEX> m_data;
std::vector<SUCOMPLEX> m_empty;
std::list<CoherentEvent> m_eventList;
SUFLOAT m_sampRate;
SUCOMPLEX m_accumulated;
SUSCOUNT m_accumCount = 0;
SUFLOAT m_max = 0;
SUFLOAT m_gain = 1;
SUCOMPLEX m_phaseAdjust = 1;
SUFLOAT m_wavelength;
SUFLOAT m_phaseScale;
FILE *m_autoSaveFp = nullptr;
SUSCOUNT m_savedSize = 0;
struct timeval m_lastTimeStamp;
struct timeval m_lastEvent;
struct timeval m_firstSamples;
bool m_haveFirstSamples = false;
bool m_infoLogged = false;
bool m_haveEvent = false;
bool m_haveSelection = false;
bool m_dataUpdated = false;
void refreshMeasurements();
void logDetectorInfo();
void clearData();
void refreshUi();
void plotSelectionPhase(qint64, qint64);
void connectAll();
void logText(QString const &);
void logText(struct timeval const &, QString const &);
void refreshPhaseScale();
void showEvent(QShowEvent *) override;
bool saveLog(QString const &);
bool saveCSV(QString const &);
public:
explicit PhasePlotPage(
TabWidgetFactory *,
UIMediator *,
QWidget *parent = nullptr);
~PhasePlotPage() override;
void feed(struct timeval const &tv, const SUCOMPLEX *, SUSCOUNT);
void setFreqencyLimits(SUFREQ min, SUFREQ max);
QString genAutoSaveFileName() const;
void abortAutoSaveFile(int error);
void cycleAutoSaveFile();
void setProperties(
PhaseComparator *,
SUFLOAT sampRate,
SUFREQ frequency,
SUFLOAT bandwidth);
virtual std::string getLabel() const override;
virtual void closeRequested() override;
virtual void setColorConfig(ColorConfig const &) override;
virtual Suscan::Serializable *allocConfig(void) override;
virtual void applyConfig(void) override;
virtual void setTimeStamp(struct timeval const &) override;
private:
Ui::PhasePlotPage *ui;
signals:
void closeReq();
void frequencyChanged(qreal);
void bandwidthChanged(qreal);
public slots:
void onSavePlot();
void onAutoScrollToggled();
void onEnablePlotToggled();
void onClear();
void onMaxAllocChanged();
void onAutoFitToggled();
void onAoAToggled();
void onGainChanged();
void onChangeFrequency();
void onChangeBandwidth();
void onChangePhaseOrigin();
void onChangeDipoleSep();
void onChangeMeasurementTime();
void onChangeCoherenceThreshold();
void onLogEnableToggled();
void onSaveLog();
void onClearLog();
void onToggleAutoSave();
void onBrowseSaveDir();
void onHSelection(qreal, qreal);
};
}
#endif // PHASEPLOTPAGE_H