1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

Stop scanning when Tune menu selected.

This commit is contained in:
srcejon 2023-12-01 12:47:50 +00:00
parent e64e0a1cd4
commit 3ca14c2bb1
5 changed files with 34 additions and 11 deletions

View File

@ -249,7 +249,7 @@ bool FreqScanner::handleMessage(const Message& cmd)
}
else if (MsgStartScan::match(cmd))
{
muteAll();
muteAll(m_settings);
startScan();
return true;
@ -657,14 +657,14 @@ void FreqScanner::setCenterFrequency(qint64 frequency)
}
// Mute all channels
void FreqScanner::muteAll()
void FreqScanner::muteAll(const FreqScannerSettings& settings)
{
QStringList channels;
channels.append(m_settings.m_channel);
for (int i = 0; i < m_settings.m_frequencySettings.size(); i++)
channels.append(settings.m_channel);
for (int i = 0; i < settings.m_frequencySettings.size(); i++)
{
QString channel = m_settings.m_frequencySettings[i].m_channel;
QString channel = settings.m_frequencySettings[i].m_channel;
if (!channel.isEmpty() && !channels.contains(channel)) {
channels.append(channel);
}

View File

@ -350,6 +350,7 @@ public:
uint32_t getNumberOfDeviceStreams() const;
void calcScannerSampleRate(int channelBW, int basebandSampleRate, int& scannerSampleRate, int& fftSize, int& binsPerChannel);
static void muteAll(const FreqScannerSettings& settings);
static const char * const m_channelIdURI;
static const char * const m_channelId;
@ -408,7 +409,6 @@ private:
void processScanResults(const QDateTime& fftStartTime, const QList<MsgScanResult::ScanResult>& results);
void setDeviceCenterFrequency(qint64 frequency);
void applyChannelSetting(const QString& channel);
void muteAll();
static QList<SWGSDRangel::SWGFreqScannerFrequency *> *createFrequencyList(const FreqScannerSettings& settings);

View File

@ -932,18 +932,29 @@ void FreqScannerGUI::table_customContextMenuRequested(QPoint pos)
// Tune to frequency
qint64 frequency = ui->table->item(row, COL_FREQUENCY)->text().toLongLong();
FreqScannerSettings::FrequencySettings *frequencySettings = m_settings.getFrequencySettings(frequency);
QString channel = m_settings.getChannel(frequencySettings);
const QRegExp re("R([0-9]+):([0-9]+)");
if (re.indexIn(m_settings.m_channel) >= 0)
if (re.indexIn(channel) >= 0)
{
int scanDeviceSetIndex = re.capturedTexts()[1].toInt();
int scanChannelIndex = re.capturedTexts()[2].toInt();
qDebug() << "scanDeviceSetIndex" << scanDeviceSetIndex << "scanChannelIndex" << scanChannelIndex;
qint64 frequency = ui->table->item(row, COL_FREQUENCY)->text().toLongLong();
ButtonSwitch *startStop = ui->startStop;
QAction* findChannelMapAction = new QAction(QString("Tune R%1:%2 to %3").arg(scanDeviceSetIndex).arg(scanChannelIndex).arg(frequency), tableContextMenu);
connect(findChannelMapAction, &QAction::triggered, this, [this, scanDeviceSetIndex, scanChannelIndex, frequency]()->void {
connect(findChannelMapAction, &QAction::triggered, this, [this, scanDeviceSetIndex, scanChannelIndex, frequency, startStop]()->void {
// Stop scanning
if (startStop->isChecked()) {
startStop->click();
}
// Mute all channels
m_freqScanner->muteAll(m_settings);
// Tune to frequency
if ((frequency - m_settings.m_channelBandwidth / 2 < m_deviceCenterFrequency - m_basebandSampleRate / 2)
|| (frequency + m_settings.m_channelBandwidth / 2 >= m_deviceCenterFrequency + m_basebandSampleRate / 2))
{
@ -958,7 +969,6 @@ void FreqScannerGUI::table_customContextMenuRequested(QPoint pos)
if (!ChannelWebAPIUtils::setCenterFrequency(getDeviceSetIndex(), centerFrequency)) {
qWarning() << "Scanner failed to set frequency" << centerFrequency;
}
ChannelWebAPIUtils::setFrequencyOffset(scanDeviceSetIndex, scanChannelIndex, offset);
}
else
@ -967,6 +977,9 @@ void FreqScannerGUI::table_customContextMenuRequested(QPoint pos)
ChannelWebAPIUtils::setFrequencyOffset(scanDeviceSetIndex, scanChannelIndex, offset);
}
// Unmute channel
ChannelWebAPIUtils::setAudioMute(scanDeviceSetIndex, scanChannelIndex, false);
});
tableContextMenu->addAction(findChannelMapAction);
}

View File

@ -420,6 +420,15 @@ QDataStream& operator>>(QDataStream& in, FreqScannerSettings::FrequencySettings&
return in;
}
QString FreqScannerSettings::getChannel(FreqScannerSettings::FrequencySettings *frequencySettings) const
{
QString channel = m_channel;
if (!frequencySettings->m_channel.isEmpty()) {
channel = frequencySettings->m_channel;
}
return channel;
}
Real FreqScannerSettings::getThreshold(FreqScannerSettings::FrequencySettings *frequencySettings) const
{
Real threshold = m_threshold;

View File

@ -103,6 +103,7 @@ struct FreqScannerSettings
bool deserialize(const QByteArray& data);
void applySettings(const QStringList& settingsKeys, const FreqScannerSettings& settings);
QString getDebugString(const QStringList& settingsKeys, bool force = false) const;
QString getChannel(FreqScannerSettings::FrequencySettings *frequencySettings) const;
Real getThreshold(FreqScannerSettings::FrequencySettings *frequencySettings) const;
int getChannelBandwidth(FreqScannerSettings::FrequencySettings *frequencySettings) const;
FreqScannerSettings::FrequencySettings *getFrequencySettings(qint64 frequency);