mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-03-12 11:09:35 -04:00
Interferometer (3): plugin
This commit is contained in:
parent
170e1f59a7
commit
c1b03bfc42
@ -1,6 +1,7 @@
|
||||
project(interferometer)
|
||||
|
||||
set(interferometer_SOURCES
|
||||
interferometerplugin.cpp
|
||||
interferometer.cpp
|
||||
interferometercorr.cpp
|
||||
interferometersettings.cpp
|
||||
@ -10,6 +11,7 @@ set(interferometer_SOURCES
|
||||
)
|
||||
|
||||
set(interferometer_HEADERS
|
||||
interferometerplugin.h
|
||||
interferometer.h
|
||||
interferometercorr.h
|
||||
interferometersettings.h
|
||||
|
||||
@ -24,6 +24,8 @@
|
||||
#include "device/deviceapi.h"
|
||||
#include "dsp/downchannelizer.h"
|
||||
#include "dsp/threadedbasebandsamplesink.h"
|
||||
#include "dsp/hbfilterchainconverter.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
|
||||
#include "SWGChannelSettings.h"
|
||||
|
||||
@ -41,7 +43,9 @@ Interferometer::Interferometer(DeviceAPI *deviceAPI) :
|
||||
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink),
|
||||
m_deviceAPI(deviceAPI),
|
||||
m_spectrumSink(nullptr),
|
||||
m_scopeSink(nullptr)
|
||||
m_scopeSink(nullptr),
|
||||
m_frequencyOffset(0),
|
||||
m_deviceSampleRate(48000)
|
||||
{
|
||||
m_deviceAPI->addChannelSinkAPI(this);
|
||||
m_thread = new QThread(this);
|
||||
@ -110,12 +114,60 @@ bool Interferometer::handleMessage(const Message& cmd)
|
||||
applySettings(cfg.getSettings(), cfg.getForce());
|
||||
return true;
|
||||
}
|
||||
else if (DSPSignalNotification::match(cmd))
|
||||
{
|
||||
DSPSignalNotification& notif = (DSPSignalNotification&) cmd;
|
||||
|
||||
qDebug() << "Interferometer::handleMessage: DSPSignalNotification:"
|
||||
<< " inputSampleRate: " << notif.getSampleRate()
|
||||
<< " centerFrequency: " << notif.getCenterFrequency();
|
||||
|
||||
m_deviceSampleRate = notif.getSampleRate();
|
||||
calculateFrequencyOffset(); // This is when device sample rate changes
|
||||
|
||||
// Redo the channelizer stuff with the new sample rate to re-synchronize everything
|
||||
InterferometerSink::MsgConfigureChannelizer *msg = InterferometerSink::MsgConfigureChannelizer::create(
|
||||
m_settings.m_log2Decim,
|
||||
m_settings.m_filterChainHash);
|
||||
m_sink->getInputMessageQueue()->push(msg);
|
||||
|
||||
if (m_guiMessageQueue)
|
||||
{
|
||||
MsgSampleRateNotification *msg = MsgSampleRateNotification::create(notif.getSampleRate());
|
||||
m_guiMessageQueue->push(msg);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray Interferometer::serialize() const
|
||||
{
|
||||
return m_settings.serialize();
|
||||
}
|
||||
|
||||
bool Interferometer::deserialize(const QByteArray& data)
|
||||
{
|
||||
(void) data;
|
||||
if (m_settings.deserialize(data))
|
||||
{
|
||||
MsgConfigureInterferometer *msg = MsgConfigureInterferometer::create(m_settings, true);
|
||||
m_inputMessageQueue.push(msg);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings.resetToDefaults();
|
||||
MsgConfigureInterferometer *msg = MsgConfigureInterferometer::create(m_settings, true);
|
||||
m_inputMessageQueue.push(msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Interferometer::validateFilterChainHash(InterferometerSettings& settings)
|
||||
{
|
||||
unsigned int s = 1;
|
||||
@ -127,6 +179,12 @@ void Interferometer::validateFilterChainHash(InterferometerSettings& settings)
|
||||
settings.m_filterChainHash = settings.m_filterChainHash >= s ? s-1 : settings.m_filterChainHash;
|
||||
}
|
||||
|
||||
void Interferometer::calculateFrequencyOffset()
|
||||
{
|
||||
double shiftFactor = HBFilterChainConverter::getShiftFactor(m_settings.m_log2Decim, m_settings.m_filterChainHash);
|
||||
m_frequencyOffset = m_deviceSampleRate * shiftFactor;
|
||||
}
|
||||
|
||||
int Interferometer::webapiSettingsGet(
|
||||
SWGSDRangel::SWGChannelSettings& response,
|
||||
QString& errorMessage)
|
||||
|
||||
@ -35,7 +35,7 @@ class QNetworkReply;
|
||||
class QNetworkAccessManager;
|
||||
class BasebandSampleSink;
|
||||
|
||||
class Interferometer: public MIMOSampleSink, ChannelAPI
|
||||
class Interferometer: public MIMOSampleSink, public ChannelAPI
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -113,6 +113,23 @@ public:
|
||||
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, unsigned int sinkIndex);
|
||||
virtual bool handleMessage(const Message& cmd); //!< Processing of a message. Returns true if message has actually been processed
|
||||
|
||||
virtual void getIdentifier(QString& id) { id = objectName(); }
|
||||
virtual void getTitle(QString& title) { title = "Interferometer"; }
|
||||
virtual qint64 getCenterFrequency() const { return m_frequencyOffset; }
|
||||
|
||||
virtual QByteArray serialize() const;
|
||||
virtual bool deserialize(const QByteArray& data);
|
||||
|
||||
virtual int getNbSinkStreams() const { return 2; }
|
||||
virtual int getNbSourceStreams() const { return 0; }
|
||||
|
||||
virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
|
||||
{
|
||||
(void) streamIndex;
|
||||
(void) sinkElseSource;
|
||||
return m_frequencyOffset;
|
||||
}
|
||||
|
||||
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
|
||||
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
|
||||
MessageQueue *getMessageQueueToGUI() { return m_guiMessageQueue; }
|
||||
@ -155,8 +172,12 @@ private:
|
||||
QNetworkAccessManager *m_networkManager;
|
||||
QNetworkRequest m_networkRequest;
|
||||
|
||||
int64_t m_frequencyOffset;
|
||||
uint32_t m_deviceSampleRate;
|
||||
|
||||
void applySettings(const InterferometerSettings& settings, bool force = false);
|
||||
static void validateFilterChainHash(InterferometerSettings& settings);
|
||||
void calculateFrequencyOffset();
|
||||
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const InterferometerSettings& settings, bool force);
|
||||
|
||||
private slots:
|
||||
|
||||
85
plugins/channelmimo/interferometer/interferometerplugin.cpp
Normal file
85
plugins/channelmimo/interferometer/interferometerplugin.cpp
Normal file
@ -0,0 +1,85 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// 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 //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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 "interferometerplugin.h"
|
||||
|
||||
#include <QtPlugin>
|
||||
#include "plugin/pluginapi.h"
|
||||
|
||||
#ifndef SERVER_MODE
|
||||
#include "interferometergui.h"
|
||||
#endif
|
||||
#include "interferometer.h"
|
||||
#include "interferometerwebapiadapter.h"
|
||||
#include "interferometerplugin.h"
|
||||
|
||||
const PluginDescriptor InterferometerPlugin::m_pluginDescriptor = {
|
||||
QString("Interferometer"),
|
||||
QString("4.12.0"),
|
||||
QString("(c) Edouard Griffiths, F4EXB"),
|
||||
QString("https://github.com/f4exb/sdrangel"),
|
||||
true,
|
||||
QString("https://github.com/f4exb/sdrangel")
|
||||
};
|
||||
|
||||
InterferometerPlugin::InterferometerPlugin(QObject* parent) :
|
||||
QObject(parent),
|
||||
m_pluginAPI(0)
|
||||
{
|
||||
}
|
||||
|
||||
const PluginDescriptor& InterferometerPlugin::getPluginDescriptor() const
|
||||
{
|
||||
return m_pluginDescriptor;
|
||||
}
|
||||
|
||||
void InterferometerPlugin::initPlugin(PluginAPI* pluginAPI)
|
||||
{
|
||||
m_pluginAPI = pluginAPI;
|
||||
|
||||
// register channel MIMO
|
||||
m_pluginAPI->registerMIMOChannel(Interferometer::m_channelIdURI, Interferometer::m_channelId, this);
|
||||
}
|
||||
|
||||
#ifdef SERVER_MODE
|
||||
PluginInstanceGUI* InterferometerPlugin::createRxChannelGUI(
|
||||
DeviceUISet *deviceUISet,
|
||||
MIMOSampleSink *mimoChannel) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
PluginInstanceGUI* InterferometerPlugin::createMIMOChannelGUI(DeviceUISet *deviceUISet, MIMOSampleSink *mimoChannel) const
|
||||
{
|
||||
return InterferometerGUI::create(m_pluginAPI, deviceUISet, mimoChannel);
|
||||
}
|
||||
#endif
|
||||
|
||||
MIMOSampleSink* InterferometerPlugin::createMIMOChannelBS(DeviceAPI *deviceAPI) const
|
||||
{
|
||||
return new Interferometer(deviceAPI);
|
||||
}
|
||||
|
||||
ChannelAPI* InterferometerPlugin::createMIMOChannelCS(DeviceAPI *deviceAPI) const
|
||||
{
|
||||
return new Interferometer(deviceAPI);
|
||||
}
|
||||
|
||||
ChannelWebAPIAdapter* InterferometerPlugin::createChannelWebAPIAdapter() const
|
||||
{
|
||||
return new InterferometerWebAPIAdapter();
|
||||
}
|
||||
50
plugins/channelmimo/interferometer/interferometerplugin.h
Normal file
50
plugins/channelmimo/interferometer/interferometerplugin.h
Normal file
@ -0,0 +1,50 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// 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 //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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 PLUGINS_CHANNELMIMO_INTERFEROMETER_INTERFEROMETERPLUGIN_H_
|
||||
#define PLUGINS_CHANNELMIMO_INTERFEROMETER_INTERFEROMETERPLUGIN_H_
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include "plugin/plugininterface.h"
|
||||
|
||||
class DeviceUISet;
|
||||
class MIMOSampleSink;
|
||||
|
||||
class InterferometerPlugin : public QObject, PluginInterface {
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(PluginInterface)
|
||||
Q_PLUGIN_METADATA(IID "sdrangel.channelmimo.interferometer")
|
||||
|
||||
public:
|
||||
explicit InterferometerPlugin(QObject* parent = nullptr);
|
||||
|
||||
const PluginDescriptor& getPluginDescriptor() const;
|
||||
void initPlugin(PluginAPI* pluginAPI);
|
||||
|
||||
virtual PluginInstanceGUI* createMIMOChannelGUI(DeviceUISet *deviceUISet, MIMOSampleSink *mimoChannel) const;
|
||||
virtual MIMOSampleSink* createMIMOChannelBS(DeviceAPI *deviceAPI) const;
|
||||
virtual ChannelAPI* createMIMOChannelCS(DeviceAPI *deviceAPI) const;
|
||||
virtual ChannelWebAPIAdapter* createChannelWebAPIAdapter() const;
|
||||
|
||||
private:
|
||||
static const PluginDescriptor m_pluginDescriptor;
|
||||
|
||||
PluginAPI* m_pluginAPI;
|
||||
};
|
||||
|
||||
#endif /* PLUGINS_CHANNELMIMO_INTERFEROMETER_INTERFEROMETERPLUGIN_H_ */
|
||||
Loading…
x
Reference in New Issue
Block a user