2015-12-06 13:47:55 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2015 F4EXB //
|
|
|
|
// written by Edouard Griffiths //
|
|
|
|
// //
|
|
|
|
// This program 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 as version 3 of the License, or //
|
2019-04-11 00:39:30 -04:00
|
|
|
// (at your option) any later version. //
|
2015-12-06 13:47:55 -05:00
|
|
|
// //
|
|
|
|
// 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 General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-10-31 03:24:05 -04:00
|
|
|
#include "device/deviceuiset.h"
|
2015-11-18 21:27:37 -05:00
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "dsp/spectrumvis.h"
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "util/db.h"
|
2017-08-25 06:12:46 -04:00
|
|
|
#include "gui/basicchannelsettingsdialog.h"
|
2019-09-22 19:25:17 -04:00
|
|
|
#include "gui/devicestreamselectiondialog.h"
|
2018-09-11 18:08:47 -04:00
|
|
|
#include "ui_udpsinkgui.h"
|
2020-10-12 15:59:04 -04:00
|
|
|
#include "maincore.h"
|
2016-10-02 07:18:07 -04:00
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
#include "udpsink.h"
|
|
|
|
#include "udpsinkgui.h"
|
2015-11-18 21:27:37 -05:00
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
UDPSinkGUI* UDPSinkGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2018-09-11 18:08:47 -04:00
|
|
|
UDPSinkGUI* gui = new UDPSinkGUI(pluginAPI, deviceUISet, rxChannel);
|
2015-11-18 21:27:37 -05:00
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::destroy()
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::resetToDefaults()
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2017-10-05 02:38:06 -04:00
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
|
|
|
applySettingsImmediate(true);
|
|
|
|
applySettings(true);
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
QByteArray UDPSinkGUI::serialize() const
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2017-10-05 02:38:06 -04:00
|
|
|
return m_settings.serialize();
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
bool UDPSinkGUI::deserialize(const QByteArray& data)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2017-10-05 02:38:06 -04:00
|
|
|
if(m_settings.deserialize(data))
|
|
|
|
{
|
|
|
|
displaySettings();
|
|
|
|
applySettingsImmediate(true);
|
|
|
|
applySettings(true);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
bool UDPSinkGUI::handleMessage(const Message& message )
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
if (UDPSink::MsgConfigureUDPSink::match(message))
|
2018-05-25 12:44:24 -04:00
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
const UDPSink::MsgConfigureUDPSink& cfg = (UDPSink::MsgConfigureUDPSink&) message;
|
2018-05-25 12:44:24 -04:00
|
|
|
m_settings = cfg.getSettings();
|
|
|
|
blockApplySettings(true);
|
|
|
|
displaySettings();
|
|
|
|
blockApplySettings(false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::handleSourceMessages()
|
2018-05-25 12:44:24 -04:00
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
|
|
|
while ((message = getInputMessageQueue()->pop()) != 0)
|
|
|
|
{
|
|
|
|
if (handleMessage(*message))
|
|
|
|
{
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::channelMarkerChangedByCursor()
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2017-11-14 02:35:18 -05:00
|
|
|
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
|
|
|
applySettingsImmediate();
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::channelMarkerHighlightedByCursor()
|
2017-11-14 16:58:35 -05:00
|
|
|
{
|
|
|
|
setHighlighted(m_channelMarker.getHighlighted());
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::tick()
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2017-08-17 06:57:45 -04:00
|
|
|
if (m_tickCount % 4 == 0)
|
|
|
|
{
|
2017-08-19 21:47:21 -04:00
|
|
|
// m_channelPowerAvg.feed(m_udpSrc->getMagSq());
|
|
|
|
// double powDb = CalcDb::dbPower(m_channelPowerAvg.average());
|
2018-09-11 18:08:47 -04:00
|
|
|
double powDb = CalcDb::dbPower(m_udpSink->getMagSq());
|
2017-08-17 06:57:45 -04:00
|
|
|
ui->channelPower->setText(QString::number(powDb, 'f', 1));
|
2018-09-11 18:08:47 -04:00
|
|
|
m_inPowerAvg.feed(m_udpSink->getInMagSq());
|
2017-08-17 14:23:17 -04:00
|
|
|
double inPowDb = CalcDb::dbPower(m_inPowerAvg.average());
|
|
|
|
ui->inputPower->setText(QString::number(inPowDb, 'f', 1));
|
2017-08-17 06:57:45 -04:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
if (m_udpSink->getSquelchOpen()) {
|
2017-08-17 18:10:15 -04:00
|
|
|
ui->squelchLabel->setStyleSheet("QLabel { background-color : green; }");
|
|
|
|
} else {
|
|
|
|
ui->squelchLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
|
|
|
|
}
|
|
|
|
|
2017-08-17 06:57:45 -04:00
|
|
|
m_tickCount++;
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget* parent) :
|
2020-10-04 00:16:15 -04:00
|
|
|
ChannelGUI(parent),
|
2018-09-11 18:08:47 -04:00
|
|
|
ui(new Ui::UDPSinkGUI),
|
2015-11-18 21:27:37 -05:00
|
|
|
m_pluginAPI(pluginAPI),
|
2017-10-31 03:24:05 -04:00
|
|
|
m_deviceUISet(deviceUISet),
|
2018-09-11 18:08:47 -04:00
|
|
|
m_udpSink(0),
|
2015-11-18 21:27:37 -05:00
|
|
|
m_channelMarker(this),
|
2017-08-17 06:57:45 -04:00
|
|
|
m_channelPowerAvg(4, 1e-10),
|
2017-08-17 14:23:17 -04:00
|
|
|
m_inPowerAvg(4, 1e-10),
|
2017-08-17 06:57:45 -04:00
|
|
|
m_tickCount(0),
|
2017-10-06 23:44:43 -04:00
|
|
|
m_doApplySettings(true),
|
|
|
|
m_rfBandwidthChanged(false)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
2017-08-25 06:12:46 -04:00
|
|
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
|
2015-11-18 21:27:37 -05:00
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
|
2020-10-14 16:07:48 -04:00
|
|
|
m_udpSink = (UDPSink*) rxChannel;
|
2020-04-30 03:57:05 -04:00
|
|
|
m_spectrumVis = m_udpSink->getSpectrumVis();
|
|
|
|
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
|
2018-09-11 18:08:47 -04:00
|
|
|
m_udpSink->setMessageQueueToGUI(getInputMessageQueue());
|
2015-11-18 21:27:37 -05:00
|
|
|
|
2016-04-04 10:44:50 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
|
2017-05-17 18:05:08 -04:00
|
|
|
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
|
|
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
2020-07-01 07:14:48 -04:00
|
|
|
ui->deltaFrequency->setValueRange(false, 8, -99999999, 99999999);
|
2017-08-17 18:10:15 -04:00
|
|
|
ui->squelchLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
|
2015-11-18 21:27:37 -05:00
|
|
|
|
|
|
|
ui->glSpectrum->setCenterFrequency(0);
|
|
|
|
ui->glSpectrum->setSampleRate(ui->sampleRate->text().toInt());
|
|
|
|
ui->glSpectrum->setDisplayWaterfall(true);
|
|
|
|
ui->glSpectrum->setDisplayMaxHold(true);
|
|
|
|
|
2020-10-12 15:59:04 -04:00
|
|
|
ui->glSpectrum->connectTimer(MainCore::instance()->getMasterTimer());
|
|
|
|
connect(&MainCore::instance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
|
2015-11-18 21:27:37 -05:00
|
|
|
|
2017-11-14 02:35:18 -05:00
|
|
|
m_channelMarker.blockSignals(true);
|
2015-11-18 21:27:37 -05:00
|
|
|
m_channelMarker.setBandwidth(16000);
|
|
|
|
m_channelMarker.setCenterFrequency(0);
|
2017-08-25 06:12:46 -04:00
|
|
|
m_channelMarker.setTitle("UDP Sample Source");
|
2017-10-05 16:11:57 -04:00
|
|
|
m_channelMarker.setColor(m_settings.m_rgbColor);
|
2017-11-14 02:35:18 -05:00
|
|
|
m_channelMarker.blockSignals(false);
|
|
|
|
m_channelMarker.setVisible(true); // activate signal on the last setting only
|
|
|
|
|
|
|
|
setTitleColor(m_channelMarker.getColor());
|
2016-05-16 13:37:53 -04:00
|
|
|
|
2017-10-05 02:17:49 -04:00
|
|
|
m_settings.setChannelMarker(&m_channelMarker);
|
|
|
|
m_settings.setSpectrumGUI(ui->spectrumGUI);
|
|
|
|
|
2017-10-31 03:24:05 -04:00
|
|
|
m_deviceUISet->addChannelMarker(&m_channelMarker);
|
|
|
|
m_deviceUISet->addRollupWidget(this);
|
2015-11-18 21:27:37 -05:00
|
|
|
|
2017-11-14 02:35:18 -05:00
|
|
|
connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor()));
|
2017-11-14 16:58:35 -05:00
|
|
|
connect(&m_channelMarker, SIGNAL(highlightedByCursor()), this, SLOT(channelMarkerHighlightedByCursor()));
|
2018-05-25 12:44:24 -04:00
|
|
|
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
|
2017-11-14 02:35:18 -05:00
|
|
|
|
2020-04-30 20:33:50 -04:00
|
|
|
ui->spectrumGUI->setBuddies(m_spectrumVis, ui->glSpectrum);
|
2015-11-18 21:27:37 -05:00
|
|
|
|
2017-08-17 06:57:45 -04:00
|
|
|
displaySettings();
|
2017-08-18 18:12:56 -04:00
|
|
|
applySettingsImmediate(true);
|
|
|
|
applySettings(true);
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
UDPSinkGUI::~UDPSinkGUI()
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::blockApplySettings(bool block)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
|
|
|
m_doApplySettings = !block;
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::displaySettings()
|
2017-08-17 06:57:45 -04:00
|
|
|
{
|
2017-10-05 02:38:06 -04:00
|
|
|
m_channelMarker.blockSignals(true);
|
|
|
|
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
|
2017-11-14 02:35:18 -05:00
|
|
|
m_channelMarker.setBandwidth(m_settings.m_rfBandwidth);
|
2017-11-19 12:18:17 -05:00
|
|
|
m_channelMarker.setTitle(m_settings.m_title);
|
2017-10-05 02:38:06 -04:00
|
|
|
m_channelMarker.blockSignals(false);
|
2017-11-14 02:35:18 -05:00
|
|
|
m_channelMarker.setColor(m_settings.m_rgbColor); // activate signal on the last setting only
|
2017-10-05 02:38:06 -04:00
|
|
|
|
2017-11-14 02:35:18 -05:00
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
2017-10-11 19:21:30 -04:00
|
|
|
setWindowTitle(m_channelMarker.getTitle());
|
|
|
|
|
2018-04-19 17:03:21 -04:00
|
|
|
blockApplySettings(true);
|
|
|
|
|
2017-10-05 02:38:06 -04:00
|
|
|
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
2017-11-14 02:35:18 -05:00
|
|
|
|
2017-10-05 02:38:06 -04:00
|
|
|
ui->sampleRate->setText(QString("%1").arg(m_settings.m_outputSampleRate, 0));
|
2017-10-06 23:44:43 -04:00
|
|
|
setSampleFormatIndex(m_settings.m_sampleFormat);
|
|
|
|
|
2018-04-19 17:03:21 -04:00
|
|
|
ui->outputUDPAddress->setText(m_settings.m_udpAddress);
|
|
|
|
ui->outputUDPPort->setText(tr("%1").arg(m_settings.m_udpPort));
|
|
|
|
ui->inputUDPAudioPort->setText(tr("%1").arg(m_settings.m_audioPort));
|
|
|
|
|
2017-10-06 23:44:43 -04:00
|
|
|
ui->squelch->setValue(m_settings.m_squelchdB);
|
|
|
|
ui->squelchText->setText(tr("%1").arg(ui->squelch->value()*1.0, 0, 'f', 0));
|
|
|
|
|
2018-09-11 18:36:30 -04:00
|
|
|
qDebug("UDPSinkGUI::deserialize: m_squelchGate: %d", m_settings.m_squelchGate);
|
2017-10-06 23:44:43 -04:00
|
|
|
ui->squelchGate->setValue(m_settings.m_squelchGate);
|
|
|
|
ui->squelchGateText->setText(tr("%1").arg(m_settings.m_squelchGate*10.0, 0, 'f', 0));
|
|
|
|
|
|
|
|
ui->rfBandwidth->setText(QString("%1").arg(m_settings.m_rfBandwidth, 0));
|
|
|
|
ui->fmDeviation->setText(QString("%1").arg(m_settings.m_fmDeviation, 0));
|
2017-10-05 02:38:06 -04:00
|
|
|
|
2017-10-06 23:44:43 -04:00
|
|
|
ui->agc->setChecked(m_settings.m_agc);
|
|
|
|
ui->audioActive->setChecked(m_settings.m_audioActive);
|
|
|
|
ui->audioStereo->setChecked(m_settings.m_audioStereo);
|
|
|
|
|
|
|
|
ui->volume->setValue(m_settings.m_volume);
|
|
|
|
ui->volumeText->setText(QString("%1").arg(ui->volume->value()));
|
|
|
|
|
|
|
|
ui->gain->setValue(m_settings.m_gain*10.0);
|
|
|
|
ui->gainText->setText(tr("%1").arg(ui->gain->value()/10.0, 0, 'f', 1));
|
|
|
|
|
2018-04-19 17:03:21 -04:00
|
|
|
ui->applyBtn->setEnabled(false);
|
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background:rgb(79,79,79); }");
|
|
|
|
|
2019-09-22 19:25:17 -04:00
|
|
|
displayStreamIndex();
|
|
|
|
|
2018-04-19 17:03:21 -04:00
|
|
|
blockApplySettings(false);
|
|
|
|
|
2017-10-06 23:44:43 -04:00
|
|
|
ui->glSpectrum->setSampleRate(m_settings.m_outputSampleRate);
|
|
|
|
}
|
|
|
|
|
2019-09-22 19:25:17 -04:00
|
|
|
void UDPSinkGUI::displayStreamIndex()
|
|
|
|
{
|
|
|
|
if (m_deviceUISet->m_deviceMIMOEngine) {
|
|
|
|
setStreamIndicator(tr("%1").arg(m_settings.m_streamIndex));
|
|
|
|
} else {
|
|
|
|
setStreamIndicator("S"); // single channel indicator
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::setSampleFormatIndex(const UDPSinkSettings::SampleFormat& sampleFormat)
|
2017-10-06 23:44:43 -04:00
|
|
|
{
|
|
|
|
switch(sampleFormat)
|
2017-10-05 02:38:06 -04:00
|
|
|
{
|
2018-09-11 18:08:47 -04:00
|
|
|
case UDPSinkSettings::FormatIQ16:
|
2017-10-05 02:38:06 -04:00
|
|
|
ui->sampleFormat->setCurrentIndex(0);
|
|
|
|
break;
|
2018-09-11 18:08:47 -04:00
|
|
|
case UDPSinkSettings::FormatIQ24:
|
2017-10-05 02:38:06 -04:00
|
|
|
ui->sampleFormat->setCurrentIndex(1);
|
|
|
|
break;
|
2018-09-11 18:08:47 -04:00
|
|
|
case UDPSinkSettings::FormatNFM:
|
2017-10-05 02:38:06 -04:00
|
|
|
ui->sampleFormat->setCurrentIndex(2);
|
|
|
|
break;
|
2018-09-11 18:08:47 -04:00
|
|
|
case UDPSinkSettings::FormatNFMMono:
|
2017-10-05 02:38:06 -04:00
|
|
|
ui->sampleFormat->setCurrentIndex(3);
|
|
|
|
break;
|
2018-09-11 18:08:47 -04:00
|
|
|
case UDPSinkSettings::FormatLSB:
|
2017-10-05 02:38:06 -04:00
|
|
|
ui->sampleFormat->setCurrentIndex(4);
|
|
|
|
break;
|
2018-09-11 18:08:47 -04:00
|
|
|
case UDPSinkSettings::FormatUSB:
|
2017-10-05 02:38:06 -04:00
|
|
|
ui->sampleFormat->setCurrentIndex(5);
|
|
|
|
break;
|
2018-09-11 18:08:47 -04:00
|
|
|
case UDPSinkSettings::FormatLSBMono:
|
2017-10-05 02:38:06 -04:00
|
|
|
ui->sampleFormat->setCurrentIndex(6);
|
|
|
|
break;
|
2018-09-11 18:08:47 -04:00
|
|
|
case UDPSinkSettings::FormatUSBMono:
|
2017-10-05 02:38:06 -04:00
|
|
|
ui->sampleFormat->setCurrentIndex(7);
|
|
|
|
break;
|
2018-09-11 18:08:47 -04:00
|
|
|
case UDPSinkSettings::FormatAMMono:
|
2017-10-05 02:38:06 -04:00
|
|
|
ui->sampleFormat->setCurrentIndex(8);
|
|
|
|
break;
|
2018-09-11 18:08:47 -04:00
|
|
|
case UDPSinkSettings::FormatAMNoDCMono:
|
2017-10-05 02:38:06 -04:00
|
|
|
ui->sampleFormat->setCurrentIndex(9);
|
|
|
|
break;
|
2018-09-11 18:08:47 -04:00
|
|
|
case UDPSinkSettings::FormatAMBPFMono:
|
2018-04-19 07:34:22 -04:00
|
|
|
ui->sampleFormat->setCurrentIndex(10);
|
|
|
|
break;
|
2017-10-05 02:38:06 -04:00
|
|
|
default:
|
|
|
|
ui->sampleFormat->setCurrentIndex(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::setSampleFormat(int index)
|
2017-10-05 02:38:06 -04:00
|
|
|
{
|
2017-10-06 23:44:43 -04:00
|
|
|
switch(index)
|
|
|
|
{
|
|
|
|
case 0:
|
2018-09-11 18:08:47 -04:00
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatIQ16;
|
2017-10-06 23:44:43 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
break;
|
|
|
|
case 1:
|
2018-09-11 18:08:47 -04:00
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatIQ24;
|
2018-04-19 07:34:22 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
break;
|
|
|
|
case 2:
|
2018-09-11 18:08:47 -04:00
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatNFM;
|
2017-10-06 23:44:43 -04:00
|
|
|
ui->fmDeviation->setEnabled(true);
|
|
|
|
break;
|
2018-04-19 07:34:22 -04:00
|
|
|
case 3:
|
2018-09-11 18:08:47 -04:00
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatNFMMono;
|
2017-10-06 23:44:43 -04:00
|
|
|
ui->fmDeviation->setEnabled(true);
|
|
|
|
break;
|
2018-04-19 07:34:22 -04:00
|
|
|
case 4:
|
2018-09-11 18:08:47 -04:00
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatLSB;
|
2017-10-06 23:44:43 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
break;
|
2018-04-19 07:34:22 -04:00
|
|
|
case 5:
|
2018-09-11 18:08:47 -04:00
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatUSB;
|
2017-10-06 23:44:43 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
break;
|
2018-04-19 07:34:22 -04:00
|
|
|
case 6:
|
2018-09-11 18:08:47 -04:00
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatLSBMono;
|
2017-10-06 23:44:43 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
break;
|
2018-04-19 07:34:22 -04:00
|
|
|
case 7:
|
2018-09-11 18:08:47 -04:00
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatUSBMono;
|
2017-10-06 23:44:43 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
break;
|
2018-04-19 07:34:22 -04:00
|
|
|
case 8:
|
2018-09-11 18:08:47 -04:00
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatAMMono;
|
2017-10-06 23:44:43 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
break;
|
2018-04-19 07:34:22 -04:00
|
|
|
case 9:
|
2018-09-11 18:08:47 -04:00
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatAMNoDCMono;
|
2017-10-06 23:44:43 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
break;
|
2018-04-19 07:34:22 -04:00
|
|
|
case 10:
|
2018-09-11 18:08:47 -04:00
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatAMBPFMono;
|
2017-10-06 23:44:43 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
break;
|
|
|
|
default:
|
2018-09-11 18:08:47 -04:00
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatIQ16;
|
2017-10-06 23:44:43 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
break;
|
|
|
|
}
|
2017-08-17 06:57:45 -04:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::applySettingsImmediate(bool force)
|
2015-12-03 21:46:51 -05:00
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
UDPSink::MsgConfigureUDPSink* message = UDPSink::MsgConfigureUDPSink::create( m_settings, force);
|
2018-09-11 18:08:47 -04:00
|
|
|
m_udpSink->getInputMessageQueue()->push(message);
|
2015-12-03 21:46:51 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::applySettings(bool force)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
UDPSink::MsgConfigureUDPSink* message = UDPSink::MsgConfigureUDPSink::create( m_settings, force);
|
2018-09-11 18:08:47 -04:00
|
|
|
m_udpSink->getInputMessageQueue()->push(message);
|
2017-10-06 23:44:43 -04:00
|
|
|
|
2015-11-18 21:27:37 -05:00
|
|
|
ui->applyBtn->setEnabled(false);
|
2017-08-18 21:45:17 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background:rgb(79,79,79); }");
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::on_deltaFrequency_changed(qint64 value)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2017-05-17 18:05:08 -04:00
|
|
|
m_channelMarker.setCenterFrequency(value);
|
2017-10-06 23:44:43 -04:00
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
|
|
|
applySettings();
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::on_sampleFormat_currentIndexChanged(int index)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2016-04-05 11:02:24 -04:00
|
|
|
if ((index == 1) || (index == 2)) {
|
2016-04-04 10:44:50 -04:00
|
|
|
ui->fmDeviation->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
2017-10-06 23:44:43 -04:00
|
|
|
setSampleFormat(index);
|
|
|
|
|
2015-11-18 21:27:37 -05:00
|
|
|
ui->applyBtn->setEnabled(true);
|
2017-08-18 21:45:17 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2018-04-19 17:03:21 -04:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::on_outputUDPAddress_editingFinished()
|
2018-04-19 17:03:21 -04:00
|
|
|
{
|
|
|
|
m_settings.m_udpAddress = ui->outputUDPAddress->text();
|
|
|
|
ui->applyBtn->setEnabled(true);
|
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::on_outputUDPPort_editingFinished()
|
2018-04-19 17:03:21 -04:00
|
|
|
{
|
|
|
|
bool ok;
|
|
|
|
quint16 udpPort = ui->outputUDPPort->text().toInt(&ok);
|
|
|
|
|
|
|
|
if((!ok) || (udpPort < 1024)) {
|
|
|
|
udpPort = 9998;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_settings.m_udpPort = udpPort;
|
|
|
|
ui->outputUDPPort->setText(tr("%1").arg(m_settings.m_udpPort));
|
|
|
|
|
|
|
|
ui->applyBtn->setEnabled(true);
|
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::on_inputUDPAudioPort_editingFinished()
|
2018-04-19 17:03:21 -04:00
|
|
|
{
|
|
|
|
bool ok;
|
|
|
|
quint16 udpPort = ui->inputUDPAudioPort->text().toInt(&ok);
|
|
|
|
|
|
|
|
if((!ok) || (udpPort < 1024)) {
|
|
|
|
udpPort = 9997;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_settings.m_audioPort = udpPort;
|
|
|
|
ui->inputUDPAudioPort->setText(tr("%1").arg(m_settings.m_audioPort));
|
|
|
|
|
|
|
|
ui->applyBtn->setEnabled(true);
|
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2018-01-27 20:30:15 -05:00
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void UDPSinkGUI::on_sampleRate_textEdited(const QString& arg1)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) arg1;
|
2017-10-06 23:44:43 -04:00
|
|
|
bool ok;
|
|
|
|
Real outputSampleRate = ui->sampleRate->text().toDouble(&ok);
|
|
|
|
|
|
|
|
if((!ok) || (outputSampleRate < 1000))
|
|
|
|
{
|
|
|
|
m_settings.m_outputSampleRate = 48000;
|
|
|
|
ui->sampleRate->setText(QString("%1").arg(outputSampleRate, 0));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_settings.m_outputSampleRate = outputSampleRate;
|
|
|
|
}
|
|
|
|
|
2015-11-18 21:27:37 -05:00
|
|
|
ui->applyBtn->setEnabled(true);
|
2017-08-18 21:45:17 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void UDPSinkGUI::on_rfBandwidth_textEdited(const QString& arg1)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) arg1;
|
2017-10-06 23:44:43 -04:00
|
|
|
bool ok;
|
|
|
|
Real rfBandwidth = ui->rfBandwidth->text().toDouble(&ok);
|
2015-11-18 21:27:37 -05:00
|
|
|
|
2017-11-21 16:46:39 -05:00
|
|
|
if ((!ok) || (rfBandwidth > m_settings.m_outputSampleRate))
|
2017-10-06 23:44:43 -04:00
|
|
|
{
|
|
|
|
m_settings.m_rfBandwidth = m_settings.m_outputSampleRate;
|
|
|
|
ui->rfBandwidth->setText(QString("%1").arg(m_settings.m_rfBandwidth, 0));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_settings.m_rfBandwidth = rfBandwidth;
|
|
|
|
}
|
2016-04-03 21:44:06 -04:00
|
|
|
|
2017-10-06 23:44:43 -04:00
|
|
|
m_rfBandwidthChanged = true;
|
2016-02-24 18:55:05 -05:00
|
|
|
|
2015-11-18 21:27:37 -05:00
|
|
|
ui->applyBtn->setEnabled(true);
|
2017-08-18 21:45:17 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void UDPSinkGUI::on_fmDeviation_textEdited(const QString& arg1)
|
2015-12-04 22:03:30 -05:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) arg1;
|
2017-10-06 23:44:43 -04:00
|
|
|
bool ok;
|
|
|
|
int fmDeviation = ui->fmDeviation->text().toInt(&ok);
|
|
|
|
|
|
|
|
if ((!ok) || (fmDeviation < 1))
|
|
|
|
{
|
|
|
|
m_settings.m_fmDeviation = 2500;
|
|
|
|
ui->fmDeviation->setText(QString("%1").arg(m_settings.m_fmDeviation));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_settings.m_fmDeviation = fmDeviation;
|
|
|
|
}
|
|
|
|
|
2015-12-04 22:03:30 -05:00
|
|
|
ui->applyBtn->setEnabled(true);
|
2017-08-18 21:45:17 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2015-12-04 22:03:30 -05:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::on_applyBtn_clicked()
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2017-10-06 23:44:43 -04:00
|
|
|
if (m_rfBandwidthChanged)
|
|
|
|
{
|
|
|
|
m_channelMarker.setBandwidth((int) m_settings.m_rfBandwidth);
|
|
|
|
m_rfBandwidthChanged = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->glSpectrum->setSampleRate(m_settings.m_outputSampleRate);
|
|
|
|
|
2015-11-18 21:27:37 -05:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::on_audioActive_toggled(bool active)
|
2015-12-03 21:46:51 -05:00
|
|
|
{
|
2017-10-06 23:44:43 -04:00
|
|
|
m_settings.m_audioActive = active;
|
2015-12-05 06:03:26 -05:00
|
|
|
applySettingsImmediate();
|
2015-12-03 21:46:51 -05:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::on_audioStereo_toggled(bool stereo)
|
2015-12-05 06:23:55 -05:00
|
|
|
{
|
2017-10-06 23:44:43 -04:00
|
|
|
m_settings.m_audioStereo = stereo;
|
2015-12-05 06:23:55 -05:00
|
|
|
applySettingsImmediate();
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::on_agc_toggled(bool agc)
|
2017-08-19 18:32:40 -04:00
|
|
|
{
|
2017-10-06 23:44:43 -04:00
|
|
|
m_settings.m_agc = agc;
|
2017-08-19 18:32:40 -04:00
|
|
|
applySettingsImmediate();
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::on_gain_valueChanged(int value)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2017-10-06 23:44:43 -04:00
|
|
|
m_settings.m_gain = value / 10.0;
|
2017-08-17 06:57:45 -04:00
|
|
|
ui->gainText->setText(tr("%1").arg(value/10.0, 0, 'f', 1));
|
2015-12-03 21:46:51 -05:00
|
|
|
applySettingsImmediate();
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::on_volume_valueChanged(int value)
|
2015-12-03 21:46:51 -05:00
|
|
|
{
|
2017-10-06 23:44:43 -04:00
|
|
|
m_settings.m_volume = value;
|
2015-12-03 21:46:51 -05:00
|
|
|
ui->volumeText->setText(QString("%1").arg(value));
|
|
|
|
applySettingsImmediate();
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::on_squelch_valueChanged(int value)
|
2017-08-17 14:23:17 -04:00
|
|
|
{
|
2017-10-06 23:44:43 -04:00
|
|
|
m_settings.m_squelchdB = value;
|
|
|
|
|
2017-08-17 14:23:17 -04:00
|
|
|
if (value == -100) // means disabled
|
|
|
|
{
|
|
|
|
ui->squelchText->setText("---");
|
2017-10-06 23:44:43 -04:00
|
|
|
m_settings.m_squelchEnabled = false;
|
2017-08-17 14:23:17 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->squelchText->setText(tr("%1").arg(value*1.0, 0, 'f', 0));
|
2017-10-06 23:44:43 -04:00
|
|
|
m_settings.m_squelchEnabled = true;
|
2017-08-17 14:23:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
applySettingsImmediate();
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::on_squelchGate_valueChanged(int value)
|
2017-08-18 18:12:56 -04:00
|
|
|
{
|
2017-10-06 23:44:43 -04:00
|
|
|
m_settings.m_squelchGate = value;
|
2017-08-18 18:12:56 -04:00
|
|
|
ui->squelchGateText->setText(tr("%1").arg(value*10.0, 0, 'f', 0));
|
|
|
|
applySettingsImmediate();
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::onWidgetRolled(QWidget* widget, bool rollDown)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
if ((widget == ui->spectrumBox) && (m_udpSink)) {
|
|
|
|
m_udpSink->enableSpectrum(rollDown);
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::onMenuDialogCalled(const QPoint &p)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2019-05-09 15:07:05 -04:00
|
|
|
if (m_contextMenuType == ContextMenuChannelSettings)
|
|
|
|
{
|
|
|
|
BasicChannelSettingsDialog dialog(&m_channelMarker, this);
|
|
|
|
dialog.setUseReverseAPI(m_settings.m_useReverseAPI);
|
|
|
|
dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress);
|
|
|
|
dialog.setReverseAPIPort(m_settings.m_reverseAPIPort);
|
|
|
|
dialog.setReverseAPIDeviceIndex(m_settings.m_reverseAPIDeviceIndex);
|
|
|
|
dialog.setReverseAPIChannelIndex(m_settings.m_reverseAPIChannelIndex);
|
|
|
|
|
|
|
|
dialog.move(p);
|
|
|
|
dialog.exec();
|
|
|
|
|
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
|
|
|
m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
|
|
|
|
m_settings.m_title = m_channelMarker.getTitle();
|
|
|
|
m_settings.m_useReverseAPI = dialog.useReverseAPI();
|
|
|
|
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
|
|
|
|
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
|
|
|
|
m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex();
|
|
|
|
m_settings.m_reverseAPIChannelIndex = dialog.getReverseAPIChannelIndex();
|
|
|
|
|
|
|
|
setWindowTitle(m_settings.m_title);
|
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
|
|
|
|
|
|
|
applySettingsImmediate();
|
|
|
|
}
|
2019-09-22 19:25:17 -04:00
|
|
|
else if ((m_contextMenuType == ContextMenuStreamSettings) && (m_deviceUISet->m_deviceMIMOEngine))
|
|
|
|
{
|
|
|
|
DeviceStreamSelectionDialog dialog(this);
|
|
|
|
dialog.setNumberOfStreams(m_udpSink->getNumberOfDeviceStreams());
|
|
|
|
dialog.setStreamIndex(m_settings.m_streamIndex);
|
|
|
|
dialog.move(p);
|
|
|
|
dialog.exec();
|
|
|
|
|
|
|
|
m_settings.m_streamIndex = dialog.getSelectedStreamIndex();
|
|
|
|
m_channelMarker.clearStreamIndexes();
|
|
|
|
m_channelMarker.addStreamIndex(m_settings.m_streamIndex);
|
|
|
|
displayStreamIndex();
|
|
|
|
applySettings();
|
|
|
|
}
|
2017-11-14 02:35:18 -05:00
|
|
|
|
2019-05-09 15:07:05 -04:00
|
|
|
resetContextMenuType();
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
2016-04-03 12:14:04 -04:00
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::leaveEvent(QEvent*)
|
2016-04-03 12:14:04 -04:00
|
|
|
{
|
|
|
|
m_channelMarker.setHighlighted(false);
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSinkGUI::enterEvent(QEvent*)
|
2016-04-03 12:14:04 -04:00
|
|
|
{
|
|
|
|
m_channelMarker.setHighlighted(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|