1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-08 00:44:48 -04:00

git clone git://git.osmocom.org/sdrangelove.git

This commit is contained in:
Hexameron
2014-05-18 16:52:39 +01:00
commit 7d3bfb26fc
203 changed files with 27958 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
project(demod)
add_subdirectory(nfm)
add_subdirectory(tcpsrc)
#add_subdirectory(tetra)
+47
View File
@@ -0,0 +1,47 @@
project(nfm)
set(nfm_SOURCES
nfmdemod.cpp
nfmdemodgui.cpp
nfmplugin.cpp
)
set(nfm_HEADERS
nfmdemod.h
nfmdemodgui.h
nfmplugin.h
)
set(nfm_FORMS
nfmdemodgui.ui
)
include_directories(
.
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/include-gpl
${OPENGL_INCLUDE_DIR}
)
#include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
add_definitions(-DQT_PLUGIN)
add_definitions(-DQT_SHARED)
#qt5_wrap_cpp(nfm_HEADERS_MOC ${nfm_HEADERS})
qt5_wrap_ui(nfm_FORMS_HEADERS ${nfm_FORMS})
add_library(demodnfm SHARED
${nfm_SOURCES}
${nfm_HEADERS_MOC}
${nfm_FORMS_HEADERS}
)
target_link_libraries(demodnfm
${QT_LIBRARIES}
${OPENGL_LIBRARIES}
sdrbase
)
qt5_use_modules(demodnfm Core Widgets OpenGL Multimedia)
+147
View File
@@ -0,0 +1,147 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
// written by Christian Daniel //
// //
// 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 //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QTime>
#include <stdio.h>
#include "nfmdemod.h"
#include "audio/audiooutput.h"
#include "dsp/dspcommands.h"
MESSAGE_CLASS_DEFINITION(NFMDemod::MsgConfigureNFMDemod, Message)
NFMDemod::NFMDemod(AudioFifo* audioFifo, SampleSink* sampleSink) :
m_sampleSink(sampleSink),
m_audioFifo(audioFifo)
{
m_rfBandwidth = 12500;
m_volume = 2.0;
m_squelchLevel = pow(10.0, -40.0 / 20.0);
m_sampleRate = 500000;
m_frequency = 0;
m_squelchLevel *= m_squelchLevel;
m_nco.setFreq(m_frequency, m_sampleRate);
m_interpolator.create(16, m_sampleRate, 12500);
m_sampleDistanceRemain = (Real)m_sampleRate / 44100.0;
m_lowpass.create(21, 44100, 3000);
m_audioBuffer.resize(256);
m_audioBufferFill = 0;
m_movingAverage.resize(16, 0);
}
NFMDemod::~NFMDemod()
{
}
void NFMDemod::configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch)
{
Message* cmd = MsgConfigureNFMDemod::create(rfBandwidth, afBandwidth, volume, squelch);
cmd->submit(messageQueue, this);
}
void NFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst)
{
Complex ci;
bool consumed;
for(SampleVector::const_iterator it = begin; it < end; ++it) {
Complex c(it->real() / 32768.0, it->imag() / 32768.0);
c *= m_nco.nextIQ();
consumed = false;
if(m_interpolator.interpolate(&m_sampleDistanceRemain, c, &consumed, &ci)) {
m_sampleBuffer.push_back(Sample(ci.real() * 32768.0, ci.imag() * 32768.0));
m_movingAverage.feed(ci.real() * ci.real() + ci.imag() * ci.imag());
if(m_movingAverage.average() >= m_squelchLevel)
m_squelchState = m_sampleRate / 50;
if(m_squelchState > 0) {
m_squelchState--;
Complex d = ci * conj(m_lastSample);
m_lastSample = ci;
Real demod = atan2(d.imag(), d.real()) / M_PI;
demod = m_lowpass.filter(demod);
demod *= m_volume;
qint16 sample = demod * 32767;
m_audioBuffer[m_audioBufferFill].l = sample;
m_audioBuffer[m_audioBufferFill].r = sample;
++m_audioBufferFill;
if(m_audioBufferFill >= m_audioBuffer.size()) {
uint res = m_audioFifo->write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1);
/*
if(res != m_audioBufferFill)
qDebug("lost %u samples", m_audioBufferFill - res);
*/
m_audioBufferFill = 0;
}
}
m_sampleDistanceRemain += (Real)m_sampleRate / 44100.0;
}
}
if(m_audioFifo->write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 0) != m_audioBufferFill)
;//qDebug("lost samples");
m_audioBufferFill = 0;
if(m_sampleSink != NULL)
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), firstOfBurst);
m_sampleBuffer.clear();
}
void NFMDemod::start()
{
m_squelchState = 0;
}
void NFMDemod::stop()
{
}
bool NFMDemod::handleMessage(Message* cmd)
{
if(DSPSignalNotification::match(cmd)) {
DSPSignalNotification* signal = (DSPSignalNotification*)cmd;
qDebug("%d samples/sec, %lld Hz offset", signal->getSampleRate(), signal->getFrequencyOffset());
m_sampleRate = signal->getSampleRate();
m_nco.setFreq(-signal->getFrequencyOffset(), m_sampleRate);
m_interpolator.create(16, m_sampleRate, m_rfBandwidth / 2.1);
m_sampleDistanceRemain = m_sampleRate / 44100.0;
m_squelchState = 0;
cmd->completed();
return true;
} else if(MsgConfigureNFMDemod::match(cmd)) {
MsgConfigureNFMDemod* cfg = (MsgConfigureNFMDemod*)cmd;
m_rfBandwidth = cfg->getRFBandwidth();
m_interpolator.create(16, m_sampleRate, m_rfBandwidth / 2.1);
m_lowpass.create(21, 44100, cfg->getAFBandwidth());
m_squelchLevel = pow(10.0, cfg->getSquelch() / 20.0);
m_squelchLevel *= m_squelchLevel;
m_volume = cfg->getVolume();
cmd->completed();
return true;
} else {
if(m_sampleSink != NULL)
return m_sampleSink->handleMessage(cmd);
else return false;
}
}
+104
View File
@@ -0,0 +1,104 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
// written by Christian Daniel //
// //
// 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 //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_NFMDEMOD_H
#define INCLUDE_NFMDEMOD_H
#include <vector>
#include "dsp/samplesink.h"
#include "dsp/nco.h"
#include "dsp/interpolator.h"
#include "dsp/lowpass.h"
#include "dsp/movingaverage.h"
#include "audio/audiofifo.h"
#include "util/message.h"
class AudioFifo;
class NFMDemod : public SampleSink {
public:
NFMDemod(AudioFifo* audioFifo, SampleSink* sampleSink);
~NFMDemod();
void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch);
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst);
void start();
void stop();
bool handleMessage(Message* cmd);
private:
class MsgConfigureNFMDemod : public Message {
MESSAGE_CLASS_DECLARATION
public:
Real getRFBandwidth() const { return m_rfBandwidth; }
Real getAFBandwidth() const { return m_afBandwidth; }
Real getVolume() const { return m_volume; }
Real getSquelch() const { return m_squelch; }
static MsgConfigureNFMDemod* create(Real rfBandwidth, Real afBandwidth, Real volume, Real squelch)
{
return new MsgConfigureNFMDemod(rfBandwidth, afBandwidth, volume, squelch);
}
private:
Real m_rfBandwidth;
Real m_afBandwidth;
Real m_volume;
Real m_squelch;
MsgConfigureNFMDemod(Real rfBandwidth, Real afBandwidth, Real volume, Real squelch) :
Message(),
m_rfBandwidth(rfBandwidth),
m_afBandwidth(afBandwidth),
m_volume(volume),
m_squelch(squelch)
{ }
};
struct AudioSample {
qint16 l;
qint16 r;
};
typedef std::vector<AudioSample> AudioVector;
Real m_rfBandwidth;
Real m_volume;
Real m_squelchLevel;
int m_sampleRate;
int m_frequency;
NCO m_nco;
Interpolator m_interpolator;
Real m_sampleDistanceRemain;
Lowpass<Real> m_lowpass;
int m_squelchState;
Complex m_lastSample;
MovingAverage m_movingAverage;
AudioVector m_audioBuffer;
uint m_audioBufferFill;
AudioFifo* m_audioFifo;
SampleSink* m_sampleSink;
SampleVector m_sampleBuffer;
};
#endif // INCLUDE_NFMDEMOD_H
+210
View File
@@ -0,0 +1,210 @@
#include <QDockWidget>
#include <QMainWindow>
#include "nfmdemodgui.h"
#include "ui_nfmdemodgui.h"
#include "nfmdemodgui.h"
#include "ui_nfmdemodgui.h"
#include "dsp/threadedsamplesink.h"
#include "dsp/channelizer.h"
#include "nfmdemod.h"
#include "dsp/spectrumvis.h"
#include "gui/glspectrum.h"
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "gui/basicchannelsettingswidget.h"
const int NFMDemodGUI::m_rfBW[] = {
5000, 6250, 8330, 10000, 12500, 15000, 20000, 25000, 40000
};
NFMDemodGUI* NFMDemodGUI::create(PluginAPI* pluginAPI)
{
NFMDemodGUI* gui = new NFMDemodGUI(pluginAPI);
return gui;
}
void NFMDemodGUI::destroy()
{
delete this;
}
void NFMDemodGUI::setName(const QString& name)
{
setObjectName(name);
}
void NFMDemodGUI::resetToDefaults()
{
ui->rfBW->setValue(4);
ui->afBW->setValue(3);
ui->volume->setValue(20);
ui->squelch->setValue(-40);
ui->spectrumGUI->resetToDefaults();
applySettings();
}
QByteArray NFMDemodGUI::serialize() const
{
SimpleSerializer s(1);
s.writeS32(1, m_channelMarker->getCenterFrequency());
s.writeS32(2, ui->rfBW->value());
s.writeS32(3, ui->afBW->value());
s.writeS32(4, ui->volume->value());
s.writeS32(5, ui->squelch->value());
s.writeBlob(6, ui->spectrumGUI->serialize());
s.writeU32(7, m_channelMarker->getColor().rgb());
return s.final();
}
bool NFMDemodGUI::deserialize(const QByteArray& data)
{
SimpleDeserializer d(data);
if(!d.isValid()) {
resetToDefaults();
return false;
}
if(d.getVersion() == 1) {
QByteArray bytetmp;
quint32 u32tmp;
qint32 tmp;
d.readS32(1, &tmp, 0);
m_channelMarker->setCenterFrequency(tmp);
d.readS32(2, &tmp, 4);
ui->rfBW->setValue(tmp);
d.readS32(3, &tmp, 3);
ui->afBW->setValue(tmp);
d.readS32(4, &tmp, 20);
ui->volume->setValue(tmp);
d.readS32(5, &tmp, -40);
ui->squelch->setValue(tmp);
d.readBlob(6, &bytetmp);
ui->spectrumGUI->deserialize(bytetmp);
if(d.readU32(7, &u32tmp))
m_channelMarker->setColor(u32tmp);
applySettings();
return true;
} else {
resetToDefaults();
return false;
}
}
bool NFMDemodGUI::handleMessage(Message* message)
{
return false;
}
void NFMDemodGUI::viewChanged()
{
applySettings();
}
void NFMDemodGUI::on_rfBW_valueChanged(int value)
{
ui->rfBWText->setText(QString("%1 kHz").arg(m_rfBW[value] / 1000.0));
m_channelMarker->setBandwidth(m_rfBW[value]);
applySettings();
}
void NFMDemodGUI::on_afBW_valueChanged(int value)
{
ui->afBWText->setText(QString("%1 kHz").arg(value));
applySettings();
}
void NFMDemodGUI::on_volume_valueChanged(int value)
{
ui->volumeText->setText(QString("%1").arg(value / 10.0, 0, 'f', 1));
applySettings();
}
void NFMDemodGUI::on_squelch_valueChanged(int value)
{
ui->squelchText->setText(QString("%1 dB").arg(value));
applySettings();
}
void NFMDemodGUI::onWidgetRolled(QWidget* widget, bool rollDown)
{
/*
if((widget == ui->spectrumContainer) && (m_nfmDemod != NULL))
m_nfmDemod->setSpectrum(m_threadedSampleSink->getMessageQueue(), rollDown);
*/
}
void NFMDemodGUI::onMenuDoubleClicked()
{
if(!m_basicSettingsShown) {
m_basicSettingsShown = true;
BasicChannelSettingsWidget* bcsw = new BasicChannelSettingsWidget(m_channelMarker, this);
bcsw->show();
}
}
NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
RollupWidget(parent),
ui(new Ui::NFMDemodGUI),
m_pluginAPI(pluginAPI),
m_basicSettingsShown(false)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
m_audioFifo = new AudioFifo(4, 44100 / 4);
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_nfmDemod = new NFMDemod(m_audioFifo, m_spectrumVis);
m_channelizer = new Channelizer(m_nfmDemod);
m_threadedSampleSink = new ThreadedSampleSink(m_channelizer);
m_pluginAPI->addAudioSource(m_audioFifo);
m_pluginAPI->addSampleSink(m_threadedSampleSink);
ui->glSpectrum->setCenterFrequency(0);
ui->glSpectrum->setSampleRate(44100);
ui->glSpectrum->setDisplayWaterfall(true);
ui->glSpectrum->setDisplayMaxHold(true);
m_spectrumVis->configure(m_threadedSampleSink->getMessageQueue(), 64, 10, FFTWindow::BlackmanHarris);
m_channelMarker = new ChannelMarker(this);
m_channelMarker->setColor(Qt::red);
m_channelMarker->setBandwidth(12500);
m_channelMarker->setCenterFrequency(0);
m_channelMarker->setVisible(true);
connect(m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged()));
m_pluginAPI->addChannelMarker(m_channelMarker);
ui->spectrumGUI->setBuddies(m_threadedSampleSink->getMessageQueue(), m_spectrumVis, ui->glSpectrum);
applySettings();
}
NFMDemodGUI::~NFMDemodGUI()
{
m_pluginAPI->removeChannelInstance(this);
m_pluginAPI->removeAudioSource(m_audioFifo);
m_pluginAPI->removeSampleSink(m_threadedSampleSink);
delete m_threadedSampleSink;
delete m_channelizer;
delete m_nfmDemod;
delete m_spectrumVis;
delete m_audioFifo;
delete m_channelMarker;
delete ui;
}
void NFMDemodGUI::applySettings()
{
setTitleColor(m_channelMarker->getColor());
m_channelizer->configure(m_threadedSampleSink->getMessageQueue(),
44100,
m_channelMarker->getCenterFrequency());
m_nfmDemod->configure(m_threadedSampleSink->getMessageQueue(),
m_rfBW[ui->rfBW->value()],
ui->afBW->value() * 1000.0,
ui->volume->value() / 10.0,
ui->squelch->value());
}
+64
View File
@@ -0,0 +1,64 @@
#ifndef INCLUDE_NFMDEMODGUI_H
#define INCLUDE_NFMDEMODGUI_H
#include "gui/rollupwidget.h"
#include "plugin/plugingui.h"
class PluginAPI;
class ChannelMarker;
class AudioFifo;
class ThreadedSampleSink;
class Channelizer;
class NFMDemod;
class SpectrumVis;
namespace Ui {
class NFMDemodGUI;
}
class NFMDemodGUI : public RollupWidget, public PluginGUI {
Q_OBJECT
public:
static NFMDemodGUI* create(PluginAPI* pluginAPI);
void destroy();
void setName(const QString& name);
void resetToDefaults();
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
bool handleMessage(Message* message);
private slots:
void viewChanged();
void on_rfBW_valueChanged(int value);
void on_afBW_valueChanged(int value);
void on_volume_valueChanged(int value);
void on_squelch_valueChanged(int value);
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked();
private:
Ui::NFMDemodGUI* ui;
PluginAPI* m_pluginAPI;
ChannelMarker* m_channelMarker;
bool m_basicSettingsShown;
AudioFifo* m_audioFifo;
ThreadedSampleSink* m_threadedSampleSink;
Channelizer* m_channelizer;
NFMDemod* m_nfmDemod;
SpectrumVis* m_spectrumVis;
static const int m_rfBW[];
explicit NFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent = NULL);
~NFMDemodGUI();
void applySettings();
};
#endif // INCLUDE_NFMDEMODGUI_H
+250
View File
@@ -0,0 +1,250 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NFMDemodGUI</class>
<widget class="RollupWidget" name="NFMDemodGUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>302</width>
<height>410</height>
</rect>
</property>
<property name="windowTitle">
<string>NFM Demodulator</string>
</property>
<widget class="QWidget" name="settingsContainer" native="true">
<property name="geometry">
<rect>
<x>35</x>
<y>35</y>
<width>242</width>
<height>96</height>
</rect>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>2</number>
</property>
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>RF Bandwidth</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="rfBW">
<property name="maximum">
<number>8</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>4</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="rfBWText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>12.5kHz</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>AF Bandwidth</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="afBW">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>20</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>3</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="afBWText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>3 kHz</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Volume</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSlider" name="volume">
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>20</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="volumeText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>2.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Squelch</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSlider" name="squelch">
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>0</number>
</property>
<property name="value">
<number>-40</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="squelchText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>-40dB</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="spectrumContainer" native="true">
<property name="geometry">
<rect>
<x>40</x>
<y>140</y>
<width>218</width>
<height>184</height>
</rect>
</property>
<property name="windowTitle">
<string>Channel Spectrum</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<number>3</number>
</property>
<item>
<widget class="GLSpectrum" name="glSpectrum" native="true">
<property name="minimumSize">
<size>
<width>200</width>
<height>150</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="GLSpectrumGUI" name="spectrumGUI" native="true"/>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>GLSpectrum</class>
<extends>QWidget</extends>
<header>gui/glspectrum.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrumGUI</class>
<extends>QWidget</extends>
<header>gui/glspectrumgui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>RollupWidget</class>
<extends>QWidget</extends>
<header>gui/rollupwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
+53
View File
@@ -0,0 +1,53 @@
#include <QtPlugin>
#include <QAction>
#include "plugin/pluginapi.h"
#include "nfmplugin.h"
#include "nfmdemodgui.h"
const PluginDescriptor NFMPlugin::m_pluginDescriptor = {
QString("NFM Demodulator"),
QString("---"),
QString("(c) maintech GmbH (written by Christian Daniel)"),
QString("http://www.maintech.de"),
true,
QString("http://www.maintech.de")
};
NFMPlugin::NFMPlugin(QObject* parent) :
QObject(parent)
{
}
const PluginDescriptor& NFMPlugin::getPluginDescriptor() const
{
return m_pluginDescriptor;
}
void NFMPlugin::initPlugin(PluginAPI* pluginAPI)
{
m_pluginAPI = pluginAPI;
// register NFM demodulator
QAction* action = new QAction(tr("&NFM Demodulator"), this);
connect(action, SIGNAL(triggered()), this, SLOT(createInstanceNFM()));
m_pluginAPI->registerChannel("de.maintech.sdrangelove.channel.nfm", this, action);
}
PluginGUI* NFMPlugin::createChannel(const QString& channelName)
{
if(channelName == "de.maintech.sdrangelove.channel.nfm") {
NFMDemodGUI* gui = NFMDemodGUI::create(m_pluginAPI);
m_pluginAPI->registerChannelInstance("de.maintech.sdrangelove.channel.nfm", gui);
m_pluginAPI->addChannelRollup(gui);
return gui;
} else {
return NULL;
}
}
void NFMPlugin::createInstanceNFM()
{
NFMDemodGUI* gui = NFMDemodGUI::create(m_pluginAPI);
m_pluginAPI->registerChannelInstance("de.maintech.sdrangelove.channel.nfm", gui);
m_pluginAPI->addChannelRollup(gui);
}
+29
View File
@@ -0,0 +1,29 @@
#ifndef INCLUDE_NFMPLUGIN_H
#define INCLUDE_NFMPLUGIN_H
#include <QObject>
#include "plugin/plugininterface.h"
class NFMPlugin : public QObject, PluginInterface {
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID "de.maintech.sdrangelove.channel.nfm")
public:
explicit NFMPlugin(QObject* parent = NULL);
const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI);
PluginGUI* createChannel(const QString& channelName);
private:
static const PluginDescriptor m_pluginDescriptor;
PluginAPI* m_pluginAPI;
private slots:
void createInstanceNFM();
};
#endif // INCLUDE_NFMPLUGIN_H
+47
View File
@@ -0,0 +1,47 @@
project(tcpsrc)
set(tcpsrc_SOURCES
tcpsrc.cpp
tcpsrcgui.cpp
tcpsrcplugin.cpp
)
set(tcpsrc_HEADERS
tcpsrc.h
tcpsrcgui.h
tcpsrcplugin.h
)
set(tcpsrc_FORMS
tcpsrcgui.ui
)
include_directories(
.
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/include-gpl
${OPENGL_INCLUDE_DIR}
)
#include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
add_definitions(-DQT_PLUGIN)
add_definitions(-DQT_SHARED)
#qt5_wrap_cpp(tcpsrc_HEADERS_MOC ${tcpsrc_HEADERS})
qt5_wrap_ui(tcpsrc_FORMS_HEADERS ${tcpsrc_FORMS})
add_library(demodtcpsrc SHARED
${tcpsrc_SOURCES}
${tcpsrc_HEADERS_MOC}
${tcpsrc_FORMS_HEADERS}
)
target_link_libraries(demodtcpsrc
${QT_LIBRARIES}
${OPENGL_LIBRARIES}
sdrbase
)
qt5_use_modules(demodtcpsrc Core Widgets OpenGL Network)
+205
View File
@@ -0,0 +1,205 @@
#include <QTcpServer>
#include <QTcpSocket>
#include <QThread>
#include "tcpsrc.h"
#include "tcpsrcgui.h"
#include "dsp/dspcommands.h"
MESSAGE_CLASS_DEFINITION(TCPSrc::MsgTCPSrcConfigure, Message)
MESSAGE_CLASS_DEFINITION(TCPSrc::MsgTCPSrcConnection, Message)
MESSAGE_CLASS_DEFINITION(TCPSrc::MsgTCPSrcSpectrum, Message)
TCPSrc::TCPSrc(MessageQueue* uiMessageQueue, TCPSrcGUI* tcpSrcGUI, SampleSink* spectrum)
{
m_inputSampleRate = 100000;
m_sampleFormat = FormatS8;
m_outputSampleRate = 50000;
m_rfBandwidth = 50000;
m_tcpPort = 9999;
m_nco.setFreq(0, m_inputSampleRate);
m_interpolator.create(16, m_inputSampleRate, m_rfBandwidth / 2.1);
m_sampleDistanceRemain = m_inputSampleRate / m_outputSampleRate;
m_uiMessageQueue = uiMessageQueue;
m_tcpSrcGUI = tcpSrcGUI;
m_spectrum = spectrum;
m_spectrumEnabled = false;
m_nextS8Id = 0;
m_nextS16leId = 0;
}
TCPSrc::~TCPSrc()
{
}
void TCPSrc::configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort)
{
Message* cmd = MsgTCPSrcConfigure::create(sampleFormat, outputSampleRate, rfBandwidth, tcpPort);
cmd->submit(messageQueue, this);
}
void TCPSrc::setSpectrum(MessageQueue* messageQueue, bool enabled)
{
Message* cmd = MsgTCPSrcSpectrum::create(enabled);
cmd->submit(messageQueue, this);
}
void TCPSrc::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst)
{
Complex ci;
bool consumed;
for(SampleVector::const_iterator it = begin; it < end; ++it) {
Complex c(it->real() / 32768.0, it->imag() / 32768.0);
c *= m_nco.nextIQ();
consumed = false;
if(m_interpolator.interpolate(&m_sampleDistanceRemain, c, &consumed, &ci)) {
m_sampleBuffer.push_back(Sample(ci.real() * 32768.0, ci.imag() * 32768.0));
m_sampleDistanceRemain += m_inputSampleRate / m_outputSampleRate;
}
}
if((m_spectrum != NULL) && (m_spectrumEnabled))
m_spectrum->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), firstOfBurst);
for(int i = 0; i < m_s16leSockets.count(); i++)
m_s16leSockets[i].socket->write((const char*)&m_sampleBuffer[0], m_sampleBuffer.size() * 4);
if(m_s8Sockets.count() > 0) {
for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it) {
m_sampleBufferS8.push_back(it->real() >> 8);
m_sampleBufferS8.push_back(it->imag() >> 8);
}
for(int i = 0; i < m_s8Sockets.count(); i++)
m_s8Sockets[i].socket->write((const char*)&m_sampleBufferS8[0], m_sampleBufferS8.size());
}
m_sampleBuffer.clear();
m_sampleBufferS8.clear();
}
void TCPSrc::start()
{
m_tcpServer = new QTcpServer();
connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(onNewConnection()));
m_tcpServer->listen(QHostAddress::Any, m_tcpPort);
}
void TCPSrc::stop()
{
closeAllSockets(&m_s8Sockets);
closeAllSockets(&m_s16leSockets);
if(m_tcpServer->isListening())
m_tcpServer->close();
delete m_tcpServer;
}
bool TCPSrc::handleMessage(Message* cmd)
{
if(DSPSignalNotification::match(cmd)) {
DSPSignalNotification* signal = (DSPSignalNotification*)cmd;
qDebug("%d samples/sec, %lld Hz offset", signal->getSampleRate(), signal->getFrequencyOffset());
m_inputSampleRate = signal->getSampleRate();
m_nco.setFreq(-signal->getFrequencyOffset(), m_inputSampleRate);
m_interpolator.create(16, m_inputSampleRate, m_rfBandwidth / 2.1);
m_sampleDistanceRemain = m_inputSampleRate / m_outputSampleRate;
cmd->completed();
return true;
} else if(DSPSignalNotification::match(cmd)) {
MsgTCPSrcConfigure* cfg = (MsgTCPSrcConfigure*)cmd;
m_sampleFormat = cfg->getSampleFormat();
m_outputSampleRate = cfg->getOutputSampleRate();
m_rfBandwidth = cfg->getRFBandwidth();
if(cfg->getTCPPort() != m_tcpPort) {
m_tcpPort = cfg->getTCPPort();
if(m_tcpServer->isListening())
m_tcpServer->close();
m_tcpServer->listen(QHostAddress::Any, m_tcpPort);
}
m_interpolator.create(16, m_inputSampleRate, m_rfBandwidth / 2.1);
m_sampleDistanceRemain = m_inputSampleRate / m_outputSampleRate;
cmd->completed();
return true;
} else if(MsgTCPSrcSpectrum::match(cmd)) {
MsgTCPSrcSpectrum* spc = (MsgTCPSrcSpectrum*)cmd;
m_spectrumEnabled = spc->getEnabled();
cmd->completed();
return true;
} else {
if(m_spectrum != NULL)
return m_spectrum->handleMessage(cmd);
else return false;
}
}
void TCPSrc::closeAllSockets(Sockets* sockets)
{
for(int i = 0; i < sockets->count(); ++i) {
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(false, sockets->at(i).id, QHostAddress(), 0);
msg->submit(m_uiMessageQueue, (PluginGUI*)m_tcpSrcGUI);
sockets->at(i).socket->close();
}
}
void TCPSrc::onNewConnection()
{
while(m_tcpServer->hasPendingConnections()) {
QTcpSocket* connection = m_tcpServer->nextPendingConnection();
connect(connection, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
switch(m_sampleFormat) {
case FormatS8: {
quint32 id = (FormatS8 << 24) | m_nextS8Id;
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(true, id, connection->peerAddress(), connection->peerPort());
m_nextS8Id = (m_nextS8Id + 1) & 0xffffff;
m_s8Sockets.push_back(Socket(id, connection));
msg->submit(m_uiMessageQueue, (PluginGUI*)m_tcpSrcGUI);
break;
}
case FormatS16LE: {
quint32 id = (FormatS16LE << 24) | m_nextS16leId;
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(true, id, connection->peerAddress(), connection->peerPort());
m_nextS16leId = (m_nextS16leId + 1) & 0xffffff;
m_s16leSockets.push_back(Socket(id, connection));
msg->submit(m_uiMessageQueue, (PluginGUI*)m_tcpSrcGUI);
break;
}
default:
delete connection;
break;
}
}
}
void TCPSrc::onDisconnected()
{
quint32 id;
QTcpSocket* socket = NULL;
for(int i = 0; i < m_s8Sockets.count(); i++) {
if(m_s8Sockets[i].socket == sender()) {
id = m_s8Sockets[i].id;
socket = m_s8Sockets[i].socket;
m_s8Sockets.removeAt(i);
break;
}
}
if(socket == NULL) {
for(int i = 0; i < m_s16leSockets.count(); i++) {
if(m_s16leSockets[i].socket == sender()) {
id = m_s16leSockets[i].id;
socket = m_s16leSockets[i].socket;
m_s16leSockets.removeAt(i);
break;
}
}
}
if(socket != NULL) {
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(false, id, QHostAddress(), 0);
msg->submit(m_uiMessageQueue, (PluginGUI*)m_tcpSrcGUI);
socket->deleteLater();
}
}
+153
View File
@@ -0,0 +1,153 @@
#ifndef INCLUDE_TCPSRC_H
#define INCLUDE_TCPSRC_H
#include <QHostAddress>
#include "dsp/samplesink.h"
#include "dsp/nco.h"
#include "dsp/interpolator.h"
#include "util/message.h"
class QTcpServer;
class QTcpSocket;
class TCPSrcGUI;
class TCPSrc : public SampleSink {
Q_OBJECT
public:
enum SampleFormat {
FormatS8,
FormatS16LE
};
TCPSrc(MessageQueue* uiMessageQueue, TCPSrcGUI* tcpSrcGUI, SampleSink* spectrum);
~TCPSrc();
void configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort);
void setSpectrum(MessageQueue* messageQueue, bool enabled);
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst);
void start();
void stop();
bool handleMessage(Message* cmd);
class MsgTCPSrcConnection : public Message {
MESSAGE_CLASS_DECLARATION
public:
bool getConnect() const { return m_connect; }
quint32 getID() const { return m_id; }
const QHostAddress& getPeerAddress() const { return m_peerAddress; }
int getPeerPort() const { return m_peerPort; }
static MsgTCPSrcConnection* create(bool connect, quint32 id, const QHostAddress& peerAddress, int peerPort)
{
return new MsgTCPSrcConnection(connect, id, peerAddress, peerPort);
}
private:
bool m_connect;
quint32 m_id;
QHostAddress m_peerAddress;
int m_peerPort;
MsgTCPSrcConnection(bool connect, quint32 id, const QHostAddress& peerAddress, int peerPort) :
Message(),
m_connect(connect),
m_id(id),
m_peerAddress(peerAddress),
m_peerPort(peerPort)
{ }
};
protected:
class MsgTCPSrcConfigure : public Message {
MESSAGE_CLASS_DECLARATION
public:
SampleFormat getSampleFormat() const { return m_sampleFormat; }
Real getOutputSampleRate() const { return m_outputSampleRate; }
Real getRFBandwidth() const { return m_rfBandwidth; }
int getTCPPort() const { return m_tcpPort; }
static MsgTCPSrcConfigure* create(SampleFormat sampleFormat, Real sampleRate, Real rfBandwidth, int tcpPort)
{
return new MsgTCPSrcConfigure(sampleFormat, sampleRate, rfBandwidth, tcpPort);
}
private:
SampleFormat m_sampleFormat;
Real m_outputSampleRate;
Real m_rfBandwidth;
int m_tcpPort;
MsgTCPSrcConfigure(SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort) :
Message(),
m_sampleFormat(sampleFormat),
m_outputSampleRate(outputSampleRate),
m_rfBandwidth(rfBandwidth),
m_tcpPort(tcpPort)
{ }
};
class MsgTCPSrcSpectrum : public Message {
MESSAGE_CLASS_DECLARATION
public:
bool getEnabled() const { return m_enabled; }
static MsgTCPSrcSpectrum* create(bool enabled)
{
return new MsgTCPSrcSpectrum(enabled);
}
private:
bool m_enabled;
MsgTCPSrcSpectrum(bool enabled) :
Message(),
m_enabled(enabled)
{ }
};
MessageQueue* m_uiMessageQueue;
TCPSrcGUI* m_tcpSrcGUI;
int m_inputSampleRate;
int m_sampleFormat;
Real m_outputSampleRate;
Real m_rfBandwidth;
int m_tcpPort;
NCO m_nco;
Interpolator m_interpolator;
Real m_sampleDistanceRemain;
SampleVector m_sampleBuffer;
std::vector<qint8> m_sampleBufferS8;
SampleSink* m_spectrum;
bool m_spectrumEnabled;
QTcpServer* m_tcpServer;
struct Socket {
quint32 id;
QTcpSocket* socket;
Socket(quint32 _id, QTcpSocket* _socket) :
id(_id),
socket(_socket)
{ }
};
typedef QList<Socket> Sockets;
Sockets m_s8Sockets;
Sockets m_s16leSockets;
quint32 m_nextS8Id;
quint32 m_nextS16leId;
void closeAllSockets(Sockets* sockets);
protected slots:
void onNewConnection();
void onDisconnected();
};
#endif // INCLUDE_TCPSRC_H
+278
View File
@@ -0,0 +1,278 @@
#include "tcpsrcgui.h"
#include "plugin/pluginapi.h"
#include "tcpsrc.h"
#include "dsp/channelizer.h"
#include "dsp/spectrumvis.h"
#include "dsp/threadedsamplesink.h"
#include "util/simpleserializer.h"
#include "gui/basicchannelsettingswidget.h"
#include "ui_tcpsrcgui.h"
TCPSrcGUI* TCPSrcGUI::create(PluginAPI* pluginAPI)
{
TCPSrcGUI* gui = new TCPSrcGUI(pluginAPI);
return gui;
}
void TCPSrcGUI::destroy()
{
delete this;
}
void TCPSrcGUI::setName(const QString& name)
{
setObjectName(name);
}
void TCPSrcGUI::resetToDefaults()
{
ui->sampleFormat->setCurrentIndex(0);
ui->sampleRate->setText("25000");
ui->rfBandwidth->setText("20000");
ui->tcpPort->setText("9999");
ui->spectrumGUI->resetToDefaults();
applySettings();
}
QByteArray TCPSrcGUI::serialize() const
{
SimpleSerializer s(1);
s.writeBlob(1, saveState());
s.writeS32(2, m_channelMarker->getCenterFrequency());
s.writeS32(3, m_sampleFormat);
s.writeReal(4, m_outputSampleRate);
s.writeReal(5, m_rfBandwidth);
s.writeS32(6, m_tcpPort);
s.writeBlob(7, ui->spectrumGUI->serialize());
s.writeU32(8, m_channelMarker->getColor().rgb());
return s.final();
}
bool TCPSrcGUI::deserialize(const QByteArray& data)
{
SimpleDeserializer d(data);
if(!d.isValid()) {
resetToDefaults();
return false;
}
if(d.getVersion() == 1) {
QByteArray bytetmp;
qint32 s32tmp;
quint32 u32tmp;
Real realtmp;
d.readBlob(1, &bytetmp);
restoreState(bytetmp);
d.readS32(2, &s32tmp, 0);
m_channelMarker->setCenterFrequency(s32tmp);
d.readS32(3, &s32tmp, TCPSrc::FormatS8);
switch(s32tmp) {
case TCPSrc::FormatS8:
ui->sampleFormat->setCurrentIndex(0);
break;
case TCPSrc::FormatS16LE:
ui->sampleFormat->setCurrentIndex(1);
break;
default:
ui->sampleFormat->setCurrentIndex(0);
break;
}
d.readReal(4, &realtmp, 25000);
ui->sampleRate->setText(QString("%1").arg(realtmp, 0));
d.readReal(5, &realtmp, 20000);
ui->rfBandwidth->setText(QString("%1").arg(realtmp, 0));
d.readS32(6, &s32tmp, 9999);
ui->tcpPort->setText(QString("%1").arg(s32tmp));
d.readBlob(7, &bytetmp);
ui->spectrumGUI->deserialize(bytetmp);
if(d.readU32(8, &u32tmp))
m_channelMarker->setColor(u32tmp);
applySettings();
return true;
} else {
resetToDefaults();
return false;
}
}
bool TCPSrcGUI::handleMessage(Message* message)
{
if(TCPSrc::MsgTCPSrcConnection::match(message)) {
TCPSrc::MsgTCPSrcConnection* con = (TCPSrc::MsgTCPSrcConnection*)message;
if(con->getConnect())
addConnection(con->getID(), con->getPeerAddress(), con->getPeerPort());
else delConnection(con->getID());
message->completed();
return true;
} else {
return false;
}
}
void TCPSrcGUI::channelMarkerChanged()
{
applySettings();
}
TCPSrcGUI::TCPSrcGUI(PluginAPI* pluginAPI, QWidget* parent) :
RollupWidget(parent),
ui(new Ui::TCPSrcGUI),
m_pluginAPI(pluginAPI),
m_tcpSrc(NULL),
m_basicSettingsShown(false)
{
ui->setupUi(this);
ui->connectedClientsBox->hide();
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
setAttribute(Qt::WA_DeleteOnClose, true);
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_tcpSrc = new TCPSrc(m_pluginAPI->getMainWindowMessageQueue(), this, m_spectrumVis);
m_channelizer = new Channelizer(m_tcpSrc);
m_threadedSampleSink = new ThreadedSampleSink(m_channelizer);
m_pluginAPI->addSampleSink(m_threadedSampleSink);
ui->glSpectrum->setCenterFrequency(0);
ui->glSpectrum->setSampleRate(ui->sampleRate->text().toInt());
ui->glSpectrum->setDisplayWaterfall(true);
ui->glSpectrum->setDisplayMaxHold(true);
m_spectrumVis->configure(m_threadedSampleSink->getMessageQueue(), 64, 10, FFTWindow::BlackmanHarris);
m_channelMarker = new ChannelMarker(this);
m_channelMarker->setBandwidth(25000);
m_channelMarker->setCenterFrequency(0);
m_channelMarker->setVisible(true);
connect(m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged()));
m_pluginAPI->addChannelMarker(m_channelMarker);
ui->spectrumGUI->setBuddies(m_threadedSampleSink->getMessageQueue(), m_spectrumVis, ui->glSpectrum);
applySettings();
}
TCPSrcGUI::~TCPSrcGUI()
{
m_pluginAPI->removeChannelInstance(this);
m_pluginAPI->removeSampleSink(m_threadedSampleSink);
delete m_threadedSampleSink;
delete m_channelizer;
delete m_tcpSrc;
delete m_spectrumVis;
delete m_channelMarker;
delete ui;
}
void TCPSrcGUI::applySettings()
{
bool ok;
Real outputSampleRate = ui->sampleRate->text().toDouble(&ok);
if((!ok) || (outputSampleRate < 100))
outputSampleRate = 25000;
Real rfBandwidth = ui->rfBandwidth->text().toDouble(&ok);
if((!ok) || (rfBandwidth > outputSampleRate))
rfBandwidth = outputSampleRate;
int tcpPort = ui->tcpPort->text().toInt(&ok);
if((!ok) || (tcpPort < 1) || (tcpPort > 65535))
tcpPort = 9999;
setTitleColor(m_channelMarker->getColor());
ui->sampleRate->setText(QString("%1").arg(outputSampleRate, 0));
ui->rfBandwidth->setText(QString("%1").arg(rfBandwidth, 0));
ui->tcpPort->setText(QString("%1").arg(tcpPort));
m_channelMarker->disconnect(this, SLOT(channelMarkerChanged()));
m_channelMarker->setBandwidth((int)rfBandwidth);
connect(m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged()));
ui->glSpectrum->setSampleRate(outputSampleRate);
m_channelizer->configure(m_threadedSampleSink->getMessageQueue(),
outputSampleRate,
m_channelMarker->getCenterFrequency());
TCPSrc::SampleFormat sampleFormat;
switch(ui->sampleFormat->currentIndex()) {
case 0:
sampleFormat = TCPSrc::FormatS8;
break;
case 1:
sampleFormat = TCPSrc::FormatS16LE;
break;
default:
sampleFormat = TCPSrc::FormatS8;
break;
}
m_sampleFormat = sampleFormat;
m_outputSampleRate = outputSampleRate;
m_rfBandwidth = rfBandwidth;
m_tcpPort = tcpPort;
m_tcpSrc->configure(m_threadedSampleSink->getMessageQueue(),
sampleFormat,
outputSampleRate,
rfBandwidth,
tcpPort);
ui->applyBtn->setEnabled(false);
}
void TCPSrcGUI::on_sampleFormat_currentIndexChanged(int index)
{
ui->applyBtn->setEnabled(true);
}
void TCPSrcGUI::on_sampleRate_textEdited(const QString& arg1)
{
ui->applyBtn->setEnabled(true);
}
void TCPSrcGUI::on_rfBandwidth_textEdited(const QString& arg1)
{
ui->applyBtn->setEnabled(true);
}
void TCPSrcGUI::on_tcpPort_textEdited(const QString& arg1)
{
ui->applyBtn->setEnabled(true);
}
void TCPSrcGUI::on_applyBtn_clicked()
{
applySettings();
}
void TCPSrcGUI::onWidgetRolled(QWidget* widget, bool rollDown)
{
if((widget == ui->spectrumBox) && (m_tcpSrc != NULL))
m_tcpSrc->setSpectrum(m_threadedSampleSink->getMessageQueue(), rollDown);
}
void TCPSrcGUI::onMenuDoubleClicked()
{
if(!m_basicSettingsShown) {
m_basicSettingsShown = true;
BasicChannelSettingsWidget* bcsw = new BasicChannelSettingsWidget(m_channelMarker, this);
bcsw->show();
}
}
void TCPSrcGUI::addConnection(quint32 id, const QHostAddress& peerAddress, int peerPort)
{
QStringList l;
l.append(QString("%1:%2").arg(peerAddress.toString()).arg(peerPort));
new QTreeWidgetItem(ui->connections, l, id);
ui->connectedClientsBox->setWindowTitle(tr("Connected Clients (%1)").arg(ui->connections->topLevelItemCount()));
}
void TCPSrcGUI::delConnection(quint32 id)
{
for(int i = 0; i < ui->connections->topLevelItemCount(); i++) {
if(ui->connections->topLevelItem(i)->type() == id) {
delete ui->connections->topLevelItem(i);
ui->connectedClientsBox->setWindowTitle(tr("Connected Clients (%1)").arg(ui->connections->topLevelItemCount()));
return;
}
}
}
+72
View File
@@ -0,0 +1,72 @@
#ifndef INCLUDE_TCPSRCGUI_H
#define INCLUDE_TCPSRCGUI_H
#include <QHostAddress>
#include "gui/rollupwidget.h"
#include "plugin/plugingui.h"
#include "tcpsrc.h"
class PluginAPI;
class ChannelMarker;
class ThreadedSampleSink;
class Channelizer;
class TCPSrc;
class SpectrumVis;
namespace Ui {
class TCPSrcGUI;
}
class TCPSrcGUI : public RollupWidget, public PluginGUI {
Q_OBJECT
public:
static TCPSrcGUI* create(PluginAPI* pluginAPI);
void destroy();
void setName(const QString& name);
void resetToDefaults();
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
bool handleMessage(Message* message);
private slots:
void channelMarkerChanged();
void on_sampleFormat_currentIndexChanged(int index);
void on_sampleRate_textEdited(const QString& arg1);
void on_rfBandwidth_textEdited(const QString& arg1);
void on_tcpPort_textEdited(const QString& arg1);
void on_applyBtn_clicked();
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked();
private:
Ui::TCPSrcGUI* ui;
PluginAPI* m_pluginAPI;
ChannelMarker* m_channelMarker;
// settings
TCPSrc::SampleFormat m_sampleFormat;
Real m_outputSampleRate;
Real m_rfBandwidth;
int m_tcpPort;
bool m_basicSettingsShown;
// RF path
ThreadedSampleSink* m_threadedSampleSink;
Channelizer* m_channelizer;
TCPSrc* m_tcpSrc;
SpectrumVis* m_spectrumVis;
explicit TCPSrcGUI(PluginAPI* pluginAPI, QWidget* parent = NULL);
~TCPSrcGUI();
void applySettings();
void addConnection(quint32 id, const QHostAddress& peerAddress, int peerPort);
void delConnection(quint32 id);
};
#endif // INCLUDE_TCPSRCGUI_H
+213
View File
@@ -0,0 +1,213 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TCPSrcGUI</class>
<widget class="RollupWidget" name="TCPSrcGUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>443</height>
</rect>
</property>
<property name="windowTitle">
<string>TCP Sample Source</string>
</property>
<widget class="QWidget" name="widget" native="true">
<property name="geometry">
<rect>
<x>10</x>
<y>5</y>
<width>201</width>
<height>142</height>
</rect>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>2</number>
</property>
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Sample Format</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="sampleFormat">
<item>
<property name="text">
<string>S8 I/Q</string>
</property>
</item>
<item>
<property name="text">
<string>S16LE I/Q</string>
</property>
</item>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="rfBandwidth">
<property name="text">
<string>20000</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>RF Bandwidth (Hz)</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Samplerate (Hz)</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="sampleRate">
<property name="text">
<string>25000</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>TCP Port</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLineEdit" name="tcpPort">
<property name="text">
<string>9999</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QPushButton" name="applyBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="spectrumBox" native="true">
<property name="geometry">
<rect>
<x>15</x>
<y>160</y>
<width>231</width>
<height>156</height>
</rect>
</property>
<property name="windowTitle">
<string>Channel Spectrum</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="GLSpectrum" name="glSpectrum" native="true"/>
</item>
<item>
<widget class="GLSpectrumGUI" name="spectrumGUI" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="connectedClientsBox" native="true">
<property name="geometry">
<rect>
<x>15</x>
<y>330</y>
<width>274</width>
<height>101</height>
</rect>
</property>
<property name="windowTitle">
<string>Connected Clients (0)</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QTreeWidget" name="connections">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="itemsExpandable">
<bool>false</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>IP:Port</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>GLSpectrum</class>
<extends>QWidget</extends>
<header>gui/glspectrum.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrumGUI</class>
<extends>QWidget</extends>
<header>gui/glspectrumgui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>RollupWidget</class>
<extends>QWidget</extends>
<header>gui/rollupwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>sampleFormat</tabstop>
<tabstop>tcpPort</tabstop>
<tabstop>sampleRate</tabstop>
<tabstop>rfBandwidth</tabstop>
<tabstop>applyBtn</tabstop>
<tabstop>connections</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
+53
View File
@@ -0,0 +1,53 @@
#include <QtPlugin>
#include <QAction>
#include "plugin/pluginapi.h"
#include "tcpsrcplugin.h"
#include "tcpsrcgui.h"
const PluginDescriptor TCPSrcPlugin::m_pluginDescriptor = {
QString("TCP Channel Source"),
QString("---"),
QString("(c) maintech GmbH (written by Christian Daniel)"),
QString("http://www.maintech.de"),
true,
QString("http://www.maintech.de")
};
TCPSrcPlugin::TCPSrcPlugin(QObject* parent) :
QObject(parent)
{
}
const PluginDescriptor& TCPSrcPlugin::getPluginDescriptor() const
{
return m_pluginDescriptor;
}
void TCPSrcPlugin::initPlugin(PluginAPI* pluginAPI)
{
m_pluginAPI = pluginAPI;
// register TCP Channel Source
QAction* action = new QAction(tr("&TCP Source"), this);
connect(action, SIGNAL(triggered()), this, SLOT(createInstanceTCPSrc()));
m_pluginAPI->registerChannel("de.maintech.sdrangelove.channel.tcpsrc", this, action);
}
PluginGUI* TCPSrcPlugin::createChannel(const QString& channelName)
{
if(channelName == "de.maintech.sdrangelove.channel.tcpsrc") {
TCPSrcGUI* gui = TCPSrcGUI::create(m_pluginAPI);
m_pluginAPI->registerChannelInstance("de.maintech.sdrangelove.channel.tcpsrc", gui);
m_pluginAPI->addChannelRollup(gui);
return gui;
} else {
return NULL;
}
}
void TCPSrcPlugin::createInstanceTCPSrc()
{
TCPSrcGUI* gui = TCPSrcGUI::create(m_pluginAPI);
m_pluginAPI->registerChannelInstance("de.maintech.sdrangelove.channel.tcpsrc", gui);
m_pluginAPI->addChannelRollup(gui);
}
+29
View File
@@ -0,0 +1,29 @@
#ifndef INCLUDE_TCPSRCPLUGIN_H
#define INCLUDE_TCPSRCPLUGIN_H
#include <QObject>
#include "plugin/plugininterface.h"
class TCPSrcPlugin : public QObject, PluginInterface {
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID "de.maintech.sdrangelove.demod.tcpsrc")
public:
explicit TCPSrcPlugin(QObject* parent = NULL);
const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI);
PluginGUI* createChannel(const QString& channelName);
private:
static const PluginDescriptor m_pluginDescriptor;
PluginAPI* m_pluginAPI;
private slots:
void createInstanceTCPSrc();
};
#endif // INCLUDE_TCPSRCPLUGIN_H
+47
View File
@@ -0,0 +1,47 @@
project(tetra)
set(tetra_SOURCES
tetrademod.cpp
tetrademodgui.cpp
tetraplugin.cpp
)
set(tetra_HEADERS
tetrademod.h
tetrademodgui.h
tetraplugin.h
)
set(tetra_FORMS
tetrademodgui.ui
)
include_directories(
.
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/include-gpl
${OPENGL_INCLUDE_DIR}
)
#include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
add_definitions(-DQT_PLUGIN)
add_definitions(-DQT_SHARED)
#qt5_wrap_cpp(tetra_HEADERS_MOC ${tetra_HEADERS})
qt5_wrap_ui(tetra_FORMS_HEADERS ${tetra_FORMS})
add_library(demodtetra SHARED
${tetra_SOURCES}
${tetra_HEADERS_MOC}
${tetra_FORMS_HEADERS}
)
target_link_libraries(demodtetra
${QT_LIBRARIES}
${OPENGL_LIBRARIES}
sdrbase
)
qt5_use_modules(demodtetra Core Widgets OpenGL Multimedia)
+106
View File
@@ -0,0 +1,106 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
// written by Christian Daniel //
// //
// 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 //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include "tetrademod.h"
#include "dsp/dspcommands.h"
MessageRegistrator TetraDemod::MsgConfigureTetraDemod::ID("MsgConfigureTetraDemod");
static FILE* f = NULL;
TetraDemod::TetraDemod(SampleSink* sampleSink) :
m_sampleSink(sampleSink)
{
m_sampleRate = 500000;
m_frequency = 0;
m_nco.setFreq(m_frequency, m_sampleRate);
m_interpolator.create(32, 32 * m_sampleRate, 36000);
m_sampleDistanceRemain = (Real)m_sampleRate / 36000.0;
}
TetraDemod::~TetraDemod()
{
}
void TetraDemod::configure(MessageQueue* messageQueue)
{
Message* cmd = MsgConfigureTetraDemod::create();
cmd->submit(messageQueue, this);
}
void TetraDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst)
{
size_t count = end - begin;
Complex ci;
bool consumed;
for(SampleVector::const_iterator it = begin; it < end; ++it) {
Complex c(it->real() / 32768.0, it->imag() / 32768.0);
c *= m_nco.nextIQ();
consumed = false;
if(m_interpolator.interpolate(&m_sampleDistanceRemain, c, &consumed, &ci)) {
m_sampleBuffer.push_back(Sample(ci.real() * 32768.0, ci.imag() * 32768.0));
m_sampleDistanceRemain += (Real)m_sampleRate / 36000.0;
}
}
if(f != NULL) {
fwrite(&m_sampleBuffer[0], m_sampleBuffer.size(), sizeof(m_sampleBuffer[0]), f);
}
if(m_sampleSink != NULL)
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), firstOfBurst);
m_sampleBuffer.clear();
}
void TetraDemod::start()
{
}
void TetraDemod::stop()
{
}
bool TetraDemod::handleMessage(Message* cmd)
{
if(cmd->id() == DSPSignalNotification::ID()) {
DSPSignalNotification* signal = (DSPSignalNotification*)cmd;
qDebug("%d samples/sec, %lld Hz offset", signal->getSampleRate(), signal->getFrequencyOffset());
m_sampleRate = signal->getSampleRate();
m_nco.setFreq(-signal->getFrequencyOffset(), m_sampleRate);
m_interpolator.create(32, m_sampleRate, 25000 / 2);
m_sampleDistanceRemain = m_sampleRate / 36000.0;
cmd->completed();
return true;
} else if(cmd->id() == MsgConfigureTetraDemod::ID()) {
if(f == NULL) {
f = fopen("/tmp/tetra.iq", "wb");
qDebug("started writing samples");
} else {
fclose(f);
f = NULL;
qDebug("stopped writing samples");
}
} else {
return false;
}
}
+67
View File
@@ -0,0 +1,67 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
// written by Christian Daniel //
// //
// 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 //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_TETRADEMOD_H
#define INCLUDE_TETRADEMOD_H
#include "dsp/samplesink.h"
#include "dsp/nco.h"
#include "dsp/interpolator.h"
#include "util/message.h"
class MessageQueue;
class TetraDemod : public SampleSink {
public:
TetraDemod(SampleSink* sampleSink);
~TetraDemod();
void configure(MessageQueue* messageQueue);
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst);
void start();
void stop();
bool handleMessage(Message* cmd);
private:
class MsgConfigureTetraDemod : public Message {
public:
static MessageRegistrator ID;
static MsgConfigureTetraDemod* create()
{
return new MsgConfigureTetraDemod();
}
private:
MsgConfigureTetraDemod() :
Message(ID())
{ }
};
int m_sampleRate;
int m_frequency;
NCO m_nco;
Interpolator m_interpolator;
Real m_sampleDistanceRemain;
SampleSink* m_sampleSink;
SampleVector m_sampleBuffer;
};
#endif // INCLUDE_TETRADEMOD_H
+110
View File
@@ -0,0 +1,110 @@
#include <QDockWidget>
#include <QMainWindow>
#include "tetrademodgui.h"
#include "ui_tetrademodgui.h"
#include "dsp/threadedsamplesink.h"
#include "dsp/channelizer.h"
#include "tetrademod.h"
#include "dsp/spectrumvis.h"
#include "gui/glspectrum.h"
#include "plugin/pluginapi.h"
TetraDemodGUI* TetraDemodGUI::create(PluginAPI* pluginAPI)
{
QDockWidget* dock = pluginAPI->createMainWindowDock(Qt::RightDockWidgetArea, tr("Tetra Demodulator"));
dock->setObjectName(QString::fromUtf8("Tetra Demodulator"));
TetraDemodGUI* gui = new TetraDemodGUI(pluginAPI, dock);
dock->setWidget(gui);
return gui;
}
void TetraDemodGUI::destroy()
{
delete m_dockWidget;
}
void TetraDemodGUI::setWidgetName(const QString& name)
{
m_dockWidget->setObjectName(name);
}
void TetraDemodGUI::resetToDefaults()
{
}
QByteArray TetraDemodGUI::serializeGeneral() const
{
return QByteArray();
}
bool TetraDemodGUI::deserializeGeneral(const QByteArray& data)
{
return false;
}
QByteArray TetraDemodGUI::serialize() const
{
return QByteArray();
}
bool TetraDemodGUI::deserialize(const QByteArray& data)
{
return false;
}
bool TetraDemodGUI::handleMessage(Message* message)
{
return false;
}
void TetraDemodGUI::viewChanged()
{
m_channelizer->configure(m_threadedSampleSink->getMessageQueue(), 36000, m_channelMarker->getCenterFrequency());
}
TetraDemodGUI::TetraDemodGUI(PluginAPI* pluginAPI, QDockWidget* dockWidget, QWidget* parent) :
PluginGUI(parent),
ui(new Ui::TetraDemodGUI),
m_pluginAPI(pluginAPI),
m_dockWidget(dockWidget)
{
ui->setupUi(this);
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_tetraDemod = new TetraDemod(m_spectrumVis);
m_channelizer = new Channelizer(m_tetraDemod);
m_threadedSampleSink = new ThreadedSampleSink(m_channelizer);
m_pluginAPI->addSampleSink(m_threadedSampleSink);
ui->glSpectrum->setCenterFrequency(0);
ui->glSpectrum->setSampleRate(36000);
ui->glSpectrum->setDisplayWaterfall(true);
ui->glSpectrum->setDisplayMaxHold(true);
m_spectrumVis->configure(m_threadedSampleSink->getMessageQueue(), 64, 10, FFTWindow::BlackmanHarris);
m_channelMarker = new ChannelMarker(this);
m_channelMarker->setColor(Qt::darkGreen);
m_channelMarker->setBandwidth(25000);
m_channelMarker->setCenterFrequency(0);
m_channelMarker->setVisible(true);
connect(m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged()));
m_pluginAPI->addChannelMarker(m_channelMarker);
viewChanged();
}
TetraDemodGUI::~TetraDemodGUI()
{
m_pluginAPI->removeSampleSink(m_threadedSampleSink);
delete m_threadedSampleSink;
delete m_channelizer;
delete m_tetraDemod;
delete m_spectrumVis;
delete m_channelMarker;
delete ui;
}
void TetraDemodGUI::on_test_clicked()
{
m_tetraDemod->configure(m_threadedSampleSink->getMessageQueue());
}
+56
View File
@@ -0,0 +1,56 @@
#ifndef INCLUDE_TETRADEMODGUI_H
#define INCLUDE_TETRADEMODGUI_H
#include "plugin/plugingui.h"
class QDockWidget;
class PluginAPI;
class ChannelMarker;
class ThreadedSampleSink;
class Channelizer;
class TetraDemod;
class SpectrumVis;
namespace Ui {
class TetraDemodGUI;
}
class TetraDemodGUI : public PluginGUI {
Q_OBJECT
public:
static TetraDemodGUI* create(PluginAPI* pluginAPI);
void destroy();
void setWidgetName(const QString& name);
void resetToDefaults();
QByteArray serializeGeneral() const;
bool deserializeGeneral(const QByteArray& data);
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
bool handleMessage(Message* message);
private slots:
void on_test_clicked();
void viewChanged();
private:
explicit TetraDemodGUI(PluginAPI* pluginAPI, QDockWidget* dockWidget, QWidget* parent = NULL);
~TetraDemodGUI();
Ui::TetraDemodGUI* ui;
PluginAPI* m_pluginAPI;
QDockWidget* m_dockWidget;
ChannelMarker* m_channelMarker;
ThreadedSampleSink* m_threadedSampleSink;
Channelizer* m_channelizer;
TetraDemod* m_tetraDemod;
SpectrumVis* m_spectrumVis;
};
#endif // INCLUDE_TETRADEMODGUI_H
+56
View File
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TetraDemodGUI</class>
<widget class="QWidget" name="TetraDemodGUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>200</width>
<height>179</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="GLSpectrum" name="glSpectrum" native="true">
<property name="minimumSize">
<size>
<width>200</width>
<height>150</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="test">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GLSpectrum</class>
<extends>QWidget</extends>
<header>gui/glspectrum.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
+50
View File
@@ -0,0 +1,50 @@
#include <QtPlugin>
#include <QAction>
#include "plugin/pluginapi.h"
#include "tetraplugin.h"
#include "tetrademodgui.h"
const PluginDescriptor TetraPlugin::m_pluginDescriptor = {
QString("Tetra Demodulator"),
QString("---"),
QString("(c) maintech GmbH (written by Christian Daniel)"),
QString("http://www.maintech.de"),
true,
QString("http://www.maintech.de")
};
TetraPlugin::TetraPlugin(QObject* parent) :
QObject(parent)
{
}
const PluginDescriptor& TetraPlugin::getPluginDescriptor() const
{
return m_pluginDescriptor;
}
void TetraPlugin::initPlugin(PluginAPI* pluginAPI)
{
m_pluginAPI = pluginAPI;
// register Tetra demodulator
QAction* action = new QAction(tr("&Tetra"), this);
connect(action, SIGNAL(triggered()), this, SLOT(createInstanceTetra()));
m_pluginAPI->registerDemodulator("de.maintech.sdrangelove.demod.tetra", this, action);
}
PluginGUI* TetraPlugin::createDemod(const QString& demodName)
{
if(demodName == "de.maintech.sdrangelove.demod.tetra") {
PluginGUI* gui = TetraDemodGUI::create(m_pluginAPI);
m_pluginAPI->registerDemodulatorInstance("de.maintech.sdrangelove.demod.tetra", gui);
return gui;
} else {
return NULL;
}
}
void TetraPlugin::createInstanceTetra()
{
m_pluginAPI->registerDemodulatorInstance("de.maintech.sdrangelove.demod.tetra", TetraDemodGUI::create(m_pluginAPI));
}
+29
View File
@@ -0,0 +1,29 @@
#ifndef INCLUDE_TETRAPLUGIN_H
#define INCLUDE_TETRAPLUGIN_H
#include <QObject>
#include "plugin/plugininterface.h"
class TetraPlugin : public QObject, PluginInterface {
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID "de.maintech.sdrangelove.demod.tetra")
public:
explicit TetraPlugin(QObject* parent = NULL);
const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI);
PluginGUI* createDemod(const QString& demodName);
private:
static const PluginDescriptor m_pluginDescriptor;
PluginAPI* m_pluginAPI;
private slots:
void createInstanceTetra();
};
#endif // INCLUDE_TETRAPLUGIN_H