mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 17:58:43 -05:00
TCP source: GUI and source separation phase 1
This commit is contained in:
parent
6e7deef7e0
commit
d3fc8396dd
@ -16,9 +16,13 @@
|
||||
|
||||
#include "tcpsrc.h"
|
||||
|
||||
#include <dsp/downchannelizer.h>
|
||||
#include <QTcpServer>
|
||||
#include <QTcpSocket>
|
||||
|
||||
#include <dsp/downchannelizer.h>
|
||||
#include "dsp/threadedbasebandsamplesink.h"
|
||||
#include <device/devicesourceapi.h>
|
||||
|
||||
#include "tcpsrcgui.h"
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(TCPSrc::MsgConfigureTCPSrc, Message)
|
||||
@ -26,7 +30,8 @@ MESSAGE_CLASS_DEFINITION(TCPSrc::MsgConfigureChannelizer, Message)
|
||||
MESSAGE_CLASS_DEFINITION(TCPSrc::MsgTCPSrcConnection, Message)
|
||||
MESSAGE_CLASS_DEFINITION(TCPSrc::MsgTCPSrcSpectrum, Message)
|
||||
|
||||
TCPSrc::TCPSrc(BasebandSampleSink* spectrum) :
|
||||
TCPSrc::TCPSrc(DeviceSourceAPI* deviceAPI) :
|
||||
m_deviceAPI(deviceAPI),
|
||||
m_settingsMutex(QMutex::Recursive)
|
||||
{
|
||||
setObjectName("TCPSrc");
|
||||
@ -40,7 +45,7 @@ TCPSrc::TCPSrc(BasebandSampleSink* spectrum) :
|
||||
m_nco.setFreq(0, m_inputSampleRate);
|
||||
m_interpolator.create(16, m_inputSampleRate, m_rfBandwidth / 2.0);
|
||||
m_sampleDistanceRemain = m_inputSampleRate / m_outputSampleRate;
|
||||
m_spectrum = spectrum;
|
||||
m_spectrum = 0;
|
||||
m_spectrumEnabled = false;
|
||||
m_nextSSBId = 0;
|
||||
m_nextS16leId = 0;
|
||||
@ -50,6 +55,11 @@ TCPSrc::TCPSrc(BasebandSampleSink* spectrum) :
|
||||
m_scale = 0;
|
||||
m_volume = 0;
|
||||
m_magsq = 0;
|
||||
|
||||
m_channelizer = new DownChannelizer(this);
|
||||
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
|
||||
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
|
||||
|
||||
m_sampleBufferSSB.resize(tcpFftLen);
|
||||
TCPFilter = new fftfilt(0.3 / 48.0, 16.0 / 48.0, tcpFftLen);
|
||||
// if (!TCPFilter) segfault;
|
||||
@ -58,6 +68,10 @@ TCPSrc::TCPSrc(BasebandSampleSink* spectrum) :
|
||||
TCPSrc::~TCPSrc()
|
||||
{
|
||||
if (TCPFilter) delete TCPFilter;
|
||||
|
||||
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
|
||||
delete m_threadedChannelizer;
|
||||
delete m_channelizer;
|
||||
}
|
||||
|
||||
void TCPSrc::setSpectrum(MessageQueue* messageQueue, bool enabled)
|
||||
@ -172,8 +186,6 @@ void TCPSrc::stop()
|
||||
|
||||
bool TCPSrc::handleMessage(const Message& cmd)
|
||||
{
|
||||
qDebug() << "TCPSrc::handleMessage";
|
||||
|
||||
if (DownChannelizer::MsgChannelizerNotification::match(cmd))
|
||||
{
|
||||
DownChannelizer::MsgChannelizerNotification& notif = (DownChannelizer::MsgChannelizerNotification&) cmd;
|
||||
@ -192,6 +204,20 @@ bool TCPSrc::handleMessage(const Message& cmd)
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureChannelizer::match(cmd))
|
||||
{
|
||||
MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
|
||||
|
||||
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
|
||||
cfg.getSampleRate(),
|
||||
cfg.getCenterFrequency());
|
||||
|
||||
qDebug() << "TCPSrc::handleMessage: MsgConfigureChannelizer:"
|
||||
<< " sampleRate: " << cfg.getSampleRate()
|
||||
<< " centerFrequency: " << cfg.getCenterFrequency();
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureTCPSrc::match(cmd))
|
||||
{
|
||||
MsgConfigureTCPSrc& cfg = (MsgConfigureTCPSrc&) cmd;
|
||||
@ -235,7 +261,7 @@ bool TCPSrc::handleMessage(const Message& cmd)
|
||||
|
||||
m_settingsMutex.unlock();
|
||||
|
||||
qDebug() << "MsgConfigureTCPSrc::handleMessage: MsgConfigureTCPSrc:"
|
||||
qDebug() << "TCPSrc::handleMessage: MsgConfigureTCPSrc:"
|
||||
<< " m_sampleFormat: " << m_sampleFormat
|
||||
<< " m_outputSampleRate: " << m_outputSampleRate
|
||||
<< " m_rfBandwidth: " << m_rfBandwidth
|
||||
@ -251,7 +277,7 @@ bool TCPSrc::handleMessage(const Message& cmd)
|
||||
|
||||
m_spectrumEnabled = spc.getEnabled();
|
||||
|
||||
qDebug() << " - MsgTCPSrcSpectrum: m_spectrumEnabled: " << m_spectrumEnabled;
|
||||
qDebug() << "TCPSrc::handleMessage: MsgTCPSrcSpectrum: m_spectrumEnabled: " << m_spectrumEnabled;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -259,6 +285,12 @@ bool TCPSrc::handleMessage(const Message& cmd)
|
||||
{
|
||||
MsgTCPSrcConnection& con = (MsgTCPSrcConnection&) cmd;
|
||||
|
||||
qDebug() << "TCPSrc::handleMessage: MsgTCPSrcConnection"
|
||||
<< " connect: " << con.getConnect()
|
||||
<< " id: " << con.getID()
|
||||
<< " peer address: " << con.getPeerAddress()
|
||||
<< " peer port: " << con.getPeerPort();
|
||||
|
||||
if (con.getConnect())
|
||||
{
|
||||
processNewConnection();
|
||||
|
@ -17,6 +17,9 @@
|
||||
class QTcpServer;
|
||||
class QTcpSocket;
|
||||
class TCPSrcGUI;
|
||||
class DeviceSourceAPI;
|
||||
class ThreadedBasebandSampleSink;
|
||||
class DownChannelizer;
|
||||
|
||||
class TCPSrc : public BasebandSampleSink {
|
||||
Q_OBJECT
|
||||
@ -98,8 +101,9 @@ public:
|
||||
{ }
|
||||
};
|
||||
|
||||
TCPSrc(BasebandSampleSink* spectrum);
|
||||
TCPSrc(DeviceSourceAPI* m_deviceAPI);
|
||||
virtual ~TCPSrc();
|
||||
void setSpectrum(BasebandSampleSink* spectrum) { m_spectrum = spectrum; }
|
||||
|
||||
void setSpectrum(MessageQueue* messageQueue, bool enabled);
|
||||
double getMagSq() const { return m_magsq; }
|
||||
@ -150,6 +154,9 @@ protected:
|
||||
};
|
||||
|
||||
TCPSrcSettings m_settings;
|
||||
DeviceSourceAPI* m_deviceAPI;
|
||||
ThreadedBasebandSampleSink* m_threadedChannelizer;
|
||||
DownChannelizer* m_channelizer;
|
||||
|
||||
int m_inputSampleRate;
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include "../../channelrx/tcpsrc/tcpsrcgui.h"
|
||||
#include "tcpsrcgui.h"
|
||||
|
||||
#include <device/devicesourceapi.h>
|
||||
#include <dsp/downchannelizer.h>
|
||||
#include "../../../sdrbase/dsp/threadedbasebandsamplesink.h"
|
||||
#include "plugin/pluginapi.h"
|
||||
#include "dsp/spectrumvis.h"
|
||||
#include "dsp/dspengine.h"
|
||||
@ -11,7 +9,7 @@
|
||||
#include "gui/basicchannelsettingswidget.h"
|
||||
#include "ui_tcpsrcgui.h"
|
||||
#include "mainwindow.h"
|
||||
#include "../../channelrx/tcpsrc/tcpsrc.h"
|
||||
#include "tcpsrc.h"
|
||||
|
||||
const QString TCPSrcGUI::m_channelID = "sdrangel.channel.tcpsrc";
|
||||
|
||||
@ -142,10 +140,8 @@ TCPSrcGUI::TCPSrcGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget*
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
|
||||
m_tcpSrc = new TCPSrc(m_spectrumVis);
|
||||
m_channelizer = new DownChannelizer(m_tcpSrc);
|
||||
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
|
||||
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
|
||||
m_tcpSrc = new TCPSrc(m_deviceAPI);
|
||||
m_tcpSrc->setSpectrum(m_spectrumVis);
|
||||
|
||||
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
||||
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
||||
@ -174,15 +170,15 @@ TCPSrcGUI::TCPSrcGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget*
|
||||
|
||||
ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
|
||||
|
||||
applySettings();
|
||||
m_settings.setSpectrumGUI(ui->spectrumGUI);
|
||||
m_settings.setChannelMarker(&m_channelMarker);
|
||||
|
||||
applySettings();
|
||||
}
|
||||
|
||||
TCPSrcGUI::~TCPSrcGUI()
|
||||
{
|
||||
m_deviceAPI->removeChannelInstance(this);
|
||||
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
|
||||
delete m_threadedChannelizer;
|
||||
delete m_channelizer;
|
||||
delete m_tcpSrc;
|
||||
delete m_spectrumVis;
|
||||
delete ui;
|
||||
@ -199,9 +195,9 @@ void TCPSrcGUI::applySettings()
|
||||
{
|
||||
ui->glSpectrum->setSampleRate(m_settings.m_outputSampleRate);
|
||||
|
||||
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
|
||||
m_settings.m_outputSampleRate,
|
||||
m_channelMarker.getCenterFrequency());
|
||||
TCPSrc::MsgConfigureChannelizer* channelConfigMsg = TCPSrc::MsgConfigureChannelizer::create(
|
||||
m_settings.m_outputSampleRate, m_channelMarker.getCenterFrequency());
|
||||
m_tcpSrc->getInputMessageQueue()->push(channelConfigMsg);
|
||||
|
||||
TCPSrc::MsgConfigureTCPSrc* message = TCPSrc::MsgConfigureTCPSrc::create( m_settings, false);
|
||||
m_tcpSrc->getInputMessageQueue()->push(message);
|
||||
|
@ -14,8 +14,6 @@
|
||||
|
||||
class PluginAPI;
|
||||
class DeviceSourceAPI;
|
||||
class ThreadedBasebandSampleSink;
|
||||
class DownChannelizer;
|
||||
class TCPSrc;
|
||||
class SpectrumVis;
|
||||
|
||||
@ -76,8 +74,6 @@ private:
|
||||
bool m_doApplySettings;
|
||||
|
||||
// RF path
|
||||
ThreadedBasebandSampleSink* m_threadedChannelizer;
|
||||
DownChannelizer* m_channelizer;
|
||||
SpectrumVis* m_spectrumVis;
|
||||
MessageQueue m_inputMessageQueue;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user