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

FreqScanner: Add API action to run scan. Add scan results to channel report.

This commit is contained in:
srcejon 2024-06-21 10:24:16 +01:00
parent c1d55b9af1
commit 28cc7c3f31
7 changed files with 94 additions and 4 deletions

View File

@ -31,6 +31,7 @@
#include "SWGWorkspaceInfo.h" #include "SWGWorkspaceInfo.h"
#include "SWGFreqScannerSettings.h" #include "SWGFreqScannerSettings.h"
#include "SWGChannelReport.h" #include "SWGChannelReport.h"
#include "SWGChannelActions.h"
#include "device/deviceset.h" #include "device/deviceset.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
@ -550,7 +551,9 @@ void FreqScanner::processScanResults(const QDateTime& fftStartTime, const QList<
setDeviceCenterFrequency(nextCenterFrequency); setDeviceCenterFrequency(nextCenterFrequency);
} }
if (complete) { if (complete)
{
m_scanResultsForReport = m_scanResults;
m_scanResults.clear(); m_scanResults.clear();
} }
} }
@ -815,6 +818,47 @@ int FreqScanner::webapiReportGet(
return 200; return 200;
} }
int FreqScanner::webapiActionsPost(
const QStringList& channelActionsKeys,
SWGSDRangel::SWGChannelActions& query,
QString& errorMessage)
{
SWGSDRangel::SWGFreqScannerActions *swgFreqScannerActions = query.getFreqScannerActions();
if (swgFreqScannerActions)
{
if (channelActionsKeys.contains("run"))
{
bool run = swgFreqScannerActions->getRun() != 0;
if (run)
{
MsgStartScan *start = MsgStartScan::create();
if (getMessageQueueToGUI()) {
getMessageQueueToGUI()->push(start);
} else {
getInputMessageQueue()->push(start);
}
}
else
{
MsgStopScan *stop = MsgStopScan::create();
if (getMessageQueueToGUI()) {
getMessageQueueToGUI()->push(stop);
} else {
getInputMessageQueue()->push(stop);
}
}
}
return 202;
}
else
{
errorMessage = "Missing FreqScannerActions in query";
return 400;
}
}
void FreqScanner::webapiUpdateChannelSettings( void FreqScanner::webapiUpdateChannelSettings(
FreqScannerSettings& settings, FreqScannerSettings& settings,
const QStringList& channelSettingsKeys, const QStringList& channelSettingsKeys,
@ -984,6 +1028,17 @@ void FreqScanner::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& r
void FreqScanner::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response) void FreqScanner::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
{ {
response.getFreqScannerReport()->setChannelSampleRate(m_basebandSink->getChannelSampleRate()); response.getFreqScannerReport()->setChannelSampleRate(m_basebandSink->getChannelSampleRate());
response.getFreqScannerReport()->setScanState((int) m_state);
QList<SWGSDRangel::SWGFreqScannerChannelState *> *list = response.getFreqScannerReport()->getChannelState();
for (int i = 0; i < m_scanResultsForReport.size(); i++)
{
SWGSDRangel::SWGFreqScannerChannelState *channelState = new SWGSDRangel::SWGFreqScannerChannelState();
channelState->setFrequency(m_scanResultsForReport[i].m_frequency);
channelState->setPower(m_scanResultsForReport[i].m_power);
list->append(channelState);
}
} }
void FreqScanner::webapiReverseSendSettings(const QStringList& channelSettingsKeys, const FreqScannerSettings& settings, bool force) void FreqScanner::webapiReverseSendSettings(const QStringList& channelSettingsKeys, const FreqScannerSettings& settings, bool force)

View File

@ -341,6 +341,11 @@ public:
SWGSDRangel::SWGChannelReport& response, SWGSDRangel::SWGChannelReport& response,
QString& errorMessage); QString& errorMessage);
virtual int webapiActionsPost(
const QStringList& channelActionsKeys,
SWGSDRangel::SWGChannelActions& query,
QString& errorMessage);
static void webapiFormatChannelSettings( static void webapiFormatChannelSettings(
SWGSDRangel::SWGChannelSettings& response, SWGSDRangel::SWGChannelSettings& response,
const FreqScannerSettings& settings); const FreqScannerSettings& settings);
@ -388,6 +393,7 @@ private:
qint64 m_stepStartFrequency; qint64 m_stepStartFrequency;
qint64 m_stepStopFrequency; qint64 m_stepStopFrequency;
QList<MsgScanResult::ScanResult> m_scanResults; QList<MsgScanResult::ScanResult> m_scanResults;
QList<MsgScanResult::ScanResult> m_scanResultsForReport;
enum State { enum State {
IDLE, IDLE,

View File

@ -204,6 +204,16 @@ bool FreqScannerGUI::handleMessage(const Message& message)
return true; return true;
} }
else if (FreqScanner::MsgStartScan::match(message))
{
ui->startStop->doToggle(true);
return true;
}
else if (FreqScanner::MsgStopScan::match(message))
{
ui->startStop->doToggle(false);
return true;
}
return false; return false;
} }
@ -609,7 +619,7 @@ void FreqScannerGUI::enterEvent(EnterEventType* event)
ChannelGUI::enterEvent(event); ChannelGUI::enterEvent(event);
} }
void FreqScannerGUI::on_startStop_clicked(bool checked) void FreqScannerGUI::on_startStop_toggled(bool checked)
{ {
if (checked) if (checked)
{ {
@ -1080,7 +1090,7 @@ void FreqScannerGUI::makeUIConnections()
QObject::connect(ui->priority, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &FreqScannerGUI::on_priority_currentIndexChanged); QObject::connect(ui->priority, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &FreqScannerGUI::on_priority_currentIndexChanged);
QObject::connect(ui->measurement, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &FreqScannerGUI::on_measurement_currentIndexChanged); QObject::connect(ui->measurement, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &FreqScannerGUI::on_measurement_currentIndexChanged);
QObject::connect(ui->mode, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &FreqScannerGUI::on_mode_currentIndexChanged); QObject::connect(ui->mode, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &FreqScannerGUI::on_mode_currentIndexChanged);
QObject::connect(ui->startStop, &ButtonSwitch::clicked, this, &FreqScannerGUI::on_startStop_clicked); QObject::connect(ui->startStop, &ButtonSwitch::toggled, this, &FreqScannerGUI::on_startStop_toggled);
QObject::connect(ui->table, &QTableWidget::cellChanged, this, &FreqScannerGUI::on_table_cellChanged); QObject::connect(ui->table, &QTableWidget::cellChanged, this, &FreqScannerGUI::on_table_cellChanged);
QObject::connect(ui->addSingle, &QToolButton::clicked, this, &FreqScannerGUI::on_addSingle_clicked); 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->addRange, &QToolButton::clicked, this, &FreqScannerGUI::on_addRange_clicked);

View File

@ -140,7 +140,7 @@ private slots:
void table_sectionResized(int logicalIndex, int oldSize, int newSize); void table_sectionResized(int logicalIndex, int oldSize, int newSize);
void columnSelectMenu(QPoint pos); void columnSelectMenu(QPoint pos);
void columnSelectMenuChecked(bool checked = false); void columnSelectMenuChecked(bool checked = false);
void on_startStop_clicked(bool checked = false); void on_startStop_toggled(bool checked = false);
void on_addSingle_clicked(); void on_addSingle_clicked();
void on_addRange_clicked(); void on_addRange_clicked();
void on_remove_clicked(); void on_remove_clicked();

View File

@ -140,3 +140,15 @@ Moves the selected rows the the frequency table (14).
<h3>21: 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. Press to reset the value in the Active Count column to 0 for all rows.
<h2>API</h2>
Full details of the API can be found in the Swagger documentation. Below are a few examples.
To run a frequency scan:
curl -X POST "http://127.0.0.1:8091/sdrangel/deviceset/0/channel/0/actions" -d '{ "channelType": "FreqScanner", "direction": 0, "originatorDeviceSetIndex": 0, "originatorChannelIndex": 0, "FreqScannerActions": { "run": 1 }}'
To get the results of the last scan:
curl -X GET "http://127.0.0.1:8091/sdrangel/deviceset/0/channel/0/report"

View File

@ -4821,6 +4821,11 @@ bool WebAPIRequestMapper::getChannelActions(
channelActions->setFileSourceActions(new SWGSDRangel::SWGFileSourceActions()); channelActions->setFileSourceActions(new SWGSDRangel::SWGFileSourceActions());
channelActions->getFileSourceActions()->fromJsonObject(actionsJsonObject); channelActions->getFileSourceActions()->fromJsonObject(actionsJsonObject);
} }
else if (channelActionsKey == "FreqScannerActions")
{
channelActions->setFreqScannerActions(new SWGSDRangel::SWGFreqScannerActions());
channelActions->getFreqScannerActions()->fromJsonObject(actionsJsonObject);
}
else if (channelActionsKey == "IEEE_802_15_4_ModActions") else if (channelActionsKey == "IEEE_802_15_4_ModActions")
{ {
channelActions->setIeee802154ModActions(new SWGSDRangel::SWGIEEE_802_15_4_ModActions()); channelActions->setIeee802154ModActions(new SWGSDRangel::SWGIEEE_802_15_4_ModActions());
@ -5629,6 +5634,7 @@ void WebAPIRequestMapper::resetChannelActions(SWGSDRangel::SWGChannelActions& ch
channelActions.setAptDemodActions(nullptr); channelActions.setAptDemodActions(nullptr);
channelActions.setChannelType(nullptr); channelActions.setChannelType(nullptr);
channelActions.setFileSourceActions(nullptr); channelActions.setFileSourceActions(nullptr);
channelActions.setFreqScannerActions(nullptr);
channelActions.setIeee802154ModActions(nullptr); channelActions.setIeee802154ModActions(nullptr);
channelActions.setPacketModActions(nullptr); channelActions.setPacketModActions(nullptr);
channelActions.setPsk31ModActions(nullptr); channelActions.setPsk31ModActions(nullptr);

View File

@ -216,6 +216,7 @@ const QMap<QString, QString> WebAPIUtils::m_channelTypeToActionsKey = {
{"APTDemod", "APTDemodActions"}, {"APTDemod", "APTDemodActions"},
{"FileSink", "FileSinkActions"}, {"FileSink", "FileSinkActions"},
{"FileSource", "FileSourceActions"}, {"FileSource", "FileSourceActions"},
{"FreqScanner", "FreqScannerActions"},
{"SigMFFileSink", "SigMFFileSinkActions"}, {"SigMFFileSink", "SigMFFileSinkActions"},
{"IEEE_802_15_4_Mod", "IEEE_802_15_4_ModActions"}, {"IEEE_802_15_4_Mod", "IEEE_802_15_4_ModActions"},
{"RadioAstronomy", "RadioAstronomyActions"}, {"RadioAstronomy", "RadioAstronomyActions"},