mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-03-22 12:18:32 -04:00
Web API: added channel enumeration in /sdrangel GET. Partial implementation in channel plugins
This commit is contained in:
parent
30cd01cad0
commit
b91ad7c4b7
@ -36,6 +36,8 @@ ChannelAnalyzer::ChannelAnalyzer(DeviceSourceAPI *deviceAPI) :
|
||||
m_sampleSink(0),
|
||||
m_settingsMutex(QMutex::Recursive)
|
||||
{
|
||||
setObjectName("ChannelAnalyzer");
|
||||
|
||||
m_Bandwidth = 5000;
|
||||
m_LowCutoff = 300;
|
||||
m_spanLog2 = 3;
|
||||
@ -54,12 +56,14 @@ ChannelAnalyzer::ChannelAnalyzer(DeviceSourceAPI *deviceAPI) :
|
||||
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
|
||||
connect(m_channelizer, SIGNAL(inputSampleRateChanged()), this, SLOT(channelSampleRateChanged()));
|
||||
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
|
||||
m_deviceAPI->addChannelAPI(this);
|
||||
}
|
||||
|
||||
ChannelAnalyzer::~ChannelAnalyzer()
|
||||
{
|
||||
if (SSBFilter) delete SSBFilter;
|
||||
if (DSBFilter) delete DSBFilter;
|
||||
m_deviceAPI->removeChannelAPI(this);
|
||||
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
|
||||
delete m_threadedChannelizer;
|
||||
delete m_channelizer;
|
||||
|
@ -17,9 +17,11 @@
|
||||
#ifndef INCLUDE_CHANALYZER_H
|
||||
#define INCLUDE_CHANALYZER_H
|
||||
|
||||
#include <dsp/basebandsamplesink.h>
|
||||
#include <QMutex>
|
||||
#include <vector>
|
||||
|
||||
#include "dsp/basebandsamplesink.h"
|
||||
#include "channel/channelsinkapi.h"
|
||||
#include "dsp/ncof.h"
|
||||
#include "dsp/fftfilt.h"
|
||||
#include "audio/audiofifo.h"
|
||||
@ -31,7 +33,7 @@ class DeviceSourceAPI;
|
||||
class ThreadedBasebandSampleSink;
|
||||
class DownChannelizer;
|
||||
|
||||
class ChannelAnalyzer : public BasebandSampleSink {
|
||||
class ChannelAnalyzer : public BasebandSampleSink, public ChannelSinkAPI {
|
||||
public:
|
||||
class MsgConfigureChannelAnalyzer : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
@ -123,6 +125,10 @@ public:
|
||||
virtual void stop();
|
||||
virtual bool handleMessage(const Message& cmd);
|
||||
|
||||
virtual int getDeltaFrequency() const { return m_frequency; }
|
||||
virtual void getIdentifier(QString& id) { id = objectName(); }
|
||||
virtual void getTitle(QString& title) { title = objectName(); }
|
||||
|
||||
static const QString m_channelID;
|
||||
|
||||
private slots:
|
||||
|
@ -36,6 +36,8 @@ ChannelAnalyzerNG::ChannelAnalyzerNG(DeviceSourceAPI *deviceAPI) :
|
||||
m_sampleSink(0),
|
||||
m_settingsMutex(QMutex::Recursive)
|
||||
{
|
||||
setObjectName("ChannelAnalyzerNG");
|
||||
|
||||
m_undersampleCount = 0;
|
||||
m_sum = 0;
|
||||
m_usb = true;
|
||||
@ -49,6 +51,7 @@ ChannelAnalyzerNG::ChannelAnalyzerNG(DeviceSourceAPI *deviceAPI) :
|
||||
m_channelizer = new DownChannelizer(this);
|
||||
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
|
||||
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
|
||||
m_deviceAPI->addChannelAPI(this);
|
||||
|
||||
apply(true);
|
||||
}
|
||||
@ -57,6 +60,7 @@ ChannelAnalyzerNG::~ChannelAnalyzerNG()
|
||||
{
|
||||
if (SSBFilter) delete SSBFilter;
|
||||
if (DSBFilter) delete DSBFilter;
|
||||
m_deviceAPI->removeChannelAPI(this);
|
||||
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
|
||||
delete m_threadedChannelizer;
|
||||
delete m_channelizer;
|
||||
|
@ -17,10 +17,11 @@
|
||||
#ifndef INCLUDE_CHANALYZERNG_H
|
||||
#define INCLUDE_CHANALYZERNG_H
|
||||
|
||||
#include <dsp/basebandsamplesink.h>
|
||||
#include <QMutex>
|
||||
#include <vector>
|
||||
|
||||
#include "dsp/basebandsamplesink.h"
|
||||
#include "channel/channelsinkapi.h"
|
||||
#include "dsp/interpolator.h"
|
||||
#include "dsp/ncof.h"
|
||||
#include "dsp/fftfilt.h"
|
||||
@ -33,7 +34,7 @@ class DeviceSourceAPI;
|
||||
class ThreadedBasebandSampleSink;
|
||||
class DownChannelizer;
|
||||
|
||||
class ChannelAnalyzerNG : public BasebandSampleSink {
|
||||
class ChannelAnalyzerNG : public BasebandSampleSink, public ChannelSinkAPI {
|
||||
public:
|
||||
class MsgConfigureChannelAnalyzer : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
@ -143,6 +144,10 @@ public:
|
||||
virtual void stop();
|
||||
virtual bool handleMessage(const Message& cmd);
|
||||
|
||||
virtual int getDeltaFrequency() const { return m_running.m_frequency; }
|
||||
virtual void getIdentifier(QString& id) { id = objectName(); }
|
||||
virtual void getTitle(QString& title) { title = objectName(); }
|
||||
|
||||
static const QString m_channelID;
|
||||
|
||||
private:
|
||||
|
@ -61,6 +61,7 @@ AMDemod::AMDemod(DeviceSourceAPI *deviceAPI) :
|
||||
m_channelizer = new DownChannelizer(this);
|
||||
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
|
||||
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
|
||||
m_deviceAPI->addChannelAPI(this);
|
||||
|
||||
applySettings(m_settings, true);
|
||||
}
|
||||
@ -69,6 +70,7 @@ AMDemod::~AMDemod()
|
||||
{
|
||||
DSPEngine::instance()->removeAudioSink(&m_audioFifo);
|
||||
delete m_udpBufferAudio;
|
||||
m_deviceAPI->removeChannelAPI(this);
|
||||
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
|
||||
delete m_threadedChannelizer;
|
||||
delete m_channelizer;
|
||||
|
@ -17,9 +17,11 @@
|
||||
#ifndef INCLUDE_AMDEMOD_H
|
||||
#define INCLUDE_AMDEMOD_H
|
||||
|
||||
#include <dsp/basebandsamplesink.h>
|
||||
#include <QMutex>
|
||||
#include <vector>
|
||||
|
||||
#include "dsp/basebandsamplesink.h"
|
||||
#include "channel/channelsinkapi.h"
|
||||
#include "dsp/nco.h"
|
||||
#include "dsp/interpolator.h"
|
||||
#include "dsp/movingaverage.h"
|
||||
@ -33,7 +35,7 @@ class DeviceSourceAPI;
|
||||
class DownChannelizer;
|
||||
class ThreadedBasebandSampleSink;
|
||||
|
||||
class AMDemod : public BasebandSampleSink {
|
||||
class AMDemod : public BasebandSampleSink, public ChannelSinkAPI {
|
||||
Q_OBJECT
|
||||
public:
|
||||
class MsgConfigureAMDemod : public Message {
|
||||
@ -90,6 +92,10 @@ public:
|
||||
virtual void stop();
|
||||
virtual bool handleMessage(const Message& cmd);
|
||||
|
||||
virtual int getDeltaFrequency() const { return m_settings.m_inputFrequencyOffset; }
|
||||
virtual void getIdentifier(QString& id) { id = objectName(); }
|
||||
virtual void getTitle(QString& title) { title = m_settings.m_title; }
|
||||
|
||||
double getMagSq() const { return m_magsq; }
|
||||
bool getSquelchOpen() const { return m_squelchOpen; }
|
||||
|
||||
|
@ -171,8 +171,9 @@ void AMDemodGUI::onMenuDialogCalled(const QPoint &p)
|
||||
m_settings.m_udpAddress = m_channelMarker.getUDPAddress(),
|
||||
m_settings.m_udpPort = m_channelMarker.getUDPSendPort(),
|
||||
m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
|
||||
m_settings.m_title = m_channelMarker.getTitle();
|
||||
|
||||
setWindowTitle(m_channelMarker.getTitle());
|
||||
setWindowTitle(m_settings.m_title);
|
||||
setTitleColor(m_settings.m_rgbColor);
|
||||
displayUDPAddress();
|
||||
|
||||
@ -258,6 +259,7 @@ void AMDemodGUI::displaySettings()
|
||||
m_channelMarker.blockSignals(true);
|
||||
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
|
||||
m_channelMarker.setBandwidth(m_settings.m_rfBandwidth);
|
||||
m_channelMarker.setTitle(m_settings.m_title);
|
||||
m_channelMarker.blockSignals(false);
|
||||
m_channelMarker.setColor(m_settings.m_rgbColor); // activate signal on the last setting only
|
||||
|
||||
|
@ -41,6 +41,7 @@ void AMDemodSettings::resetToDefaults()
|
||||
m_udpAddress = "127.0.0.1";
|
||||
m_udpPort = 9999;
|
||||
m_rgbColor = QColor(255, 255, 0).rgb();
|
||||
m_title = "AM Demodulator";
|
||||
}
|
||||
|
||||
QByteArray AMDemodSettings::serialize() const
|
||||
@ -57,6 +58,7 @@ QByteArray AMDemodSettings::serialize() const
|
||||
|
||||
s.writeU32(7, m_rgbColor);
|
||||
s.writeBool(8, m_bandpassEnable);
|
||||
s.writeString(9, m_title);
|
||||
return s.final();
|
||||
}
|
||||
|
||||
@ -91,6 +93,8 @@ bool AMDemodSettings::deserialize(const QByteArray& data)
|
||||
|
||||
d.readU32(7, &m_rgbColor);
|
||||
d.readBool(8, &m_bandpassEnable, false);
|
||||
d.readString(9, &m_title, "AM Demodulator");
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -35,6 +35,7 @@ struct AMDemodSettings
|
||||
QString m_udpAddress;
|
||||
quint16 m_udpPort;
|
||||
quint32 m_rgbColor;
|
||||
QString m_title;
|
||||
Serializable *m_channelMarker;
|
||||
|
||||
AMDemodSettings();
|
||||
|
@ -90,6 +90,7 @@ ATVDemod::ATVDemod(DeviceSourceAPI *deviceAPI) :
|
||||
m_channelizer = new DownChannelizer(this);
|
||||
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
|
||||
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
|
||||
m_deviceAPI->addChannelAPI(this);
|
||||
|
||||
connect(m_channelizer, SIGNAL(inputSampleRateChanged()), this, SLOT(channelSampleRateChanged()));
|
||||
|
||||
@ -98,6 +99,7 @@ ATVDemod::ATVDemod(DeviceSourceAPI *deviceAPI) :
|
||||
|
||||
ATVDemod::~ATVDemod()
|
||||
{
|
||||
m_deviceAPI->removeChannelAPI(this);
|
||||
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
|
||||
delete m_threadedChannelizer;
|
||||
delete m_channelizer;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "dsp/basebandsamplesink.h"
|
||||
#include "channel/channelsinkapi.h"
|
||||
#include "dsp/devicesamplesource.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
#include "dsp/downchannelizer.h"
|
||||
@ -42,7 +43,7 @@ class DeviceSourceAPI;
|
||||
class ThreadedBasebandSampleSink;
|
||||
class DownChannelizer;
|
||||
|
||||
class ATVDemod : public BasebandSampleSink
|
||||
class ATVDemod : public BasebandSampleSink, public ChannelSinkAPI
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -222,6 +223,10 @@ public:
|
||||
virtual void stop();
|
||||
virtual bool handleMessage(const Message& cmd);
|
||||
|
||||
virtual int getDeltaFrequency() const { return m_rfRunning.m_intFrequencyOffset; }
|
||||
virtual void getIdentifier(QString& id) { id = objectName(); }
|
||||
virtual void getTitle(QString& title) { title = objectName(); }
|
||||
|
||||
void setATVScreen(ATVScreenInterface *objScreen);
|
||||
int getSampleRate();
|
||||
int getEffectiveSampleRate();
|
||||
|
@ -85,6 +85,7 @@ BFMDemod::BFMDemod(DeviceSourceAPI *deviceAPI) :
|
||||
m_channelizer = new DownChannelizer(this);
|
||||
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
|
||||
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
|
||||
m_deviceAPI->addChannelAPI(this);
|
||||
|
||||
applySettings(m_settings, true);
|
||||
}
|
||||
@ -99,6 +100,7 @@ BFMDemod::~BFMDemod()
|
||||
DSPEngine::instance()->removeAudioSink(&m_audioFifo);
|
||||
delete m_udpBufferAudio;
|
||||
|
||||
m_deviceAPI->removeChannelAPI(this);
|
||||
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
|
||||
delete m_threadedChannelizer;
|
||||
delete m_channelizer;
|
||||
|
@ -18,9 +18,11 @@
|
||||
#ifndef INCLUDE_BFMDEMOD_H
|
||||
#define INCLUDE_BFMDEMOD_H
|
||||
|
||||
#include <dsp/basebandsamplesink.h>
|
||||
#include <QMutex>
|
||||
#include <vector>
|
||||
|
||||
#include "dsp/basebandsamplesink.h"
|
||||
#include "channel/channelsinkapi.h"
|
||||
#include "dsp/nco.h"
|
||||
#include "dsp/interpolator.h"
|
||||
#include "dsp/lowpass.h"
|
||||
@ -42,7 +44,7 @@ class DeviceSourceAPI;
|
||||
class ThreadedBasebandSampleSink;
|
||||
class DownChannelizer;
|
||||
|
||||
class BFMDemod : public BasebandSampleSink {
|
||||
class BFMDemod : public BasebandSampleSink, public ChannelSinkAPI {
|
||||
public:
|
||||
class MsgConfigureBFMDemod : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
@ -120,6 +122,10 @@ public:
|
||||
virtual void stop();
|
||||
virtual bool handleMessage(const Message& cmd);
|
||||
|
||||
virtual int getDeltaFrequency() const { return m_settings.m_inputFrequencyOffset; }
|
||||
virtual void getIdentifier(QString& id) { id = objectName(); }
|
||||
virtual void getTitle(QString& title) { title = m_settings.m_title; }
|
||||
|
||||
double getMagSq() const { return m_magsq; }
|
||||
|
||||
bool getPilotLock() const { return m_pilotPLL.locked(); }
|
||||
|
@ -314,8 +314,9 @@ void BFMDemodGUI::onMenuDialogCalled(const QPoint &p)
|
||||
m_settings.m_udpAddress = m_channelMarker.getUDPAddress(),
|
||||
m_settings.m_udpPort = m_channelMarker.getUDPSendPort(),
|
||||
m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
|
||||
m_settings.m_title = m_channelMarker.getTitle();
|
||||
|
||||
setWindowTitle(m_channelMarker.getTitle());
|
||||
setWindowTitle(m_settings.m_title);
|
||||
setTitleColor(m_settings.m_rgbColor);
|
||||
displayUDPAddress();
|
||||
|
||||
@ -426,6 +427,7 @@ void BFMDemodGUI::displaySettings()
|
||||
m_channelMarker.blockSignals(true);
|
||||
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
|
||||
m_channelMarker.setBandwidth(m_settings.m_rfBandwidth);
|
||||
m_channelMarker.setTitle(m_settings.m_title);
|
||||
m_channelMarker.blockSignals(false);
|
||||
m_channelMarker.setColor(m_settings.m_rgbColor); // activate signal on the last setting only
|
||||
|
||||
|
@ -51,6 +51,7 @@ void BFMDemodSettings::resetToDefaults()
|
||||
m_udpAddress = "127.0.0.1";
|
||||
m_udpPort = 9999;
|
||||
m_rgbColor = QColor(80, 120, 228).rgb();
|
||||
m_title = "Broadcast FM Demod";
|
||||
}
|
||||
|
||||
QByteArray BFMDemodSettings::serialize() const
|
||||
@ -74,6 +75,8 @@ QByteArray BFMDemodSettings::serialize() const
|
||||
s.writeBlob(11, m_channelMarker->serialize());
|
||||
}
|
||||
|
||||
s.writeString(12, m_title);
|
||||
|
||||
return s.final();
|
||||
}
|
||||
|
||||
@ -120,6 +123,8 @@ bool BFMDemodSettings::deserialize(const QByteArray& data)
|
||||
m_channelMarker->deserialize(bytetmp);
|
||||
}
|
||||
|
||||
d.readString(12, &m_title, "Broadcast FM Demod");
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -36,6 +36,7 @@ struct BFMDemodSettings
|
||||
QString m_udpAddress;
|
||||
quint16 m_udpPort;
|
||||
quint32 m_rgbColor;
|
||||
QString m_title;
|
||||
|
||||
Serializable *m_channelMarker;
|
||||
Serializable *m_spectrumGUI;
|
||||
|
@ -6,6 +6,9 @@ set(sdrbase_SOURCES
|
||||
audio/audiooutput.cpp
|
||||
audio/audioinput.cpp
|
||||
|
||||
channel/channelsinkapi.cpp
|
||||
channel/channelsourceapi.cpp
|
||||
|
||||
dsp/afsquelch.cpp
|
||||
dsp/agc.cpp
|
||||
dsp/downchannelizer.cpp
|
||||
@ -78,6 +81,9 @@ set(sdrbase_HEADERS
|
||||
audio/audiooutput.h
|
||||
audio/audioinput.h
|
||||
|
||||
channel/channelsinkapi.h
|
||||
channel/channelsourceapi.h
|
||||
|
||||
dsp/afsquelch.h
|
||||
dsp/downchannelizer.h
|
||||
dsp/upchannelizer.h
|
||||
|
23
sdrbase/channel/channelsinkapi.cpp
Normal file
23
sdrbase/channel/channelsinkapi.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// API for Rx channels //
|
||||
// //
|
||||
// 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 "channelsinkapi.h"
|
||||
|
||||
ChannelSinkAPI::ChannelSinkAPI() :
|
||||
m_indexInDeviceSet(-1)
|
||||
{ }
|
43
sdrbase/channel/channelsinkapi.h
Normal file
43
sdrbase/channel/channelsinkapi.h
Normal file
@ -0,0 +1,43 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// API for Rx channels //
|
||||
// //
|
||||
// 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 SDRBASE_CHANNEL_CHANNELSINKAPI_H_
|
||||
#define SDRBASE_CHANNEL_CHANNELSINKAPI_H_
|
||||
|
||||
#include <QString>
|
||||
#include "util/export.h"
|
||||
|
||||
class SDRANGEL_API ChannelSinkAPI {
|
||||
public:
|
||||
ChannelSinkAPI();
|
||||
virtual ~ChannelSinkAPI() {}
|
||||
|
||||
virtual int getDeltaFrequency() const = 0;
|
||||
virtual void getIdentifier(QString& id) = 0;
|
||||
virtual void getTitle(QString& title) = 0;
|
||||
|
||||
int getIndexInDeviceSet() const { return m_indexInDeviceSet; }
|
||||
void setIndexInDeviceSet(int indexInDeviceSet) { m_indexInDeviceSet = indexInDeviceSet; }
|
||||
|
||||
private:
|
||||
int m_indexInDeviceSet;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* SDRBASE_CHANNEL_CHANNELSINKAPI_H_ */
|
24
sdrbase/channel/channelsourceapi.cpp
Normal file
24
sdrbase/channel/channelsourceapi.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// API for Tx channels //
|
||||
// //
|
||||
// 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 "channelsourceapi.h"
|
||||
|
||||
ChannelSourceAPI::ChannelSourceAPI() :
|
||||
m_indexInDeviceSet(-1)
|
||||
{ }
|
||||
|
43
sdrbase/channel/channelsourceapi.h
Normal file
43
sdrbase/channel/channelsourceapi.h
Normal file
@ -0,0 +1,43 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// API for Tx channels //
|
||||
// //
|
||||
// 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 SDRBASE_CHANNEL_CHANNELSOURCEAPI_H_
|
||||
#define SDRBASE_CHANNEL_CHANNELSOURCEAPI_H_
|
||||
|
||||
#include <QString>
|
||||
#include "util/export.h"
|
||||
|
||||
class SDRANGEL_API ChannelSourceAPI {
|
||||
public:
|
||||
ChannelSourceAPI();
|
||||
virtual ~ChannelSourceAPI() {}
|
||||
|
||||
virtual int getDeltaFrequency() const = 0;
|
||||
virtual void getIdentifier(QString& id) = 0;
|
||||
virtual void getTitle(QString& title) = 0;
|
||||
|
||||
int getIndexInDeviceSet() const { return m_indexInDeviceSet; }
|
||||
void setIndexInDeviceSet(int indexInDeviceSet) { m_indexInDeviceSet = indexInDeviceSet; }
|
||||
|
||||
private:
|
||||
int m_indexInDeviceSet;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* SDRBASE_CHANNEL_CHANNELSOURCEAPI_H_ */
|
@ -21,6 +21,7 @@
|
||||
#include "plugin/plugininterface.h"
|
||||
#include "settings/preset.h"
|
||||
#include "dsp/dspengine.h"
|
||||
#include "channel/channelsourceapi.h"
|
||||
|
||||
DeviceSinkAPI::DeviceSinkAPI(int deviceTabIndex,
|
||||
DSPDeviceSinkEngine *deviceSinkEngine) :
|
||||
@ -71,6 +72,38 @@ void DeviceSinkAPI::removeThreadedSource(ThreadedBasebandSampleSource* source)
|
||||
m_deviceSinkEngine->removeThreadedSource(source);
|
||||
}
|
||||
|
||||
void DeviceSinkAPI::addChannelAPI(ChannelSourceAPI* channelAPI)
|
||||
{
|
||||
m_channelAPIs.append(channelAPI);
|
||||
renumerateChannels();
|
||||
}
|
||||
|
||||
void DeviceSinkAPI::removeChannelAPI(ChannelSourceAPI* channelAPI)
|
||||
{
|
||||
if (m_channelAPIs.removeOne(channelAPI)) {
|
||||
renumerateChannels();
|
||||
}
|
||||
|
||||
channelAPI->setIndexInDeviceSet(-1);
|
||||
}
|
||||
|
||||
ChannelSourceAPI *DeviceSinkAPI::getChanelAPIAt(int index)
|
||||
{
|
||||
if (index < m_channelAPIs.size()) {
|
||||
return m_channelAPIs.at(index);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceSinkAPI::renumerateChannels()
|
||||
{
|
||||
for (int i = 0; i < m_channelAPIs.size(); ++i) {
|
||||
m_channelAPIs.at(i)->setIndexInDeviceSet(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32_t DeviceSinkAPI::getNumberOfSources()
|
||||
{
|
||||
return m_deviceSinkEngine->getNumberOfSources();
|
||||
|
@ -31,6 +31,7 @@ class PluginInstanceGUI;
|
||||
class PluginInterface;
|
||||
class Preset;
|
||||
class DeviceSourceAPI;
|
||||
class ChannelSourceAPI;
|
||||
|
||||
class SDRANGEL_API DeviceSinkAPI : public QObject {
|
||||
Q_OBJECT
|
||||
@ -47,6 +48,8 @@ public:
|
||||
void removeSource(BasebandSampleSource* sink); //!< Remove a baseband sample source from device engine
|
||||
void addThreadedSource(ThreadedBasebandSampleSource* sink); //!< Add a baseband sample source that will run on its own thread to device engine
|
||||
void removeThreadedSource(ThreadedBasebandSampleSource* sink); //!< Remove a baseband sample source that runs on its own thread from device engine
|
||||
void addChannelAPI(ChannelSourceAPI* channelAPI);
|
||||
void removeChannelAPI(ChannelSourceAPI* channelAPI);
|
||||
uint32_t getNumberOfSources();
|
||||
void setSampleSink(DeviceSampleSink* sink); //!< Set device engine sample sink type
|
||||
DeviceSampleSink *getSampleSink(); //!< Return pointer to the device sample sink
|
||||
@ -81,6 +84,8 @@ public:
|
||||
PluginInterface *getPluginInterface() { return m_pluginInterface; }
|
||||
PluginInstanceGUI *getSampleSinkPluginInstanceGUI() { return m_sampleSinkPluginInstanceUI; }
|
||||
void getDeviceEngineStateStr(QString& state);
|
||||
ChannelSourceAPI *getChanelAPIAt(int index);
|
||||
int getNbChannels() const { return m_channelAPIs.size(); }
|
||||
|
||||
void registerChannelInstance(const QString& channelName, PluginInstanceGUI* pluginGUI);
|
||||
void removeChannelInstance(PluginInstanceGUI* pluginGUI);
|
||||
@ -125,7 +130,12 @@ protected:
|
||||
bool m_isBuddyLeader;
|
||||
const QTimer& m_masterTimer; //!< This is the DSPEngine master timer
|
||||
|
||||
QList<ChannelSourceAPI*> m_channelAPIs;
|
||||
|
||||
friend class DeviceSourceAPI;
|
||||
|
||||
private:
|
||||
void renumerateChannels();
|
||||
};
|
||||
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "plugin/plugininterface.h"
|
||||
#include "settings/preset.h"
|
||||
#include "dsp/dspengine.h"
|
||||
#include "channel/channelsinkapi.h"
|
||||
|
||||
DeviceSourceAPI::DeviceSourceAPI(int deviceTabIndex,
|
||||
DSPDeviceSourceEngine *deviceSourceEngine) :
|
||||
@ -61,6 +62,37 @@ void DeviceSourceAPI::removeThreadedSink(ThreadedBasebandSampleSink* sink)
|
||||
m_deviceSourceEngine->removeThreadedSink(sink);
|
||||
}
|
||||
|
||||
void DeviceSourceAPI::addChannelAPI(ChannelSinkAPI* channelAPI)
|
||||
{
|
||||
m_channelAPIs.append(channelAPI);
|
||||
renumerateChannels();
|
||||
}
|
||||
|
||||
void DeviceSourceAPI::removeChannelAPI(ChannelSinkAPI* channelAPI)
|
||||
{
|
||||
if (m_channelAPIs.removeOne(channelAPI)) {
|
||||
renumerateChannels();
|
||||
}
|
||||
|
||||
channelAPI->setIndexInDeviceSet(-1);
|
||||
}
|
||||
|
||||
ChannelSinkAPI *DeviceSourceAPI::getChanelAPIAt(int index)
|
||||
{
|
||||
if (index < m_channelAPIs.size()) {
|
||||
return m_channelAPIs.at(index);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceSourceAPI::renumerateChannels()
|
||||
{
|
||||
for (int i = 0; i < m_channelAPIs.size(); ++i) {
|
||||
m_channelAPIs.at(i)->setIndexInDeviceSet(i);
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceSourceAPI::setSampleSource(DeviceSampleSource* source)
|
||||
{
|
||||
m_deviceSourceEngine->setSource(source);
|
||||
|
@ -33,6 +33,7 @@ class PluginInstanceGUI;
|
||||
class PluginInterface;
|
||||
class Preset;
|
||||
class DeviceSinkAPI;
|
||||
class ChannelSinkAPI;
|
||||
|
||||
class SDRANGEL_API DeviceSourceAPI : public QObject {
|
||||
Q_OBJECT
|
||||
@ -47,6 +48,8 @@ public:
|
||||
void removeSink(BasebandSampleSink* sink); //!< Remove a sample sink from device engine
|
||||
void addThreadedSink(ThreadedBasebandSampleSink* sink); //!< Add a sample sink that will run on its own thread to device engine
|
||||
void removeThreadedSink(ThreadedBasebandSampleSink* sink); //!< Remove a sample sink that runs on its own thread from device engine
|
||||
void addChannelAPI(ChannelSinkAPI* channelAPI);
|
||||
void removeChannelAPI(ChannelSinkAPI* channelAPI);
|
||||
void setSampleSource(DeviceSampleSource* source); //!< Set device sample source
|
||||
DeviceSampleSource *getSampleSource(); //!< Return pointer to the device sample source
|
||||
bool initAcquisition(); //!< Initialize device engine acquisition sequence
|
||||
@ -81,6 +84,8 @@ public:
|
||||
PluginInterface *getPluginInterface() { return m_pluginInterface; }
|
||||
PluginInstanceGUI *getSampleSourcePluginInstanceGUI() { return m_sampleSourcePluginInstanceUI; }
|
||||
void getDeviceEngineStateStr(QString& state);
|
||||
ChannelSinkAPI *getChanelAPIAt(int index);
|
||||
int getNbChannels() const { return m_channelAPIs.size(); }
|
||||
|
||||
void loadSourceSettings(const Preset* preset);
|
||||
void saveSourceSettings(Preset* preset);
|
||||
@ -121,7 +126,12 @@ protected:
|
||||
bool m_isBuddyLeader;
|
||||
const QTimer& m_masterTimer; //!< This is the DSPEngine master timer
|
||||
|
||||
QList<ChannelSinkAPI*> m_channelAPIs;
|
||||
|
||||
friend class DeviceSinkAPI;
|
||||
|
||||
private:
|
||||
void renumerateChannels();
|
||||
};
|
||||
|
||||
|
||||
|
@ -51,6 +51,8 @@ SOURCES += audio/audiodeviceinfo.cpp\
|
||||
audio/audiofifo.cpp\
|
||||
audio/audiooutput.cpp\
|
||||
audio/audioinput.cpp\
|
||||
channel/channelsinkapi.cpp\
|
||||
channel/channelsourceapi.cpp\
|
||||
device/devicesourceapi.cpp\
|
||||
device/devicesinkapi.cpp\
|
||||
device/deviceenumerator.cpp\
|
||||
@ -114,6 +116,8 @@ HEADERS += audio/audiodeviceinfo.h\
|
||||
audio/audiofifo.h\
|
||||
audio/audiooutput.h\
|
||||
audio/audioinput.h\
|
||||
channel/channelsinkapi.h\
|
||||
channel/channelsourceapi.h\
|
||||
device/devicesourceapi.h\
|
||||
device/devicesinkapi.h\
|
||||
device/deviceenumerator.h\
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "device/deviceuiset.h"
|
||||
#include "dsp/devicesamplesource.h"
|
||||
#include "dsp/devicesamplesink.h"
|
||||
#include "channel/channelsinkapi.h"
|
||||
#include "channel/channelsourceapi.h"
|
||||
|
||||
#include "SWGInstanceSummaryResponse.h"
|
||||
#include "SWGErrorResponse.h"
|
||||
@ -86,7 +88,18 @@ int WebAPIAdapterGUI::instanceSummary(
|
||||
samplingDevice->setBandwidth(sampleSink->getSampleRate());
|
||||
}
|
||||
|
||||
deviceSet->back()->setChannelcount(0);
|
||||
deviceSet->back()->setChannelcount((*it)->m_deviceSinkAPI->getNbChannels());
|
||||
QList<Swagger::SWGChannel*> *channels = deviceSet->back()->getChannels();
|
||||
|
||||
for (int i = 0; i < deviceSet->back()->getChannelcount(); i++)
|
||||
{
|
||||
channels->append(new Swagger::SWGChannel);
|
||||
ChannelSourceAPI *channel = (*it)->m_deviceSinkAPI->getChanelAPIAt(i);
|
||||
channels->back()->setDeltaFrequency(channel->getDeltaFrequency());
|
||||
channels->back()->setIndex(channel->getIndexInDeviceSet());
|
||||
channel->getIdentifier(*channels->back()->getId());
|
||||
channel->getTitle(*channels->back()->getTitle());
|
||||
}
|
||||
}
|
||||
|
||||
if ((*it)->m_deviceSourceEngine) // Rx data
|
||||
@ -104,7 +117,18 @@ int WebAPIAdapterGUI::instanceSummary(
|
||||
samplingDevice->setBandwidth(sampleSource->getSampleRate());
|
||||
}
|
||||
|
||||
deviceSet->back()->setChannelcount(0);
|
||||
deviceSet->back()->setChannelcount((*it)->m_deviceSourceAPI->getNbChannels());
|
||||
QList<Swagger::SWGChannel*> *channels = deviceSet->back()->getChannels();
|
||||
|
||||
for (int i = 0; i < deviceSet->back()->getChannelcount(); i++)
|
||||
{
|
||||
channels->append(new Swagger::SWGChannel);
|
||||
ChannelSinkAPI *channel = (*it)->m_deviceSourceAPI->getChanelAPIAt(i);
|
||||
channels->back()->setDeltaFrequency(channel->getDeltaFrequency());
|
||||
channels->back()->setIndex(channel->getIndexInDeviceSet());
|
||||
channel->getIdentifier(*channels->back()->getId());
|
||||
channel->getTitle(*channels->back()->getTitle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -599,6 +599,7 @@ definitions:
|
||||
required:
|
||||
- index
|
||||
- id
|
||||
- title
|
||||
- deltaFrequency
|
||||
properties:
|
||||
index:
|
||||
@ -607,6 +608,9 @@ definitions:
|
||||
id:
|
||||
description: "Key to identify the type of channel"
|
||||
type: string
|
||||
title:
|
||||
description: "Freeform title of the channel"
|
||||
type: string
|
||||
deltaFrequency:
|
||||
description: "Channel shift frequency in Hz from the center of baseband"
|
||||
type: integer
|
||||
|
@ -737,7 +737,7 @@ margin-bottom: 20px;
|
||||
"description" : "Audio devices selected"
|
||||
};
|
||||
defs.Channel = {
|
||||
"required" : [ "deltaFrequency", "id", "index" ],
|
||||
"required" : [ "deltaFrequency", "id", "index", "title" ],
|
||||
"properties" : {
|
||||
"index" : {
|
||||
"type" : "integer",
|
||||
@ -747,6 +747,10 @@ margin-bottom: 20px;
|
||||
"type" : "string",
|
||||
"description" : "Key to identify the type of channel"
|
||||
},
|
||||
"title" : {
|
||||
"type" : "string",
|
||||
"description" : "Freeform title of the channel"
|
||||
},
|
||||
"deltaFrequency" : {
|
||||
"type" : "integer",
|
||||
"description" : "Channel shift frequency in Hz from the center of baseband"
|
||||
@ -7293,7 +7297,7 @@ except ApiException as e:
|
||||
</div>
|
||||
<div id="generator">
|
||||
<div class="content">
|
||||
Generated 2017-11-19T00:43:35.861+01:00
|
||||
Generated 2017-11-19T03:28:56.995+01:00
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -39,6 +39,7 @@ void
|
||||
SWGChannel::init() {
|
||||
index = 0;
|
||||
id = new QString("");
|
||||
title = new QString("");
|
||||
delta_frequency = 0;
|
||||
}
|
||||
|
||||
@ -50,6 +51,10 @@ SWGChannel::cleanup() {
|
||||
delete id;
|
||||
}
|
||||
|
||||
if(title != nullptr) {
|
||||
delete title;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SWGChannel*
|
||||
@ -65,6 +70,7 @@ void
|
||||
SWGChannel::fromJsonObject(QJsonObject &pJson) {
|
||||
::Swagger::setValue(&index, pJson["index"], "qint32", "");
|
||||
::Swagger::setValue(&id, pJson["id"], "QString", "QString");
|
||||
::Swagger::setValue(&title, pJson["title"], "QString", "QString");
|
||||
::Swagger::setValue(&delta_frequency, pJson["deltaFrequency"], "qint32", "");
|
||||
}
|
||||
|
||||
@ -86,6 +92,8 @@ SWGChannel::asJsonObject() {
|
||||
|
||||
toJsonValue(QString("id"), id, obj, QString("QString"));
|
||||
|
||||
toJsonValue(QString("title"), title, obj, QString("QString"));
|
||||
|
||||
obj->insert("deltaFrequency", QJsonValue(delta_frequency));
|
||||
|
||||
return obj;
|
||||
@ -109,6 +117,15 @@ SWGChannel::setId(QString* id) {
|
||||
this->id = id;
|
||||
}
|
||||
|
||||
QString*
|
||||
SWGChannel::getTitle() {
|
||||
return title;
|
||||
}
|
||||
void
|
||||
SWGChannel::setTitle(QString* title) {
|
||||
this->title = title;
|
||||
}
|
||||
|
||||
qint32
|
||||
SWGChannel::getDeltaFrequency() {
|
||||
return delta_frequency;
|
||||
|
@ -48,6 +48,9 @@ public:
|
||||
QString* getId();
|
||||
void setId(QString* id);
|
||||
|
||||
QString* getTitle();
|
||||
void setTitle(QString* title);
|
||||
|
||||
qint32 getDeltaFrequency();
|
||||
void setDeltaFrequency(qint32 delta_frequency);
|
||||
|
||||
@ -55,6 +58,7 @@ public:
|
||||
private:
|
||||
qint32 index;
|
||||
QString* id;
|
||||
QString* title;
|
||||
qint32 delta_frequency;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user