From 5942e7683d1f5cfe371229569fa95fc75aeffbbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Jos=C3=A9=20Carracedo=20Carballal?= Date: Fri, 16 Aug 2019 13:37:56 +0200 Subject: [PATCH] Add channel parameter adjustment in inspector tab --- App/Application.cpp | 11 +- Components/InspectorPanel.cpp | 27 ++ Inspector/Inspector.cpp | 36 +++ Inspector/InspectorUI.cpp | 75 ++++- Suscan/Messages/InspectorMessage.cpp | 24 ++ include/Inspector.h | 2 + include/InspectorPanel.h | 5 + include/InspectorUI.h | 15 + include/Suscan/Messages/InspectorMessage.h | 4 + ui/Inspector.ui | 347 +++++++++++++++++---- ui/InspectorPanel.ui | 73 +++-- 11 files changed, 522 insertions(+), 97 deletions(-) diff --git a/App/Application.cpp b/App/Application.cpp index 68ff717e..2f38eff7 100644 --- a/App/Application.cpp +++ b/App/Application.cpp @@ -770,7 +770,16 @@ Application::onOpenInspector(void) ch.fLow = - .5 * ch.bw; ch.fHigh = + .5 * ch.bw; - this->analyzer->open(this->ui.inspectorPanel->getInspectorClass(), ch, 0); + if (this->ui.inspectorPanel->getPrecise()) + this->analyzer->openPrecise( + this->ui.inspectorPanel->getInspectorClass(), + ch, + 0); + else + this->analyzer->open( + this->ui.inspectorPanel->getInspectorClass(), + ch, + 0); } } diff --git a/Components/InspectorPanel.cpp b/Components/InspectorPanel.cpp index 4cc3a6e7..9d55a1ed 100644 --- a/Components/InspectorPanel.cpp +++ b/Components/InspectorPanel.cpp @@ -30,6 +30,7 @@ void InspectorPanelConfig::deserialize(Suscan::Object const &conf) { LOAD(inspectorClass); + LOAD(precise); } Suscan::Object && @@ -40,6 +41,7 @@ InspectorPanelConfig::serialize(void) obj.setClass("InspectorPanelConfig"); STORE(inspectorClass); + STORE(precise); return this->persist(obj); } @@ -55,6 +57,7 @@ void InspectorPanel::applyConfig(void) { this->setInspectorClass(this->panelConfig->inspectorClass); + this->setPrecise(this->panelConfig->precise); } void @@ -71,6 +74,12 @@ InspectorPanel::connectAll(void) SIGNAL(clicked(bool)), this, SLOT(onOpenInspector(void))); + + connect( + this->ui->preciseCheck, + SIGNAL(stateChanged(int)), + this, + SLOT(onPreciseChanged(void))); } void @@ -108,6 +117,12 @@ InspectorPanel::setBandwidth(unsigned int freq) this->ui->bandwidthSpin->setValue(static_cast(freq)); } +void +InspectorPanel::setPrecise(bool precise) +{ + this->ui->preciseCheck->setChecked(precise); +} + void InspectorPanel::setState(enum State state) { @@ -123,6 +138,12 @@ InspectorPanel::getState(void) const return this->state; } +bool +InspectorPanel::getPrecise(void) const +{ + return this->ui->preciseCheck->isChecked(); +} + void InspectorPanel::setInspectorClass(std::string const &cls) { @@ -183,3 +204,9 @@ InspectorPanel::onBandwidthChanged(int bw) /* this->mainWindow->mainSpectrum->setHiLowCutFrequencies(-bw / 2, bw / 2); */ emit bandwidthChanged(bw); } + +void +InspectorPanel::onPreciseChanged(void) +{ + this->panelConfig->precise = this->ui->preciseCheck->isChecked(); +} diff --git a/Inspector/Inspector.cpp b/Inspector/Inspector.cpp index 904c5876..30837648 100644 --- a/Inspector/Inspector.cpp +++ b/Inspector/Inspector.cpp @@ -34,6 +34,10 @@ Inspector::Inspector( this->ui = std::make_unique(this, &this->config); this->ui->setColors(config); + this->ui->setBasebandRate(msg.getBasebandRate()); + this->ui->setSampleRate(msg.getEquivSampleRate()); + this->ui->setBandwidth(static_cast(msg.getBandwidth())); + this->ui->setLo(static_cast(msg.getLo())); this->connect( this->ui.get(), @@ -47,6 +51,18 @@ Inspector::Inspector( this, SLOT(onSetSpectrumSource(unsigned int))); + this->connect( + this->ui.get(), + SIGNAL(loChanged(void)), + this, + SLOT(onLoChanged(void))); + + this->connect( + this->ui.get(), + SIGNAL(bandwidthChanged(void)), + this, + SLOT(onBandwidthChanged(void))); + for (auto p = msg.getSpectrumSources().begin(); p != msg.getSpectrumSources().end(); ++p) @@ -108,3 +124,23 @@ Inspector::onSetSpectrumSource(unsigned int index) index, static_cast(rand())); } + +void +Inspector::onLoChanged(void) +{ + if (this->analyzer != nullptr) + this->analyzer->setInspectorFreq( + this->handle, + this->ui->getLo(), + 0); +} + +void +Inspector::onBandwidthChanged(void) +{ + if (this->analyzer != nullptr) + this->analyzer->setInspectorBandwidth( + this->handle, + this->ui->getBandwidth(), + 0); +} diff --git a/Inspector/InspectorUI.cpp b/Inspector/InspectorUI.cpp index 10758783..53730cae 100644 --- a/Inspector/InspectorUI.cpp +++ b/Inspector/InspectorUI.cpp @@ -197,6 +197,18 @@ InspectorUI::InspectorUI( this, SLOT(onResetSNR())); + this->connect( + this->ui->loLcd, + SIGNAL(valueChanged(void)), + this, + SLOT(onChangeLo(void))); + + this->connect( + this->ui->bwLcd, + SIGNAL(valueChanged(void)), + this, + SLOT(onChangeBandwidth(void))); + this->populate(); // Configure throttleable widgets @@ -222,6 +234,54 @@ InspectorUI::~InspectorUI() delete this->ui; } +void +InspectorUI::setBasebandRate(unsigned int rate) +{ + this->basebandSampleRate = rate; + this->ui->loLcd->setMin(-static_cast(rate) / 2); + this->ui->loLcd->setMax(static_cast(rate) / 2); +} + +void +InspectorUI::setSampleRate(float rate) +{ + this->sampleRate = rate; + this->ui->sampleRateLabel->setText( + "Sample rate: " + + QString::number(static_cast(rate)) + + " sps"); + this->ui->bwLcd->setMin(0); + this->ui->bwLcd->setMax(static_cast(rate)); +} + +void +InspectorUI::setBandwidth(unsigned int bandwidth) +{ + // More COBOL + this->ui->bwLcd->setValue( + static_cast(bandwidth * + static_cast(this->ui->bwLcd->getMax()) + / this->sampleRate)); +} + +void +InspectorUI::setLo(int lo) +{ + this->ui->loLcd->setValue(lo); +} + +unsigned int +InspectorUI::getBandwidth(void) const +{ + return static_cast(this->ui->bwLcd->getValue()); +} + +int +InspectorUI::getLo(void) const +{ + return static_cast(this->ui->loLcd->getValue()); +} + bool InspectorUI::setPalette(std::string const &str) { @@ -251,7 +311,6 @@ InspectorUI::addEstimator(Suscan::Estimator const &estimator) this->estimators.push_back(estimator); } - void InspectorUI::connectDataSaver() { @@ -530,6 +589,8 @@ InspectorUI::refreshUi(void) this->ui->snrButton->setEnabled(enabled); this->ui->snrResetButton->setEnabled(enabled); this->ui->recordButton->setEnabled(enabled); + this->ui->loLcd->setEnabled(enabled); + this->ui->bwLcd->setEnabled(enabled); this->saverUI->setEnabled(enabled && this->recordingRate != 0); } @@ -860,3 +921,15 @@ InspectorUI::onCommit(void) this->saverUI->setCaptureSize(this->dataSaver->getSize()); } +void +InspectorUI::onChangeLo(void) +{ + emit loChanged(); +} + +void +InspectorUI::onChangeBandwidth(void) +{ + emit bandwidthChanged(); +} + diff --git a/Suscan/Messages/InspectorMessage.cpp b/Suscan/Messages/InspectorMessage.cpp index e929f424..f151981e 100644 --- a/Suscan/Messages/InspectorMessage.cpp +++ b/Suscan/Messages/InspectorMessage.cpp @@ -78,6 +78,30 @@ InspectorMessage::getSpectrumRate(void) const return this->message->samp_rate; } +unsigned int +InspectorMessage::getBasebandRate(void) const +{ + return this->message->fs; +} + +SUFLOAT +InspectorMessage::getEquivSampleRate(void) const +{ + return this->message->equiv_fs; +} + +SUFLOAT +InspectorMessage::getBandwidth(void) const +{ + return this->message->bandwidth; +} + +SUFLOAT +InspectorMessage::getLo(void) const +{ + return this->message->lo; +} + enum suscan_analyzer_inspector_msgkind InspectorMessage::getKind(void) const { diff --git a/include/Inspector.h b/include/Inspector.h index 7acb9cb1..9a9d9677 100644 --- a/include/Inspector.h +++ b/include/Inspector.h @@ -62,6 +62,8 @@ namespace SigDigger { public slots: void onConfigChanged(void); void onSetSpectrumSource(unsigned int index); + void onLoChanged(void); + void onBandwidthChanged(void); }; } diff --git a/include/InspectorPanel.h b/include/InspectorPanel.h index 1dc80b1a..31786697 100644 --- a/include/InspectorPanel.h +++ b/include/InspectorPanel.h @@ -29,6 +29,7 @@ namespace SigDigger { class InspectorPanelConfig : public Suscan::Serializable { public: std::string inspectorClass = "psk"; + bool precise = false; // Overriden methods void deserialize(Suscan::Object const &conf) override; @@ -65,10 +66,12 @@ namespace SigDigger { void setDemodFrequency(qint64); void setBandwidthLimits(unsigned int min, unsigned int max); void setBandwidth(unsigned int freq); + void setPrecise(bool precise); void setState(enum State state); unsigned int getBandwidth(void) const; std::string getInspectorClass(void) const; + bool getPrecise(void) const; enum State getState(void) const; // Overriden methods @@ -78,10 +81,12 @@ namespace SigDigger { public slots: void onOpenInspector(void); void onBandwidthChanged(int); + void onPreciseChanged(void); signals: void bandwidthChanged(int); void requestOpenInspector(QString); + }; } diff --git a/include/InspectorUI.h b/include/InspectorUI.h index b47d7ea7..cb4495eb 100644 --- a/include/InspectorUI.h +++ b/include/InspectorUI.h @@ -51,6 +51,9 @@ namespace SigDigger { private: + unsigned int basebandSampleRate; + float sampleRate; + bool scrolling = false; bool demodulating = true; bool recording = false; @@ -110,6 +113,14 @@ namespace SigDigger { bool installDataSaver(void); void uninstallDataSaver(void); + void setBasebandRate(unsigned int); + void setSampleRate(float rate); + void setBandwidth(unsigned int bw); + void setLo(int lo); + + unsigned int getBandwidth(void) const; + int getLo(void) const; + enum State getState(void) const; public slots: @@ -129,6 +140,8 @@ namespace SigDigger { void onToggleSNR(void); void onResetSNR(void); void onToggleRecord(void); + void onChangeLo(void); + void onChangeBandwidth(void); // DataSaver slots void onSaveError(void); @@ -139,6 +152,8 @@ namespace SigDigger { signals: void configChanged(void); void setSpectrumSource(unsigned int index); + void loChanged(void); + void bandwidthChanged(void); }; } diff --git a/include/Suscan/Messages/InspectorMessage.h b/include/Suscan/Messages/InspectorMessage.h index a042b8d5..1c114194 100644 --- a/include/Suscan/Messages/InspectorMessage.h +++ b/include/Suscan/Messages/InspectorMessage.h @@ -47,6 +47,10 @@ namespace Suscan { SUFLOAT *getSpectrumData(void) const; SUSCOUNT getSpectrumLength(void) const; SUSCOUNT getSpectrumRate(void) const; + unsigned int getBasebandRate(void) const; + SUFLOAT getEquivSampleRate(void) const; + SUFLOAT getBandwidth(void) const; + SUFLOAT getLo(void) const; std::string getClass(void) const; std::vector const &getSpectrumSources(void) const; std::vector const &getEstimators(void) const; diff --git a/ui/Inspector.ui b/ui/Inspector.ui index d36b4cf3..a9850e88 100644 --- a/ui/Inspector.ui +++ b/ui/Inspector.ui @@ -6,7 +6,7 @@ 0 0 - 793 + 1125 802 @@ -32,67 +32,14 @@ 3 - - - - - 300 - 16777215 - - - - true - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - 0 - 0 - 107 - 788 - - - - - 16777215 - 16777215 - - - - - 3 - - - 3 - - - 3 - - - 3 - - - 0 - - - - - - 16777215 - 16777215 - - - - - - - - - + + + + 0 + 0 + + QFrame::StyledPanel @@ -198,6 +145,9 @@ font-family: Monospace; 120 + + 60 + @@ -259,7 +209,7 @@ font-family: Monospace; - + 0 @@ -663,6 +613,274 @@ font-family: Monospace; + + + + + 300 + 16777215 + + + + QToolBox::tab { + color: white; + font-weight: bold; + background: qlineargradient( x1:0 y1:0, x2:0 y2:1, stop:0 #808080, stop:1 black); + border-radius: 5px; + border: 1px solid transparent; +} + +QToolBox::tab:hover { + background: qlineargradient( x1:0 y1:0, x2:0 y2:1, stop:0 #a0a0a0, stop:1 black); + border-color: black; +} + + + + 0 + + + 1 + + + 0 + + + + + 0 + 0 + 300 + 734 + + + + 🠟 Channel properties + + + + 6 + + + 6 + + + 6 + + + 6 + + + 3 + + + + + Bandwidth (Hz) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Channel offset (Hz) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Sample rate: XXX + + + + + + + + 0 + 32 + + + + 0.900000000000000 + + + 0.300000000000000 + + + 0.600000000000000 + + + + 0 + 0 + 0 + + + + + 144 + 177 + 86 + + + + + + + + + 0 + 32 + + + + 0.900000000000000 + + + 0.300000000000000 + + + 0.600000000000000 + + + + 0 + 0 + 0 + + + + + 144 + 177 + 86 + + + + + + + + + + 0 + 0 + 300 + 734 + + + + 🠟Demodulator controls + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 300 + 16777215 + + + + QFrame::NoFrame + + + true + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + 0 + 0 + 300 + 734 + + + + + 16777215 + 16777215 + + + + + 3 + + + 3 + + + 3 + + + 3 + + + 0 + + + + + + 16777215 + 16777215 + + + + + + + + + + + + @@ -681,6 +899,11 @@ font-family: Monospace; QFrame
Histogram.h
+ + LCD + QFrame +
LCD.h
+
SymView QFrame diff --git a/ui/InspectorPanel.ui b/ui/InspectorPanel.ui index cbd73557..2ce86b15 100644 --- a/ui/InspectorPanel.ui +++ b/ui/InspectorPanel.ui @@ -6,8 +6,8 @@ 0 0 - 197 - 247 + 218 + 282 @@ -29,20 +29,10 @@ 3 - - - - false - - - Enable channel detector - - - - - - - Center frequency + + + + Hz @@ -60,14 +50,20 @@ - - - - Hz + + + + Qt::Vertical - + + + 20 + 1 + + + - + QFrame::Box @@ -135,7 +131,7 @@ - + background-color: #7fff7f; @@ -147,18 +143,29 @@ font-weight: bold; - - - - Qt::Vertical + + + + false - - - 20 - 1 - + + Enable channel detector - + + + + + + Center frequency + + + + + + + Precise channel centering + +