Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frequency scanner: Add multiplex mode #2310

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 24 additions & 122 deletions plugins/channelrx/demodadsb/adsbdemod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ADSBDemod::ADSBDemod(DeviceAPI *devieAPI) :
m_worker = new ADSBDemodWorker();
m_basebandSink->setMessageQueueToWorker(m_worker->getInputMessageQueue());

applySettings(m_settings, true);
applySettings(m_settings, QStringList(), true);

m_deviceAPI->addChannelSink(this);
m_deviceAPI->addChannelSinkAPI(this);
Expand Down Expand Up @@ -147,7 +147,7 @@ void ADSBDemod::start()
m_basebandSink->startWork();
m_thread->start();

ADSBDemodWorker::MsgConfigureADSBDemodWorker *msg = ADSBDemodWorker::MsgConfigureADSBDemodWorker::create(m_settings, true);
ADSBDemodWorker::MsgConfigureADSBDemodWorker *msg = ADSBDemodWorker::MsgConfigureADSBDemodWorker::create(m_settings, QStringList(), true);
m_worker->getInputMessageQueue()->push(msg);
}

Expand All @@ -169,7 +169,7 @@ bool ADSBDemod::handleMessage(const Message& cmd)
MsgConfigureADSBDemod& cfg = (MsgConfigureADSBDemod&) cmd;
qDebug() << "ADSBDemod::handleMessage: MsgConfigureADSBDemod";

applySettings(cfg.getSettings(), cfg.getForce());
applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce());

return true;
}
Expand Down Expand Up @@ -200,112 +200,12 @@ bool ADSBDemod::handleMessage(const Message& cmd)
}
}

void ADSBDemod::applySettings(const ADSBDemodSettings& settings, bool force)
void ADSBDemod::applySettings(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force)
{
qDebug() << "ADSBDemod::applySettings:"
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
<< " m_rfBandwidth: " << settings.m_rfBandwidth
<< " m_streamIndex: " << settings.m_streamIndex
<< " m_useReverseAPI: " << settings.m_useReverseAPI
<< " m_reverseAPIAddress: " << settings.m_reverseAPIAddress
<< " m_reverseAPIPort: " << settings.m_reverseAPIPort
<< " m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex
<< " m_reverseAPIChannelIndex: " << settings.m_reverseAPIChannelIndex
<< settings.getDebugString(settingsKeys, force)
<< " force: " << force;

QList<QString> reverseAPIKeys;

if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) {
reverseAPIKeys.append("inputFrequencyOffset");
}
if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force) {
reverseAPIKeys.append("rfBandwidth");
}
if ((settings.m_correlationThreshold != m_settings.m_correlationThreshold) || force) {
reverseAPIKeys.append("correlationThreshold");
}
if ((settings.m_samplesPerBit != m_settings.m_samplesPerBit) || force) {
reverseAPIKeys.append("samplesPerBit");
}
if ((settings.m_correlateFullPreamble != m_settings.m_correlateFullPreamble) || force) {
reverseAPIKeys.append("correlateFullPreamble");
}
if ((settings.m_demodModeS != m_settings.m_demodModeS) || force) {
reverseAPIKeys.append("demodModeS");
}
if ((settings.m_interpolatorPhaseSteps != m_settings.m_interpolatorPhaseSteps) || force) {
reverseAPIKeys.append("interpolatorPhaseSteps");
}
if ((settings.m_interpolatorTapsPerPhase != m_settings.m_interpolatorTapsPerPhase) || force) {
reverseAPIKeys.append("interpolatorTapsPerPhase");
}
if ((settings.m_removeTimeout != m_settings.m_removeTimeout) || force) {
reverseAPIKeys.append("removeTimeout");
}
if ((settings.m_feedEnabled != m_settings.m_feedEnabled) || force) {
reverseAPIKeys.append("feedEnabled");
}
if ((settings.m_exportClientEnabled != m_settings.m_exportClientEnabled) || force) {
reverseAPIKeys.append("exportClientEnabled");
}
if ((settings.m_exportClientHost != m_settings.m_exportClientHost) || force) {
reverseAPIKeys.append("exportClientHost");
}
if ((settings.m_exportClientPort != m_settings.m_exportClientPort) || force) {
reverseAPIKeys.append("exportClientPort");
}
if ((settings.m_exportClientFormat != m_settings.m_exportClientFormat) || force) {
reverseAPIKeys.append("exportClientFormat");
}
if ((settings.m_exportServerEnabled != m_settings.m_exportServerEnabled) || force) {
reverseAPIKeys.append("exportServerEnabled");
}
if ((settings.m_exportServerPort != m_settings.m_exportServerPort) || force) {
reverseAPIKeys.append("exportServerPort");
}
if ((settings.m_importEnabled != m_settings.m_importEnabled) || force) {
reverseAPIKeys.append("importEnabled");
}
if ((settings.m_importHost != m_settings.m_importHost) || force) {
reverseAPIKeys.append("importHost");
}
if ((settings.m_importUsername != m_settings.m_importUsername) || force) {
reverseAPIKeys.append("importUsername");
}
if ((settings.m_importPassword != m_settings.m_importPassword) || force) {
reverseAPIKeys.append("importPassword");
}
if ((settings.m_importParameters != m_settings.m_importParameters) || force) {
reverseAPIKeys.append("importParameters");
}
if ((settings.m_importPeriod != m_settings.m_importPeriod) || force) {
reverseAPIKeys.append("importPeriod");
}
if ((settings.m_importMinLatitude != m_settings.m_importMinLatitude) || force) {
reverseAPIKeys.append("importMinLatitude");
}
if ((settings.m_importMaxLatitude != m_settings.m_importMaxLatitude) || force) {
reverseAPIKeys.append("importMaxLatitude");
}
if ((settings.m_importMinLongitude != m_settings.m_importMinLongitude) || force) {
reverseAPIKeys.append("importMinLongitude");
}
if ((settings.m_importMaxLongitude != m_settings.m_importMaxLongitude) || force) {
reverseAPIKeys.append("importMaxLongitude");
}
if ((settings.m_logFilename != m_settings.m_logFilename) || force) {
reverseAPIKeys.append("logFilename");
}
if ((settings.m_logEnabled != m_settings.m_logEnabled) || force) {
reverseAPIKeys.append("logEnabled");
}
if ((settings.m_title != m_settings.m_title) || force) {
reverseAPIKeys.append("title");
}
if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force) {
reverseAPIKeys.append("rfBandwidth");
}

if (m_settings.m_streamIndex != settings.m_streamIndex)
{
if (m_deviceAPI->getSampleMIMO()) // change of stream is possible for MIMO devices only
Expand All @@ -317,38 +217,40 @@ void ADSBDemod::applySettings(const ADSBDemodSettings& settings, bool force)
m_settings.m_streamIndex = settings.m_streamIndex; // make sure ChannelAPI::getStreamIndex() is consistent
emit streamIndexChanged(settings.m_streamIndex);
}

reverseAPIKeys.append("streamIndex");
}

ADSBDemodBaseband::MsgConfigureADSBDemodBaseband *msg = ADSBDemodBaseband::MsgConfigureADSBDemodBaseband::create(settings, force);
ADSBDemodBaseband::MsgConfigureADSBDemodBaseband *msg = ADSBDemodBaseband::MsgConfigureADSBDemodBaseband::create(settings, settingsKeys, force);
m_basebandSink->getInputMessageQueue()->push(msg);

ADSBDemodWorker::MsgConfigureADSBDemodWorker *workerMsg = ADSBDemodWorker::MsgConfigureADSBDemodWorker::create(settings, force);
ADSBDemodWorker::MsgConfigureADSBDemodWorker *workerMsg = ADSBDemodWorker::MsgConfigureADSBDemodWorker::create(settings, settingsKeys, force);
m_worker->getInputMessageQueue()->push(workerMsg);

if (settings.m_useReverseAPI)
{
bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
(m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) ||
(m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) ||
(m_settings.m_reverseAPIDeviceIndex != settings.m_reverseAPIDeviceIndex) ||
(m_settings.m_reverseAPIChannelIndex != settings.m_reverseAPIChannelIndex);
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) ||
settingsKeys.contains("reverseAPIAddress") ||
settingsKeys.contains("reverseAPIPort") ||
settingsKeys.contains("reverseAPIDeviceIndex") ||
settingsKeys.contains("reverseAPIChannelIndex");
webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force);
}

m_settings = settings;
if (force) {
m_settings = settings;
} else {
m_settings.applySettings(settingsKeys, settings);
}
}

void ADSBDemod::setCenterFrequency(qint64 frequency)
{
ADSBDemodSettings settings = m_settings;
settings.m_inputFrequencyOffset = frequency;
applySettings(settings);
applySettings(settings, {"inputFrequencyOffset"}, false);

if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureADSBDemod *msgToGUI = MsgConfigureADSBDemod::create(settings, false);
MsgConfigureADSBDemod *msgToGUI = MsgConfigureADSBDemod::create(settings, {"inputFrequencyOffset"}, false);
m_guiMessageQueue->push(msgToGUI);
}
}
Expand All @@ -368,7 +270,7 @@ bool ADSBDemod::deserialize(const QByteArray& data)
success = false;
}

MsgConfigureADSBDemod *msg = MsgConfigureADSBDemod::create(m_settings, true);
MsgConfigureADSBDemod *msg = MsgConfigureADSBDemod::create(m_settings, QStringList(), true);
m_inputMessageQueue.push(msg);

return success;
Expand Down Expand Up @@ -404,12 +306,12 @@ int ADSBDemod::webapiSettingsPutPatch(
ADSBDemodSettings settings = m_settings;
webapiUpdateChannelSettings(settings, channelSettingsKeys, response);

MsgConfigureADSBDemod *msg = MsgConfigureADSBDemod::create(settings, force);
MsgConfigureADSBDemod *msg = MsgConfigureADSBDemod::create(settings, channelSettingsKeys, force);
m_inputMessageQueue.push(msg);

if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureADSBDemod *msgToGUI = MsgConfigureADSBDemod::create(settings, force);
MsgConfigureADSBDemod *msgToGUI = MsgConfigureADSBDemod::create(settings, channelSettingsKeys, force);
m_guiMessageQueue->push(msgToGUI);
}

Expand Down Expand Up @@ -661,7 +563,7 @@ void ADSBDemod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& respons
}
}

void ADSBDemod::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const ADSBDemodSettings& settings, bool force)
void ADSBDemod::webapiReverseSendSettings(const QList<QString>& channelSettingsKeys, const ADSBDemodSettings& settings, bool force)
{
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
swgChannelSettings->setDirection(0); // single sink (Rx)
Expand Down
15 changes: 8 additions & 7 deletions plugins/channelrx/demodadsb/adsbdemod.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#ifndef INCLUDE_ADSBDEMOD_H
#define INCLUDE_ADSBDEMOD_H

#include <vector>

#include <QNetworkRequest>

#include "dsp/basebandsamplesink.h"
Expand All @@ -44,20 +42,23 @@ class ADSBDemod : public BasebandSampleSink, public ChannelAPI {

public:
const ADSBDemodSettings& getSettings() const { return m_settings; }
const QStringList& getSettingsKeys() const { return m_settingsKeys; }
bool getForce() const { return m_force; }

static MsgConfigureADSBDemod* create(const ADSBDemodSettings& settings, bool force)
static MsgConfigureADSBDemod* create(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force)
{
return new MsgConfigureADSBDemod(settings, force);
return new MsgConfigureADSBDemod(settings, settingsKeys, force);
}

private:
ADSBDemodSettings m_settings;
QStringList m_settingsKeys;
bool m_force;

MsgConfigureADSBDemod(const ADSBDemodSettings& settings, bool force) :
MsgConfigureADSBDemod(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force) :
Message(),
m_settings(settings),
m_settingsKeys(settingsKeys),
m_force(force)
{ }
};
Expand Down Expand Up @@ -184,9 +185,9 @@ class ADSBDemod : public BasebandSampleSink, public ChannelAPI {
QNetworkRequest m_networkRequest;

virtual bool handleMessage(const Message& cmd); //!< Processing of a message. Returns true if message has actually been processed
void applySettings(const ADSBDemodSettings& settings, bool force = false);
void applySettings(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force = false);
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response);
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const ADSBDemodSettings& settings, bool force);
void webapiReverseSendSettings(const QList<QString>& channelSettingsKeys, const ADSBDemodSettings& settings, bool force);

private slots:
void networkManagerFinished(QNetworkReply *reply);
Expand Down
17 changes: 11 additions & 6 deletions plugins/channelrx/demodadsb/adsbdemodbaseband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ bool ADSBDemodBaseband::handleMessage(const Message& cmd)
MsgConfigureADSBDemodBaseband& cfg = (MsgConfigureADSBDemodBaseband&) cmd;
qDebug() << "ADSBDemodBaseband::handleMessage: MsgConfigureADSBDemodBaseband";

applySettings(cfg.getSettings(), cfg.getForce());
applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce());

return true;
}
Expand All @@ -138,19 +138,24 @@ bool ADSBDemodBaseband::handleMessage(const Message& cmd)
}
}

void ADSBDemodBaseband::applySettings(const ADSBDemodSettings& settings, bool force)
void ADSBDemodBaseband::applySettings(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force)
{
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset)
|| (settings.m_samplesPerBit != m_settings.m_samplesPerBit) || force)
if ( (settingsKeys.contains("inputFrequencyOffset") && (settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset))
|| (settingsKeys.contains("samplesPerBit") && (settings.m_samplesPerBit != m_settings.m_samplesPerBit))
|| force)
{
int requestedRate = ADS_B_BITS_PER_SECOND * settings.m_samplesPerBit;
m_channelizer->setChannelization(requestedRate, settings.m_inputFrequencyOffset);
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
}

m_sink.applySettings(settings, force);
m_sink.applySettings(settings, settingsKeys, force);

m_settings = settings;
if (force) {
m_settings = settings;
} else {
m_settings.applySettings(settingsKeys, settings);
}
}

int ADSBDemodBaseband::getChannelSampleRate() const
Expand Down
11 changes: 7 additions & 4 deletions plugins/channelrx/demodadsb/adsbdemodbaseband.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,23 @@ class ADSBDemodBaseband : public QObject

public:
const ADSBDemodSettings& getSettings() const { return m_settings; }
const QStringList& getSettingsKeys() const { return m_settingsKeys; }
bool getForce() const { return m_force; }

static MsgConfigureADSBDemodBaseband* create(const ADSBDemodSettings& settings, bool force)
static MsgConfigureADSBDemodBaseband* create(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force)
{
return new MsgConfigureADSBDemodBaseband(settings, force);
return new MsgConfigureADSBDemodBaseband(settings, settingsKeys, force);
}

private:
ADSBDemodSettings m_settings;
QStringList m_settingsKeys;
bool m_force;

MsgConfigureADSBDemodBaseband(const ADSBDemodSettings& settings, bool force) :
MsgConfigureADSBDemodBaseband(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force) :
Message(),
m_settings(settings),
m_settingsKeys(settingsKeys),
m_force(force)
{ }
};
Expand Down Expand Up @@ -80,7 +83,7 @@ class ADSBDemodBaseband : public QObject
QRecursiveMutex m_mutex;

bool handleMessage(const Message& cmd);
void applySettings(const ADSBDemodSettings& settings, bool force = false);
void applySettings(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force = false);

private slots:
void handleInputMessages();
Expand Down
Loading
Loading