mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-06-12 19:42:34 -04:00
Add --start option to start all devices and features. For #2359.
This commit is contained in:
parent
83b36c6aab
commit
f841eecab9
@ -20,12 +20,42 @@
|
||||
#include "SWGFeatureActions.h"
|
||||
#include "SWGMapActions.h"
|
||||
#include "SWGPERTesterActions.h"
|
||||
#include "SWGDeviceState.h"
|
||||
|
||||
#include "maincore.h"
|
||||
#include "feature/featureset.h"
|
||||
#include "feature/feature.h"
|
||||
#include "featurewebapiutils.h"
|
||||
|
||||
// Start feature
|
||||
bool FeatureWebAPIUtils::run(int featureSetIndex, int featureIndex)
|
||||
{
|
||||
Feature *feature = FeatureWebAPIUtils::getFeature(featureSetIndex, featureIndex, "");
|
||||
if (feature != nullptr)
|
||||
{
|
||||
SWGSDRangel::SWGDeviceState runResponse;
|
||||
QString errorResponse;
|
||||
int httpRC;
|
||||
|
||||
runResponse.setState(new QString());
|
||||
httpRC = feature->webapiRun(true, runResponse, errorResponse);
|
||||
|
||||
if (httpRC/100 != 2)
|
||||
{
|
||||
qWarning("FeatureWebAPIUtils::run: run error %d: %s",
|
||||
httpRC, qPrintable(errorResponse));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning("FeatureWebAPIUtils::run: no feature F%d:%d", featureSetIndex, featureIndex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Find the specified target on the map
|
||||
bool FeatureWebAPIUtils::mapFind(const QString& target, int featureSetIndex, int featureIndex)
|
||||
{
|
||||
|
@ -47,6 +47,7 @@ private slots:
|
||||
class SDRBASE_API FeatureWebAPIUtils
|
||||
{
|
||||
public:
|
||||
static bool run(int featureSetIndex, int featureIndex);
|
||||
static bool mapFind(const QString& target, int featureSetIndex=-1, int featureIndex=-1);
|
||||
static bool mapSetDateTime(const QDateTime& dateTime, int featureSetIndex=-1, int featureIndex=-1);
|
||||
static bool skyMapFind(const QString& target, int featureSetIndex=-1, int featureIndex=-1);
|
||||
|
@ -42,7 +42,8 @@ MainParser::MainParser() :
|
||||
m_remoteTCPSinkPortOption("remote-tcp-port", "Remote TCP Sink port (Default 1234).", "port", "1234"),
|
||||
m_remoteTCPSinkHWTypeOption("remote-tcp-hwtype", "Remote TCP Sink device hardware type (Optional. E.g. RTLSDR/SDRplayV3/AirspyHF).", "hwtype"),
|
||||
m_remoteTCPSinkSerialOption("remote-tcp-serial", "Remote TCP Sink device serial (Optional).", "serial"),
|
||||
m_listDevicesOption("list-devices", "List available physical devices.")
|
||||
m_listDevicesOption("list-devices", "List available physical devices."),
|
||||
m_startOption("start", "Start all devices and features")
|
||||
{
|
||||
|
||||
m_serverAddress = ""; // Bind to any address
|
||||
@ -56,6 +57,7 @@ MainParser::MainParser() :
|
||||
m_remoteTCPSinkHWType = "";
|
||||
m_remoteTCPSinkSerial = "";
|
||||
m_listDevices = false;
|
||||
m_start = false;
|
||||
|
||||
m_parser.setApplicationDescription("Software Defined Radio application");
|
||||
m_parser.addHelpOption();
|
||||
@ -72,6 +74,7 @@ MainParser::MainParser() :
|
||||
m_parser.addOption(m_remoteTCPSinkHWTypeOption);
|
||||
m_parser.addOption(m_remoteTCPSinkSerialOption);
|
||||
m_parser.addOption(m_listDevicesOption);
|
||||
m_parser.addOption(m_startOption);
|
||||
}
|
||||
|
||||
MainParser::~MainParser()
|
||||
@ -154,4 +157,8 @@ void MainParser::parse(const QCoreApplication& app)
|
||||
qCritical() << "You must specify a device with either --remote-tcp-hwtype or --remote-tcp-serial";
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Start devices and features
|
||||
m_start = m_parser.isSet(m_startOption);
|
||||
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
const QString& getRemoteTCPSinkHWType() const { return m_remoteTCPSinkHWType; }
|
||||
const QString& getRemoteTCPSinkSerial() const { return m_remoteTCPSinkSerial; }
|
||||
bool getListDevices() const { return m_listDevices; }
|
||||
bool getStart() const { return m_start; }
|
||||
|
||||
private:
|
||||
QString m_serverAddress;
|
||||
@ -58,6 +59,7 @@ private:
|
||||
QString m_remoteTCPSinkHWType;
|
||||
QString m_remoteTCPSinkSerial;
|
||||
bool m_listDevices;
|
||||
bool m_start;
|
||||
|
||||
QCommandLineParser m_parser;
|
||||
QCommandLineOption m_serverAddressOption;
|
||||
@ -71,6 +73,7 @@ private:
|
||||
QCommandLineOption m_remoteTCPSinkHWTypeOption;
|
||||
QCommandLineOption m_remoteTCPSinkSerialOption;
|
||||
QCommandLineOption m_listDevicesOption;
|
||||
QCommandLineOption m_startOption;
|
||||
};
|
||||
|
||||
|
||||
|
@ -61,6 +61,7 @@
|
||||
#include "feature/featureset.h"
|
||||
#include "feature/feature.h"
|
||||
#include "feature/featuregui.h"
|
||||
#include "feature/featurewebapiutils.h"
|
||||
#include "mainspectrum/mainspectrumgui.h"
|
||||
#include "commands/commandkeyreceiver.h"
|
||||
#include "gui/presetitem.h"
|
||||
@ -275,6 +276,9 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parse
|
||||
InitFSM *fsm = new InitFSM(this, splash, !parser.getScratch());
|
||||
connect(fsm, &InitFSM::finished, fsm, &InitFSM::deleteLater);
|
||||
connect(fsm, &InitFSM::finished, splash, &SDRangelSplash::deleteLater);
|
||||
if (parser.getStart()) {
|
||||
connect(fsm, &InitFSM::finished, this, &MainWindow::startAllAfterDelay);
|
||||
}
|
||||
fsm->start();
|
||||
|
||||
qDebug() << "MainWindow::MainWindow: end";
|
||||
@ -3382,6 +3386,30 @@ void MainWindow::showAllChannels(int deviceSetIndex)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::startAllAfterDelay()
|
||||
{
|
||||
// Wait a little bit before starting all devices and features,
|
||||
// as some devices, such as FileSinks, can fail to start if run before initialised
|
||||
// Is there a better way than this arbitrary time?
|
||||
QTimer::singleShot(1000, this, &MainWindow::startAll);
|
||||
}
|
||||
|
||||
// Start all devices and features in all workspaces
|
||||
void MainWindow::startAll()
|
||||
{
|
||||
// Start all devices
|
||||
for (const auto& workspace : m_workspaces) {
|
||||
startAllDevices(workspace);
|
||||
}
|
||||
// Start all features
|
||||
for (int featureSetIndex = 0; featureSetIndex < m_featureUIs.size(); featureSetIndex++)
|
||||
{
|
||||
for (int featureIndex = 0; featureIndex < m_featureUIs[featureSetIndex]->getNumberOfFeatures(); featureIndex++) {
|
||||
FeatureWebAPIUtils::run(featureSetIndex, featureIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Start all devices in the workspace
|
||||
void MainWindow::startAllDevices(const Workspace *workspace) const
|
||||
{
|
||||
|
@ -458,6 +458,8 @@ private slots:
|
||||
void featureMove(FeatureGUI *gui, int wsIndexDestnation);
|
||||
void deviceStateChanged(DeviceAPI *deviceAPI);
|
||||
void openFeaturePresetsDialog(QPoint p, Workspace *workspace);
|
||||
void startAllAfterDelay();
|
||||
void startAll();
|
||||
void startAllDevices(const Workspace *workspace) const;
|
||||
void stopAllDevices(const Workspace *workspace) const;
|
||||
void deviceMove(DeviceGUI *gui, int wsIndexDestnation);
|
||||
|
Loading…
x
Reference in New Issue
Block a user