Skip to content

Commit

Permalink
Merge pull request #1986 from srcejon/freq_scanner
Browse files Browse the repository at this point in the history
Sky Map feature plugin
  • Loading branch information
f4exb authored Feb 17, 2024
2 parents 0a8b86b + 431fda3 commit fcd94aa
Show file tree
Hide file tree
Showing 122 changed files with 10,311 additions and 1,381 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ option(ENABLE_FEATURE_RIGCTLSERVER "Enable feature rigctlserver plugin" ON)
option(ENABLE_FEATURE_PERTESTER "Enable feature pertester plugin" ON)
option(ENABLE_FEATURE_GS232CONTROLLER "Enable feature gs232controller plugin" ON)
option(ENABLE_FEATURE_REMOTECONTROL "Enable feature remote control plugin" ON)
option(ENABLE_FEATURE_SKYMAP "Enable feature sky map plugin" ON)

# on windows always build external libraries
if(WIN32)
Expand Down
Binary file added doc/img/SkyMap_ESASky.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/SkyMap_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/SkyMap_wwt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
198 changes: 10 additions & 188 deletions plugins/channelrx/freqscanner/freqscanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ FreqScanner::FreqScanner(DeviceAPI *deviceAPI) :
m_basebandSink(nullptr),
m_running(false),
m_basebandSampleRate(0),
m_availableChannelHandler({}),
m_scanDeviceSetIndex(0),
m_scanChannelIndex(0),
m_state(IDLE),
Expand Down Expand Up @@ -95,19 +96,8 @@ FreqScanner::FreqScanner(DeviceAPI *deviceAPI) :

start();

scanAvailableChannels();
QObject::connect(
MainCore::instance(),
&MainCore::channelAdded,
this,
&FreqScanner::handleChannelAdded
);
QObject::connect(
MainCore::instance(),
&MainCore::channelRemoved,
this,
&FreqScanner::handleChannelRemoved
);
QObject::connect(&m_availableChannelHandler, &AvailableChannelOrFeatureHandler::channelsOrFeaturesChanged, this, &FreqScanner::channelsChanged);
m_availableChannelHandler.scanAvailableChannelsAndFeatures();

m_timeoutTimer.callOnTimeout(this, &FreqScanner::timeout);
}
Expand Down Expand Up @@ -708,7 +698,7 @@ void FreqScanner::applySettings(const FreqScannerSettings& settings, const QStri
m_deviceAPI->removeChannelSink(this, m_settings.m_streamIndex);
m_deviceAPI->addChannelSink(this, settings.m_streamIndex);
m_deviceAPI->addChannelSinkAPI(this);
scanAvailableChannels(); // re-scan
//FIXME:scanAvailableChannels(); // re-scan
emit streamIndexChanged(settings.m_streamIndex);
}
}
Expand Down Expand Up @@ -1116,186 +1106,18 @@ void FreqScanner::handleIndexInDeviceSetChanged(int index)
m_basebandSink->setFifoLabel(fifoLabel);
}

void FreqScanner::scanAvailableChannels()
void FreqScanner::channelsChanged(const QStringList& renameFrom, const QStringList& renameTo)
{
m_availableChannels.clear();

DSPDeviceSourceEngine* deviceSourceEngine = getDeviceAPI()->getDeviceSourceEngine();

if (deviceSourceEngine)
{
for (int chi = 0; chi < getDeviceAPI()->getNbSinkChannels(); chi++) // Rx channels
{
ChannelAPI* channel = getDeviceAPI()->getChanelSinkAPIAt(chi);

if (channel->getIndexInDeviceSet() == getIndexInDeviceSet()) { // Exclude oneself
continue;
}

FreqScannerSettings::AvailableChannel availableChannel =
FreqScannerSettings::AvailableChannel{
channel->getDeviceSetIndex(),
channel->getIndexInDeviceSet(),
-1
};
m_availableChannels[channel] = availableChannel;
QObject::connect(
channel,
&ChannelAPI::streamIndexChanged,
[=](int streamIndex){
this->handleChannelStreamIndexChanged(streamIndex, channel);
}
);
}
}

DSPDeviceMIMOEngine *deviceMIMOEngine = getDeviceAPI()->getDeviceMIMOEngine();

if (deviceMIMOEngine)
{
for (int chi = 0; chi < getDeviceAPI()->getNbSinkChannels(); chi++) // Rx channels
{
ChannelAPI* channel = getDeviceAPI()->getChanelSinkAPIAt(chi);

if (channel->getIndexInDeviceSet() == getIndexInDeviceSet()) { // Exclude oneself
continue;
}

// Single Rx on the same I/Q stream
if ((channel->getNbSinkStreams() == 1)
&& (channel->getNbSourceStreams() == 0)
&& (channel->getStreamIndex() == m_settings.m_streamIndex))
{
FreqScannerSettings::AvailableChannel availableChannel =
FreqScannerSettings::AvailableChannel{
channel->getDeviceSetIndex(),
channel->getIndexInDeviceSet(),
channel->getStreamIndex()
};
m_availableChannels[channel] = availableChannel;
QObject::connect(
channel,
&ChannelAPI::streamIndexChanged,
[=](int streamIndex){
this->handleChannelStreamIndexChanged(streamIndex, channel);
}
);
}
}
}

notifyUpdateChannels();
m_availableChannels = m_availableChannelHandler.getAvailableChannelOrFeatureList();
notifyUpdateChannels(renameFrom, renameTo);
}

void FreqScanner::handleChannelAdded(int deviceSetIndex, ChannelAPI* channel)
{
if (deviceSetIndex != getDeviceSetIndex()) { // Can control channels only in the same device set
return;
}

qDebug("FreqScanner::handleChannelAdded: deviceSetIndex: %d:%d channel: %s (%p)",
deviceSetIndex, channel->getIndexInDeviceSet(), qPrintable(channel->getURI()), channel);
DSPDeviceSourceEngine* deviceSourceEngine = getDeviceAPI()->getDeviceSourceEngine();

if (deviceSourceEngine)
{
FreqScannerSettings::AvailableChannel availableChannel =
FreqScannerSettings::AvailableChannel{ deviceSetIndex, channel->getIndexInDeviceSet(), -1};
m_availableChannels[channel] = availableChannel;
QObject::connect(
channel,
&ChannelAPI::streamIndexChanged,
[=](int streamIndex){
this->handleChannelStreamIndexChanged(streamIndex, channel);
}
);
}

DSPDeviceMIMOEngine *deviceMIMOEngine = getDeviceAPI()->getDeviceMIMOEngine();

if (deviceMIMOEngine
&& (channel->getNbSinkStreams() == 1)
&& (channel->getNbSourceStreams() == 0)
&& (channel->getStreamIndex() == m_settings.m_streamIndex))
{
FreqScannerSettings::AvailableChannel availableChannel =
FreqScannerSettings::AvailableChannel{
deviceSetIndex,
channel->getIndexInDeviceSet(),
channel->getStreamIndex()
};
m_availableChannels[channel] = availableChannel;
QObject::connect(
channel,
&ChannelAPI::streamIndexChanged,
[=](int streamIndex){
this->handleChannelStreamIndexChanged(streamIndex, channel);
}
);
}

notifyUpdateChannels();
}

void FreqScanner::handleChannelRemoved(int deviceSetIndex, ChannelAPI* channel)
{
if (deviceSetIndex != getDeviceSetIndex()) { // Can control channels only in the same device set
return;
}

qDebug("FreqScanner::handleChannelRemoved: deviceSetIndex: %d:%d channel: %s (%p)",
deviceSetIndex, channel->getIndexInDeviceSet(), qPrintable(channel->getURI()), channel);
DSPDeviceSourceEngine* deviceSourceEngine = getDeviceAPI()->getDeviceSourceEngine();
DSPDeviceMIMOEngine *deviceMIMOEngine = getDeviceAPI()->getDeviceMIMOEngine();

if (deviceSourceEngine || deviceMIMOEngine) {
m_availableChannels.remove(channel);
}

notifyUpdateChannels();
}

void FreqScanner::handleChannelStreamIndexChanged(int streamIndex, ChannelAPI* channel)
{
qDebug("FreqScanner::handleChannelStreamIndexChanged: channel: %s (%p) stream: %d",
qPrintable(channel->getURI()), channel, streamIndex);
if (streamIndex != m_settings.m_streamIndex) // channel has moved to another I/Q stream
{
m_availableChannels.remove(channel);
notifyUpdateChannels();
}
else if (!m_availableChannels.contains(channel)) // if channel has been tracked before put back it in the list
{
FreqScannerSettings::AvailableChannel availableChannel =
FreqScannerSettings::AvailableChannel{
getDeviceSetIndex(),
channel->getIndexInDeviceSet(),
channel->getStreamIndex()
};
m_availableChannels[channel] = availableChannel;
notifyUpdateChannels();
}
}

void FreqScanner::notifyUpdateChannels()
void FreqScanner::notifyUpdateChannels(const QStringList& renameFrom, const QStringList& renameTo)
{
if (getMessageQueueToGUI())
{
MsgReportChannels* msgToGUI = MsgReportChannels::create();
QList<FreqScannerSettings::AvailableChannel>& msgChannels = msgToGUI->getChannels();
QHash<ChannelAPI*, FreqScannerSettings::AvailableChannel>::iterator it = m_availableChannels.begin();

for (; it != m_availableChannels.end(); ++it)
{
FreqScannerSettings::AvailableChannel msgChannel =
FreqScannerSettings::AvailableChannel{
it->m_deviceSetIndex,
it->m_channelIndex,
it->m_streamIndex
};
msgChannels.push_back(msgChannel);
}

MsgReportChannels* msgToGUI = MsgReportChannels::create(renameFrom, renameTo);
msgToGUI->getChannels() = m_availableChannels;
getMessageQueueToGUI()->push(msgToGUI);
}
}
30 changes: 18 additions & 12 deletions plugins/channelrx/freqscanner/freqscanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "dsp/basebandsamplesink.h"
#include "channel/channelapi.h"
#include "util/message.h"
#include "availablechannelorfeaturehandler.h"

#include "freqscannerbaseband.h"
#include "freqscannersettings.h"
Expand Down Expand Up @@ -71,17 +72,23 @@ class FreqScanner : public BasebandSampleSink, public ChannelAPI {

public:

QList<FreqScannerSettings::AvailableChannel>& getChannels() { return m_channels; }
AvailableChannelOrFeatureList& getChannels() { return m_channels; }
const QStringList& getRenameFrom() const { return m_renameFrom; }
const QStringList& getRenameTo() const { return m_renameTo; }

static MsgReportChannels* create() {
return new MsgReportChannels();
static MsgReportChannels* create(const QStringList& renameFrom, const QStringList& renameTo) {
return new MsgReportChannels(renameFrom, renameTo);
}

private:
QList<FreqScannerSettings::AvailableChannel> m_channels;
AvailableChannelOrFeatureList m_channels;
QStringList m_renameFrom;
QStringList m_renameTo;

MsgReportChannels() :
Message()
MsgReportChannels(const QStringList& renameFrom, const QStringList& renameTo) :
Message(),
m_renameFrom(renameFrom),
m_renameTo(renameTo)
{}
};

Expand Down Expand Up @@ -369,7 +376,8 @@ class FreqScanner : public BasebandSampleSink, public ChannelAPI {
QNetworkAccessManager *m_networkManager;
QNetworkRequest m_networkRequest;

QHash<ChannelAPI*, FreqScannerSettings::AvailableChannel> m_availableChannels;
AvailableChannelOrFeatureList m_availableChannels;
AvailableChannelOrFeatureHandler m_availableChannelHandler;

unsigned int m_scanDeviceSetIndex;
unsigned int m_scanChannelIndex;
Expand Down Expand Up @@ -402,8 +410,8 @@ class FreqScanner : public BasebandSampleSink, public ChannelAPI {
);
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response);

void scanAvailableChannels();
void notifyUpdateChannels();
//void scanAvailableChannels();
void notifyUpdateChannels(const QStringList& renameFrom, const QStringList& renameTo);
void startScan();
void stopScan();
void initScan();
Expand All @@ -416,9 +424,7 @@ class FreqScanner : public BasebandSampleSink, public ChannelAPI {
private slots:
void networkManagerFinished(QNetworkReply *reply);
void handleIndexInDeviceSetChanged(int index);
void handleChannelAdded(int deviceSetIndex, ChannelAPI* channel);
void handleChannelRemoved(int deviceSetIndex, ChannelAPI* channel);
void handleChannelStreamIndexChanged(int streamIndex, ChannelAPI* channel);
void channelsChanged(const QStringList& renameFrom, const QStringList& renameTo);
void timeout();

};
Expand Down
45 changes: 29 additions & 16 deletions plugins/channelrx/freqscanner/freqscannergui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ bool FreqScannerGUI::handleMessage(const Message& message)
else if (FreqScanner::MsgReportChannels::match(message))
{
FreqScanner::MsgReportChannels& report = (FreqScanner::MsgReportChannels&)message;
m_availableChannels = report.getChannels();
updateChannelsList(m_availableChannels);
updateChannelsList(report.getChannels(), report.getRenameFrom(), report.getRenameTo());
return true;
}
else if (FreqScanner::MsgStatus::match(message))
Expand Down Expand Up @@ -212,7 +211,7 @@ bool FreqScannerGUI::handleMessage(const Message& message)
return false;
}

void FreqScannerGUI::updateChannelsCombo(QComboBox *combo, const QList<FreqScannerSettings::AvailableChannel>& channels, const QString& channel, bool empty)
void FreqScannerGUI::updateChannelsCombo(QComboBox *combo, const AvailableChannelOrFeatureList& channels, const QString& channel, bool empty)
{
combo->blockSignals(true);
combo->clear();
Expand All @@ -223,17 +222,8 @@ void FreqScannerGUI::updateChannelsCombo(QComboBox *combo, const QList<FreqScann
for (const auto& channel : channels)
{
// Add channels in this device set, other than ourself (Don't use ChannelGUI::getDeviceSetIndex()/getIndex() as not valid when this is first called)
if ((channel.m_deviceSetIndex == m_freqScanner->getDeviceSetIndex()) && (channel.m_channelIndex != m_freqScanner->getIndexInDeviceSet()))
{
QString name;

if (channel.m_streamIndex < 0) { // Rx
name = QString("R%1:%2").arg(channel.m_deviceSetIndex).arg(channel.m_channelIndex);
} else { // MIMO
name = QString("M%1:%2.%3").arg(channel.m_deviceSetIndex).arg(channel.m_channelIndex).arg(channel.m_streamIndex);
}

combo->addItem(name);
if ((channel.m_superIndex == m_freqScanner->getDeviceSetIndex()) && (channel.m_index != m_freqScanner->getIndexInDeviceSet())) {
combo->addItem(channel.getId());
}
}

Expand All @@ -250,8 +240,29 @@ void FreqScannerGUI::updateChannelsCombo(QComboBox *combo, const QList<FreqScann
combo->blockSignals(false);
}

void FreqScannerGUI::updateChannelsList(const QList<FreqScannerSettings::AvailableChannel>& channels)
void FreqScannerGUI::updateChannelsList(const AvailableChannelOrFeatureList& channels, const QStringList& renameFrom, const QStringList& renameTo)
{
m_availableChannels = channels;

// Update channel setting if it has been renamed
if (renameFrom.contains(m_settings.m_channel))
{
m_settings.m_channel = renameTo[renameFrom.indexOf(m_settings.m_channel)];
applySetting("channel");
}
bool rename = false;
for (auto& setting : m_settings.m_frequencySettings)
{
if (renameFrom.contains(setting.m_channel))
{
setting.m_channel = renameTo[renameFrom.indexOf(setting.m_channel)];
rename = true;
}
}
if (rename) {
applySetting("frequencySettings");
}

updateChannelsCombo(ui->channels, channels, m_settings.m_channel, false);

for (int row = 0; row < ui->table->rowCount(); row++)
Expand Down Expand Up @@ -515,10 +526,12 @@ void FreqScannerGUI::applySetting(const QString& settingsKey)

void FreqScannerGUI::applySettings(const QStringList& settingsKeys, bool force)
{
m_settingsKeys.append(settingsKeys);
if (m_doApplySettings)
{
FreqScanner::MsgConfigureFreqScanner* message = FreqScanner::MsgConfigureFreqScanner::create(m_settings, settingsKeys, force);
FreqScanner::MsgConfigureFreqScanner* message = FreqScanner::MsgConfigureFreqScanner::create(m_settings, m_settingsKeys, force);
m_freqScanner->getInputMessageQueue()->push(message);
m_settingsKeys.clear();
}
}

Expand Down
Loading

0 comments on commit fcd94aa

Please sign in to comment.