Skip to content

Commit

Permalink
Add channel parameter adjustment in inspector tab
Browse files Browse the repository at this point in the history
  • Loading branch information
BatchDrake committed Aug 16, 2019
1 parent 009b998 commit 5942e76
Show file tree
Hide file tree
Showing 11 changed files with 522 additions and 97 deletions.
11 changes: 10 additions & 1 deletion App/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
27 changes: 27 additions & 0 deletions Components/InspectorPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ void
InspectorPanelConfig::deserialize(Suscan::Object const &conf)
{
LOAD(inspectorClass);
LOAD(precise);
}

Suscan::Object &&
Expand All @@ -40,6 +41,7 @@ InspectorPanelConfig::serialize(void)
obj.setClass("InspectorPanelConfig");

STORE(inspectorClass);
STORE(precise);

return this->persist(obj);
}
Expand All @@ -55,6 +57,7 @@ void
InspectorPanel::applyConfig(void)
{
this->setInspectorClass(this->panelConfig->inspectorClass);
this->setPrecise(this->panelConfig->precise);
}

void
Expand All @@ -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
Expand Down Expand Up @@ -108,6 +117,12 @@ InspectorPanel::setBandwidth(unsigned int freq)
this->ui->bandwidthSpin->setValue(static_cast<int>(freq));
}

void
InspectorPanel::setPrecise(bool precise)
{
this->ui->preciseCheck->setChecked(precise);
}

void
InspectorPanel::setState(enum State state)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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();
}
36 changes: 36 additions & 0 deletions Inspector/Inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Inspector::Inspector(

this->ui = std::make_unique<InspectorUI>(this, &this->config);
this->ui->setColors(config);
this->ui->setBasebandRate(msg.getBasebandRate());
this->ui->setSampleRate(msg.getEquivSampleRate());
this->ui->setBandwidth(static_cast<unsigned int>(msg.getBandwidth()));
this->ui->setLo(static_cast<int>(msg.getLo()));

this->connect(
this->ui.get(),
Expand All @@ -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)
Expand Down Expand Up @@ -108,3 +124,23 @@ Inspector::onSetSpectrumSource(unsigned int index)
index,
static_cast<Suscan::RequestId>(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);
}
75 changes: 74 additions & 1 deletion Inspector/InspectorUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -222,6 +234,54 @@ InspectorUI::~InspectorUI()
delete this->ui;
}

void
InspectorUI::setBasebandRate(unsigned int rate)
{
this->basebandSampleRate = rate;
this->ui->loLcd->setMin(-static_cast<int>(rate) / 2);
this->ui->loLcd->setMax(static_cast<int>(rate) / 2);
}

void
InspectorUI::setSampleRate(float rate)
{
this->sampleRate = rate;
this->ui->sampleRateLabel->setText(
"Sample rate: "
+ QString::number(static_cast<qreal>(rate))
+ " sps");
this->ui->bwLcd->setMin(0);
this->ui->bwLcd->setMax(static_cast<qint64>(rate));
}

void
InspectorUI::setBandwidth(unsigned int bandwidth)
{
// More COBOL
this->ui->bwLcd->setValue(
static_cast<int>(bandwidth *
static_cast<unsigned int>(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<unsigned int>(this->ui->bwLcd->getValue());
}

int
InspectorUI::getLo(void) const
{
return static_cast<int>(this->ui->loLcd->getValue());
}

bool
InspectorUI::setPalette(std::string const &str)
{
Expand Down Expand Up @@ -251,7 +311,6 @@ InspectorUI::addEstimator(Suscan::Estimator const &estimator)
this->estimators.push_back(estimator);
}


void
InspectorUI::connectDataSaver()
{
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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();
}

24 changes: 24 additions & 0 deletions Suscan/Messages/InspectorMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions include/Inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ namespace SigDigger {
public slots:
void onConfigChanged(void);
void onSetSpectrumSource(unsigned int index);
void onLoChanged(void);
void onBandwidthChanged(void);
};
}

Expand Down
5 changes: 5 additions & 0 deletions include/InspectorPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -78,10 +81,12 @@ namespace SigDigger {
public slots:
void onOpenInspector(void);
void onBandwidthChanged(int);
void onPreciseChanged(void);

signals:
void bandwidthChanged(int);
void requestOpenInspector(QString);

};
}

Expand Down
15 changes: 15 additions & 0 deletions include/InspectorUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ namespace SigDigger {

private:

unsigned int basebandSampleRate;
float sampleRate;

bool scrolling = false;
bool demodulating = true;
bool recording = false;
Expand Down Expand Up @@ -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:
Expand All @@ -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);
Expand All @@ -139,6 +152,8 @@ namespace SigDigger {
signals:
void configChanged(void);
void setSpectrumSource(unsigned int index);
void loChanged(void);
void bandwidthChanged(void);
};
}

Expand Down
4 changes: 4 additions & 0 deletions include/Suscan/Messages/InspectorMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<SpectrumSource> const &getSpectrumSources(void) const;
std::vector<Estimator> const &getEstimators(void) const;
Expand Down
Loading

0 comments on commit 5942e76

Please sign in to comment.