Fix loading settings. Add remove inactive button. Restart scan when sample rate changes.

This commit is contained in:
srcejon 2023-10-02 15:45:17 +01:00
parent f8f9d270df
commit d2526cdc5b
8 changed files with 271 additions and 103 deletions

View File

@ -225,7 +225,13 @@ bool FreqScanner::handleMessage(const Message& cmd)
else if (DSPSignalNotification::match(cmd))
{
DSPSignalNotification& notif = (DSPSignalNotification&) cmd;
m_basebandSampleRate = notif.getSampleRate();
int newSampleRate = notif.getSampleRate();
if ((newSampleRate != m_basebandSampleRate) && (m_state != IDLE))
{
// Restart scan if sample rate changes
startScan();
}
m_basebandSampleRate = newSampleRate;
m_centerFrequency = notif.getCenterFrequency();
qDebug() << "FreqScanner::handleMessage: DSPSignalNotification";
// Forward to the sink
@ -645,7 +651,7 @@ void FreqScanner::applySettings(const FreqScannerSettings& settings, const QStri
{
// Restart scan if any settings change
if (m_state != IDLE) {
m_state = START_SCAN;
startScan();
}
}

View File

@ -29,11 +29,9 @@ FreqScannerAddRangeDialog::FreqScannerAddRangeDialog(int step, QWidget* parent)
ui->stop->setColorMapper(ColorMapper(ColorMapper::GrayGold));
ui->stop->setValueRange(false, 11, 0, 99999999999);
// Airband frequency range
ui->start->setValue(118000000);
ui->stop->setValue(137000000);
on_preset_currentTextChanged("Airband");
ui->step->setCurrentText(QString::number(step));
//ui->step->setCurrentText(QString::number(step));
}
FreqScannerAddRangeDialog::~FreqScannerAddRangeDialog()
@ -43,8 +41,84 @@ FreqScannerAddRangeDialog::~FreqScannerAddRangeDialog()
void FreqScannerAddRangeDialog::accept()
{
m_start = ui->start->getValue();
m_stop = ui->stop->getValue();
m_step = ui->step->currentText().toInt();
if (ui->preset->currentText() == "Digital Selective Calling")
{
// From ITU M.541
static const QList<qint64> dscFreqs = {
2177000, 2189500,
4208000, 4208500, 4209000,
6312500, 6313000,
8415000, 8415500, 8416000,
12577500, 12578000, 12578500,
16805000, 16805500, 16806000, 18898500, 18899000, 18899500,
22374500, 22375000, 22375500,
25208500, 25209000, 25209500
};
m_frequencies.append(dscFreqs);
}
else if (ui->preset->currentText() == "DAB")
{
static const QList<qint64> dabFreqs = {
174928000, 176640000, 178352000, 180064000,
181936000, 183648000, 185360000, 187072000,
188928000, 190640000, 192352000, 194064000,
195936000, 197648000, 199360000, 201072000,
202928000, 204640000, 206352000, 208064000,
209936000, 211648000, 213360000, 215072000,
216928000, 218640000, 220352000, 222064000,
223936000, 225648000, 227360000, 229072000,
230784000, 232496000, 234208000, 235776000,
237448000, 239200000
};
m_frequencies.append(dabFreqs);
}
else
{
qint64 start = ui->start->getValue();
qint64 stop = ui->stop->getValue();
int step = ui->step->currentText().toInt();
if ((start <= stop) && (step > 0))
{
for (qint64 f = start; f <= stop; f += step) {
m_frequencies.append(f);
}
}
}
QDialog::accept();
}
void FreqScannerAddRangeDialog::on_preset_currentTextChanged(const QString& text)
{
bool enableManAdjust = true;
if (text == "Airband")
{
ui->start->setValue(118000000);
ui->stop->setValue(137000000);
ui->step->setCurrentText("25000");
}
else if (text == "Broadcast FM")
{
ui->start->setValue(87500000);
ui->stop->setValue(108000000);
ui->step->setCurrentText("100000");
}
else if (text == "DAB")
{
enableManAdjust = false;
}
else if (text == "Marine")
{
ui->start->setValue(156000000);
ui->stop->setValue(162150000);
ui->step->setCurrentText("25000");
}
else if (text == "Digital Selective Calling")
{
enableManAdjust = false;
}
ui->start->setEnabled(enableManAdjust);
ui->stop->setEnabled(enableManAdjust);
ui->step->setEnabled(enableManAdjust);
}

View File

@ -30,12 +30,11 @@ public:
explicit FreqScannerAddRangeDialog(int step, QWidget* parent = nullptr);
~FreqScannerAddRangeDialog();
qint64 m_start;
qint64 m_stop;
int m_step;
QList<qint64> m_frequencies;
private slots:
void accept();
void on_preset_currentTextChanged(const QString& text);
private:
Ui::FreqScannerAddRangeDialog *ui;

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>385</width>
<height>162</height>
<height>190</height>
</rect>
</property>
<property name="font">
@ -31,82 +31,21 @@
<string>Add Frequency Range</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="1">
<widget class="ValueDialZ" name="stop" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="font">
<font>
<family>Liberation Mono</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Stop frequency in Hertz</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="stopLabel">
<item row="4" column="0">
<widget class="QLabel" name="stepLabel">
<property name="text">
<string>Stop Frequency</string>
<string>Step</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="startLabel">
<property name="minimumSize">
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Start Frequency</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="stopUnits">
<item row="1" column="2">
<widget class="QLabel" name="startUnits">
<property name="text">
<string>Hz</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="step">
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string>25000</string>
</property>
</item>
<item>
<property name="text">
<string>8333.3</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="ValueDialZ" name="start" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
@ -137,24 +76,129 @@
</property>
</widget>
</item>
<item row="3" column="2">
<item row="4" column="2">
<widget class="QLabel" name="stepUnits">
<property name="text">
<string>Hz</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="startUnits">
<item row="3" column="2">
<widget class="QLabel" name="stopUnits">
<property name="text">
<string>Hz</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="stepLabel">
<widget class="QLabel" name="stopLabel">
<property name="text">
<string>Step</string>
<string>Stop Frequency</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="startLabel">
<property name="minimumSize">
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Start Frequency</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="step">
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string>25000</string>
</property>
</item>
<item>
<property name="text">
<string>8333.3</string>
</property>
</item>
<item>
<property name="text">
<string>100000</string>
</property>
</item>
</widget>
</item>
<item row="3" column="1">
<widget class="ValueDialZ" name="stop" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="font">
<font>
<family>Liberation Mono</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Stop frequency in Hertz</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="preset">
<property name="toolTip">
<string>Select a preset range of frequencies</string>
</property>
<item>
<property name="text">
<string>Airband</string>
</property>
</item>
<item>
<property name="text">
<string>Broadcast FM</string>
</property>
</item>
<item>
<property name="text">
<string>DAB</string>
</property>
</item>
<item>
<property name="text">
<string>Digital Selective Calling</string>
</property>
</item>
<item>
<property name="text">
<string>Marine</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="presetLabel">
<property name="text">
<string>Preset</string>
</property>
</widget>
</item>

View File

@ -504,7 +504,6 @@ void FreqScannerGUI::displaySettings()
setTitle(m_channelMarker.getTitle());
blockApplySettings(true);
int channelIndex = ui->channels->findText(m_settings.m_channel);
if (channelIndex >= 0) {
ui->channels->setCurrentIndex(channelIndex);
@ -524,6 +523,7 @@ void FreqScannerGUI::displaySettings()
ui->mode->setCurrentIndex((int)m_settings.m_mode);
ui->table->blockSignals(true);
ui->table->setRowCount(0);
for (int i = 0; i < m_settings.m_frequencies.size(); i++)
{
addRow(m_settings.m_frequencies[i], m_settings.m_enabled[i], m_settings.m_notes[i]);
@ -618,16 +618,9 @@ void FreqScannerGUI::on_addRange_clicked()
new DialogPositioner(&dialog, false);
if (dialog.exec())
{
qint64 start = dialog.m_start;
qint64 stop = dialog.m_stop;
int step = dialog.m_step;
blockApplySettings(true);
if ((start <= stop) && (step > 0))
{
for (qint64 f = start; f <= stop; f += step) {
addRow(f, true);
}
for (const auto f : dialog.m_frequencies) {
addRow(f, true);
}
blockApplySettings(false);
QList<QString> settingsKeys({
@ -659,6 +652,27 @@ void FreqScannerGUI::on_remove_clicked()
applySettings(settingsKeys);
}
void FreqScannerGUI::on_removeInactive_clicked()
{
for (int i = ui->table->rowCount() - 1; i >= 0; i--)
{
if (ui->table->item(i, COL_ACTIVE_COUNT)->data(Qt::DisplayRole).toInt() == 0)
{
ui->table->removeRow(i);
m_settings.m_frequencies.removeAt(i); // table_cellChanged isn't called for removeRow
m_settings.m_enabled.removeAt(i);
m_settings.m_notes.removeAt(i);
}
}
QList<QString> settingsKeys({
"frequencies",
"enabled",
"notes"
});
applySettings(settingsKeys);
}
static QList<QTableWidgetItem*> takeRow(QTableWidget* table, int row)
{
QList<QTableWidgetItem*> rowItems;
@ -805,6 +819,14 @@ void FreqScannerGUI::table_customContextMenuRequested(QPoint pos)
});
tableContextMenu->addAction(copyAction);
// Remove selected rows
QAction* removeAction = new QAction("Remove", tableContextMenu);
connect(removeAction, &QAction::triggered, this, [this]()->void {
on_remove_clicked();
});
tableContextMenu->addAction(removeAction);
tableContextMenu->addSeparator();
// Tune to frequency
@ -904,7 +926,7 @@ void FreqScannerGUI::resizeTable()
// Fill table with a row of dummy data that will size the columns nicely
int row = ui->table->rowCount();
ui->table->setRowCount(row + 1);
ui->table->setItem(row, COL_FREQUENCY, new QTableWidgetItem("999.000 MHz"));
ui->table->setItem(row, COL_FREQUENCY, new QTableWidgetItem("800,000.5 MHz"));
ui->table->setItem(row, COL_ANNOTATION, new QTableWidgetItem("An annotation"));
ui->table->setItem(row, COL_ENABLE, new QTableWidgetItem("Enable"));
ui->table->setItem(row, COL_POWER, new QTableWidgetItem("-100.0"));
@ -931,6 +953,7 @@ void FreqScannerGUI::makeUIConnections()
QObject::connect(ui->addSingle, &QToolButton::clicked, this, &FreqScannerGUI::on_addSingle_clicked);
QObject::connect(ui->addRange, &QToolButton::clicked, this, &FreqScannerGUI::on_addRange_clicked);
QObject::connect(ui->remove, &QToolButton::clicked, this, &FreqScannerGUI::on_remove_clicked);
QObject::connect(ui->removeInactive, &QToolButton::clicked, this, &FreqScannerGUI::on_removeInactive_clicked);
QObject::connect(ui->up, &QToolButton::clicked, this, &FreqScannerGUI::on_up_clicked);
QObject::connect(ui->down, &QToolButton::clicked, this, &FreqScannerGUI::on_down_clicked);
QObject::connect(ui->clearActiveCount, &QToolButton::clicked, this, &FreqScannerGUI::on_clearActiveCount_clicked);

View File

@ -132,6 +132,7 @@ private slots:
void on_addSingle_clicked();
void on_addRange_clicked();
void on_remove_clicked();
void on_removeInactive_clicked();
void on_up_clicked();
void on_down_clicked();
void on_clearActiveCount_clicked();

View File

@ -181,6 +181,12 @@
<layout class="QHBoxLayout" name="channelPowerLayout">
<item>
<widget class="QLabel" name="channelPower">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Active frequency power </string>
</property>
@ -231,10 +237,10 @@
<string>Power threshold in dB</string>
</property>
<property name="minimum">
<number>-1400</number>
<number>-1000</number>
</property>
<property name="maximum">
<number>100</number>
<number>0</number>
</property>
<property name="pageStep">
<number>1</number>
@ -699,6 +705,16 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="removeInactive">
<property name="toolTip">
<string>Remove rows with Active Count of 0</string>
</property>
<property name="text">
<string>Remove Inactive</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="up">
<property name="toolTip">

View File

@ -87,7 +87,7 @@ Displays the current status of the Frequency Scanner.
The frequency table contains the list of frequencies to be scanned, along with results of a scan. The columns are:
- Freq (Hz): Specifies the channel center frequencies to be scanned. These should be spaced by integer multiples of the channel bandwidth (8). Values should be entered in Hertz.
- Freq (Hz): Specifies the channel center frequencies to be scanned. Values should be entered in Hertz.
- Annotation: An annotation (description) for the frequency, that is obtained from the closest matching [annotation marker](../../../sdrgui/gui/spectrummarkers.md) in the Main Spectrum.
- Enable: Determines whether the frequency will be scanned. This can be used to temporaily disable frequencies you aren't interested in.
- Power (dB): Displays the measured power in decibels from the last scan. The cell will have a green background if the power was above the threshold (4).
@ -99,6 +99,7 @@ When an active frequency is found after a scan, the corresponding row in the tab
Right clicking on a cell will display a popup menu:
- Copy contents of cell to clipboard.
- Remove selected rows.
- Tune selected channel (1) to the frequency in the row clicked on.
<h3>15: Add</h3>
@ -112,16 +113,20 @@ The step value should typically be an integer multiple of the channel bandwidth
<h3>17: Remove</h3>
Removes the selected rows from the frequency table (14).
Removes the selected rows from the frequency table (14). Press Ctrl-A to select all rows.
<h3>18: Up</h3>
<h3>18: Remove Inactive</h3>
Removes all rows with Active Count of 0.
<h3>19: Up</h3>
Moves the selected rows up the frequency table (14).
<h3>19: Down</h3>
<h3>20: Down</h3>
Moves the selected rows the the frequency table (14).
<h3>20: Clear Active Count</h3>
<h3>21: Clear Active Count</h3>
Press to reset the value in the Active Count column to 0 for all rows.