1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 01:18:38 -05:00

Create a MainCore singleton and renamed MainCore to MainServer

This commit is contained in:
f4exb 2020-10-09 08:52:30 +02:00
parent d3ce9d49d0
commit 5f2e251629
9 changed files with 725 additions and 615 deletions

View File

@ -104,6 +104,7 @@ static int runQtApplication(int argc, char* argv[], qtwebapp::LoggerWithFile *lo
qtwebapp::LoggerWithFile *logger = new qtwebapp::LoggerWithFile(qApp);
logger->installMsgHandler();
int res = runQtApplication(argc, argv, logger);
delete logger;
qWarning("SDRangel quit.");
return res;
}

View File

@ -178,6 +178,7 @@ set(sdrbase_SOURCES
websockets/wsspectrum.cpp
mainparser.cpp
maincore.cpp
resources/webapi.qrc
)
@ -340,11 +341,13 @@ set(sdrbase_HEADERS
websockets/wsspectrum.h
mainparser.h
maincore.h
)
include_directories(
${CMAKE_SOURCE_DIR}/exports
${CMAKE_SOURCE_DIR}/httpserver
${CMAKE_SOURCE_DIR}/logging
${CMAKE_SOURCE_DIR}/qrtplib
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
${Boost_INCLUDE_DIRS}
@ -372,6 +375,7 @@ target_link_libraries(sdrbase
Qt5::Multimedia
Qt5::WebSockets
httpserver
logging
qrtplib
swagger
)

102
sdrbase/maincore.cpp Normal file
View File

@ -0,0 +1,102 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QGlobalStatic>
#include <QCoreApplication>
#include <QString>
#include "loggerwithfile.h"
#include "dsp/dsptypes.h"
#include "maincore.h"
MESSAGE_CLASS_DEFINITION(MainCore::MsgDeleteInstance, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgLoadPreset, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgSavePreset, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgDeletePreset, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgLoadFeatureSetPreset, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgSaveFeatureSetPreset, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgDeleteFeatureSetPreset, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgAddDeviceSet, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgRemoveLastDeviceSet, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgSetDevice, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgAddChannel, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgDeleteChannel, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgApplySettings, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgAddFeature, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgDeleteFeature, Message)
MainCore::MainCore()
{}
MainCore::~MainCore()
{}
Q_GLOBAL_STATIC(MainCore, mainCore)
MainCore *MainCore::instance()
{
return mainCore;
}
void MainCore::setLoggingOptions()
{
m_logger->setConsoleMinMessageLevel(m_settings.getConsoleMinLogLevel());
if (m_settings.getUseLogFile())
{
qtwebapp::FileLoggerSettings fileLoggerSettings; // default values
if (m_logger->hasFileLogger()) {
fileLoggerSettings = m_logger->getFileLoggerSettings(); // values from file logger if it exists
}
fileLoggerSettings.fileName = m_settings.getLogFileName(); // put new values
m_logger->createOrSetFileLogger(fileLoggerSettings, 2000); // create file logger if it does not exist and apply settings in any case
}
if (m_logger->hasFileLogger()) {
m_logger->setFileMinMessageLevel(m_settings.getFileMinLogLevel());
}
m_logger->setUseFileLogger(m_settings.getUseLogFile());
if (m_settings.getUseLogFile())
{
#if QT_VERSION >= 0x050400
QString appInfoStr(QString("%1 %2 Qt %3 %4b %5 %6 DSP Rx:%7b Tx:%8b PID %9")
.arg(QCoreApplication::applicationName())
.arg(QCoreApplication::applicationVersion())
.arg(QT_VERSION_STR)
.arg(QT_POINTER_SIZE*8)
.arg(QSysInfo::currentCpuArchitecture())
.arg(QSysInfo::prettyProductName())
.arg(SDR_RX_SAMP_SZ)
.arg(SDR_TX_SAMP_SZ)
.arg(QCoreApplication::applicationPid()));
#else
QString appInfoStr(QString("%1 %2 Qt %3 %4b DSP Rx:%5b Tx:%6b PID %7")
.arg(QCoreApplication::applicationName())
.arg(QCoreApplication::applicationVersion())
.arg(QT_VERSION_STR)
.arg(QT_POINTER_SIZE*8)
.arg(SDR_RX_SAMP_SZ)
.arg(SDR_RX_SAMP_SZ)
.arg(QCoreApplication::applicationPid());
#endif
m_logger->logToFile(QtInfoMsg, appInfoStr);
}
}

389
sdrbase/maincore.h Normal file
View File

@ -0,0 +1,389 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRBASE_MAINCORE_H_
#define SDRBASE_MAINCORE_H_
#include <vector>
#include <QTimer>
#include "export.h"
#include "settings/mainsettings.h"
#include "util/message.h"
class DeviceSet;
class FeatureSet;
class PluginManager;
class MessageQueue;
namespace qtwebapp {
class LoggerWithFile;
}
class SDRBASE_API MainCore
{
public:
class MsgLoadPreset : public Message {
MESSAGE_CLASS_DECLARATION
public:
const Preset *getPreset() const { return m_preset; }
int getDeviceSetIndex() const { return m_deviceSetIndex; }
static MsgLoadPreset* create(const Preset *preset, int deviceSetIndex)
{
return new MsgLoadPreset(preset, deviceSetIndex);
}
private:
const Preset *m_preset;
int m_deviceSetIndex;
MsgLoadPreset(const Preset *preset, int deviceSetIndex) :
Message(),
m_preset(preset),
m_deviceSetIndex(deviceSetIndex)
{ }
};
class MsgSavePreset : public Message {
MESSAGE_CLASS_DECLARATION
public:
Preset *getPreset() const { return m_preset; }
int getDeviceSetIndex() const { return m_deviceSetIndex; }
bool isNewPreset() const { return m_newPreset; }
static MsgSavePreset* create(Preset *preset, int deviceSetIndex, bool newPreset)
{
return new MsgSavePreset(preset, deviceSetIndex, newPreset);
}
private:
Preset *m_preset;
int m_deviceSetIndex;
bool m_newPreset;
MsgSavePreset(Preset *preset, int deviceSetIndex, bool newPreset) :
Message(),
m_preset(preset),
m_deviceSetIndex(deviceSetIndex),
m_newPreset(newPreset)
{ }
};
class MsgDeletePreset : public Message {
MESSAGE_CLASS_DECLARATION
public:
const Preset *getPreset() const { return m_preset; }
static MsgDeletePreset* create(const Preset *preset)
{
return new MsgDeletePreset(preset);
}
private:
const Preset *m_preset;
MsgDeletePreset(const Preset *preset) :
Message(),
m_preset(preset)
{ }
};
class MsgLoadFeatureSetPreset : public Message {
MESSAGE_CLASS_DECLARATION
public:
const FeatureSetPreset *getPreset() const { return m_preset; }
int getFeatureSetIndex() const { return m_featureSetIndex; }
static MsgLoadFeatureSetPreset* create(const FeatureSetPreset *preset, int featureSetIndex) {
return new MsgLoadFeatureSetPreset(preset, featureSetIndex);
}
private:
const FeatureSetPreset *m_preset;
int m_featureSetIndex;
MsgLoadFeatureSetPreset(const FeatureSetPreset *preset, int featureSetIndex) :
Message(),
m_preset(preset),
m_featureSetIndex(featureSetIndex)
{ }
};
class MsgSaveFeatureSetPreset : public Message {
MESSAGE_CLASS_DECLARATION
public:
FeatureSetPreset *getPreset() const { return m_preset; }
int getFeatureSetIndex() const { return m_featureSetIndex; }
bool isNewPreset() const { return m_newPreset; }
static MsgSaveFeatureSetPreset* create(FeatureSetPreset *preset, int featureSetIndex, bool newPreset)
{
return new MsgSaveFeatureSetPreset(preset, featureSetIndex, newPreset);
}
private:
FeatureSetPreset *m_preset;
int m_featureSetIndex;
bool m_newPreset;
MsgSaveFeatureSetPreset(FeatureSetPreset *preset, int featureSetIndex, bool newPreset) :
Message(),
m_preset(preset),
m_featureSetIndex(featureSetIndex),
m_newPreset(newPreset)
{ }
};
class MsgDeleteFeatureSetPreset : public Message {
MESSAGE_CLASS_DECLARATION
public:
const FeatureSetPreset *getPreset() const { return m_preset; }
static MsgDeleteFeatureSetPreset* create(const FeatureSetPreset *preset)
{
return new MsgDeleteFeatureSetPreset(preset);
}
private:
const FeatureSetPreset *m_preset;
MsgDeleteFeatureSetPreset(const FeatureSetPreset *preset) :
Message(),
m_preset(preset)
{ }
};
class MsgDeleteInstance : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgDeleteInstance* create()
{
return new MsgDeleteInstance();
}
private:
MsgDeleteInstance() :
Message()
{ }
};
class MsgAddDeviceSet : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getDirection() const { return m_direction; }
static MsgAddDeviceSet* create(int direction)
{
return new MsgAddDeviceSet(direction);
}
private:
int m_direction;
MsgAddDeviceSet(int direction) :
Message(),
m_direction(direction)
{ }
};
class MsgRemoveLastDeviceSet : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgRemoveLastDeviceSet* create()
{
return new MsgRemoveLastDeviceSet();
}
private:
MsgRemoveLastDeviceSet() :
Message()
{ }
};
class MsgSetDevice : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getDeviceSetIndex() const { return m_deviceSetIndex; }
int getDeviceIndex() const { return m_deviceIndex; }
int getDeviceType() const { return m_deviceType; }
static MsgSetDevice* create(int deviceSetIndex, int deviceIndex, int deviceType)
{
return new MsgSetDevice(deviceSetIndex, deviceIndex, deviceType);
}
private:
int m_deviceSetIndex;
int m_deviceIndex;
int m_deviceType;
MsgSetDevice(int deviceSetIndex, int deviceIndex, int deviceType) :
Message(),
m_deviceSetIndex(deviceSetIndex),
m_deviceIndex(deviceIndex),
m_deviceType(deviceType)
{ }
};
class MsgAddChannel : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getDeviceSetIndex() const { return m_deviceSetIndex; }
int getChannelRegistrationIndex() const { return m_channelRegistrationIndex; }
bool isTx() const { return m_tx; }
static MsgAddChannel* create(int deviceSetIndex, int channelRegistrationIndex, bool tx)
{
return new MsgAddChannel(deviceSetIndex, channelRegistrationIndex, tx);
}
private:
int m_deviceSetIndex;
int m_channelRegistrationIndex;
bool m_tx;
MsgAddChannel(int deviceSetIndex, int channelRegistrationIndex, bool tx) :
Message(),
m_deviceSetIndex(deviceSetIndex),
m_channelRegistrationIndex(channelRegistrationIndex),
m_tx(tx)
{ }
};
class MsgDeleteChannel : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getDeviceSetIndex() const { return m_deviceSetIndex; }
int getChannelIndex() const { return m_channelIndex; }
static MsgDeleteChannel* create(int deviceSetIndex, int channelIndex)
{
return new MsgDeleteChannel(deviceSetIndex, channelIndex);
}
private:
int m_deviceSetIndex;
int m_channelIndex;
MsgDeleteChannel(int deviceSetIndex, int channelIndex) :
Message(),
m_deviceSetIndex(deviceSetIndex),
m_channelIndex(channelIndex)
{ }
};
class MsgApplySettings : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgApplySettings* create() {
return new MsgApplySettings();
}
private:
MsgApplySettings() :
Message()
{ }
};
class MsgAddFeature : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getFeatureSetIndex() const { return m_featureSetIndex; }
int getFeatureRegistrationIndex() const { return m_featureRegistrationIndex; }
static MsgAddFeature* create(int featureSetIndex, int featureRegistrationIndex)
{
return new MsgAddFeature(featureSetIndex, featureRegistrationIndex);
}
private:
int m_featureSetIndex;
int m_featureRegistrationIndex;
MsgAddFeature(int featureSetIndex, int featureRegistrationIndex) :
Message(),
m_featureSetIndex(featureSetIndex),
m_featureRegistrationIndex(featureRegistrationIndex)
{ }
};
class MsgDeleteFeature : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getFeatureSetIndex() const { return m_featureSetIndex; }
int getFeatureIndex() const { return m_featureIndex; }
static MsgDeleteFeature* create(int m_featureSetIndex, int m_featureIndex) {
return new MsgDeleteFeature(m_featureSetIndex, m_featureIndex);
}
private:
int m_featureSetIndex;
int m_featureIndex;
MsgDeleteFeature(int m_featureSetIndex, int m_featureIndex) :
Message(),
m_featureSetIndex(m_featureSetIndex),
m_featureIndex(m_featureIndex)
{ }
};
MainCore();
~MainCore();
static MainCore *instance();
const QTimer& getMasterTimer() const { return m_masterTimer; }
const MainSettings& getSettings() const { return m_settings; }
MessageQueue *getMainMessageQueue() { return m_mainMessageQueue; }
const PluginManager *getPluginManager() const { return m_pluginManager; }
std::vector<DeviceSet*>& getDeviceSets() { return m_deviceSets; }
std::vector<FeatureSet*>& getFeatureeSets() { return m_featureSets; }
void setLoggingOptions();
friend class MainServer;
friend class MainWindow;
friend class WebAPIAdapterSrv;
private:
MainSettings m_settings;
qtwebapp::LoggerWithFile *m_logger;
MessageQueue *m_mainMessageQueue;
int m_masterTabIndex;
QTimer m_masterTimer;
std::vector<DeviceSet*> m_deviceSets;
std::vector<FeatureSet*> m_featureSets;
PluginManager* m_pluginManager;
};
#endif // SDRBASE_MAINCORE_H_

View File

@ -16,7 +16,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <gui/commandkeyreceiver.h>
#include <QInputDialog>
#include <QMessageBox>
#include <QLabel>
@ -30,8 +29,7 @@
#include <QResource>
#include <QFontDatabase>
#include <device/devicegui.h>
#include <device/devicegui.h>
#include "device/devicegui.h"
#include "device/deviceapi.h"
#include "device/deviceuiset.h"
#include "device/deviceenumerator.h"
@ -39,6 +37,7 @@
#include "channel/channelgui.h"
#include "feature/featureuiset.h"
#include "feature/feature.h"
#include "gui/commandkeyreceiver.h"
#include "gui/indicator.h"
#include "gui/presetitem.h"
#include "gui/commanditem.h"

View File

@ -30,54 +30,37 @@
#include "device/deviceenumerator.h"
#include "feature/featureset.h"
#include "plugin/pluginmanager.h"
#include "loggerwithfile.h"
#include "webapi/webapirequestmapper.h"
#include "webapi/webapiserver.h"
#include "webapi/webapiadaptersrv.h"
#include "mainserver.h"
MESSAGE_CLASS_DEFINITION(MainServer::MsgDeleteInstance, Message)
MESSAGE_CLASS_DEFINITION(MainServer::MsgLoadPreset, Message)
MESSAGE_CLASS_DEFINITION(MainServer::MsgSavePreset, Message)
MESSAGE_CLASS_DEFINITION(MainServer::MsgDeletePreset, Message)
MESSAGE_CLASS_DEFINITION(MainServer::MsgLoadFeatureSetPreset, Message)
MESSAGE_CLASS_DEFINITION(MainServer::MsgSaveFeatureSetPreset, Message)
MESSAGE_CLASS_DEFINITION(MainServer::MsgDeleteFeatureSetPreset, Message)
MESSAGE_CLASS_DEFINITION(MainServer::MsgAddDeviceSet, Message)
MESSAGE_CLASS_DEFINITION(MainServer::MsgRemoveLastDeviceSet, Message)
MESSAGE_CLASS_DEFINITION(MainServer::MsgSetDevice, Message)
MESSAGE_CLASS_DEFINITION(MainServer::MsgAddChannel, Message)
MESSAGE_CLASS_DEFINITION(MainServer::MsgDeleteChannel, Message)
MESSAGE_CLASS_DEFINITION(MainServer::MsgApplySettings, Message)
MESSAGE_CLASS_DEFINITION(MainServer::MsgAddFeature, Message)
MESSAGE_CLASS_DEFINITION(MainServer::MsgDeleteFeature, Message)
MainServer *MainServer::m_instance = 0;
MainServer::MainServer(qtwebapp::LoggerWithFile *logger, const MainParser& parser, QObject *parent) :
QObject(parent),
m_settings(),
m_masterTabIndex(-1),
m_dspEngine(DSPEngine::instance()),
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted),
m_logger(logger)
m_mainCore(MainCore::instance()),
m_dspEngine(DSPEngine::instance())
{
qDebug() << "MainServer::MainServer: start";
m_instance = this;
m_settings.setAudioDeviceManager(m_dspEngine->getAudioDeviceManager());
m_settings.setAMBEEngine(m_dspEngine->getAMBEEngine());
m_mainCore->m_logger = logger;
m_mainCore->m_mainMessageQueue = &m_inputMessageQueue;
m_mainCore->m_settings.setAudioDeviceManager(m_dspEngine->getAudioDeviceManager());
m_mainCore->m_settings.setAMBEEngine(m_dspEngine->getAMBEEngine());
m_mainCore->m_masterTabIndex = -1;
qDebug() << "MainServer::MainServer: create FFT factory...";
m_dspEngine->createFFTFactory(parser.getFFTWFWisdomFileName());
qDebug() << "MainServer::MainServer: load plugins...";
m_pluginManager = new PluginManager(this);
m_pluginManager->loadPlugins(QString("pluginssrv"));
m_mainCore->m_pluginManager = new PluginManager(this);
m_mainCore->m_pluginManager->loadPlugins(QString("pluginssrv"));
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection);
m_masterTimer.start(50);
m_mainCore->m_masterTimer.start(50);
qDebug() << "MainServer::MainServer: load setings...";
loadSettings();
@ -85,7 +68,7 @@ MainServer::MainServer(qtwebapp::LoggerWithFile *logger, const MainParser& parse
qDebug() << "MainServer::MainServer: finishing...";
QString applicationDirPath = QCoreApplication::instance()->applicationDirPath();
m_apiAdapter = new WebAPIAdapterSrv(*this);
m_apiAdapter = new WebAPIAdapterSrv(*m_mainCore);
m_requestMapper = new WebAPIRequestMapper(this);
m_requestMapper->setAdapter(m_apiAdapter);
m_apiHost = parser.getServerAddress();
@ -100,27 +83,26 @@ MainServer::MainServer(qtwebapp::LoggerWithFile *logger, const MainParser& parse
MainServer::~MainServer()
{
while (m_deviceSets.size() > 0) {
while (m_mainCore->m_deviceSets.size() > 0) {
removeLastDevice();
}
m_apiServer->stop();
m_settings.save();
m_mainCore->m_settings.save();
delete m_apiServer;
delete m_requestMapper;
delete m_apiAdapter;
delete m_pluginManager;
delete m_mainCore->m_pluginManager;
qDebug() << "MainServer::~MainServer: end";
delete m_logger;
}
bool MainServer::handleMessage(const Message& cmd)
{
if (MsgDeleteInstance::match(cmd))
if (MainCore::MsgDeleteInstance::match(cmd))
{
while (m_deviceSets.size() > 0)
while (m_mainCore->m_deviceSets.size() > 0)
{
removeLastDevice();
}
@ -128,53 +110,53 @@ bool MainServer::handleMessage(const Message& cmd)
emit finished();
return true;
}
else if (MsgLoadPreset::match(cmd))
else if (MainCore::MsgLoadPreset::match(cmd))
{
MsgLoadPreset& notif = (MsgLoadPreset&) cmd;
MainCore::MsgLoadPreset& notif = (MainCore::MsgLoadPreset&) cmd;
loadPresetSettings(notif.getPreset(), notif.getDeviceSetIndex());
return true;
}
else if (MsgSavePreset::match(cmd))
else if (MainCore::MsgSavePreset::match(cmd))
{
MsgSavePreset& notif = (MsgSavePreset&) cmd;
MainCore::MsgSavePreset& notif = (MainCore::MsgSavePreset&) cmd;
savePresetSettings(notif.getPreset(), notif.getDeviceSetIndex());
m_settings.sortPresets();
m_settings.save();
m_mainCore->m_settings.sortPresets();
m_mainCore->m_settings.save();
return true;
}
else if (MsgDeletePreset::match(cmd))
else if (MainCore::MsgDeletePreset::match(cmd))
{
MsgDeletePreset& notif = (MsgDeletePreset&) cmd;
MainCore::MsgDeletePreset& notif = (MainCore::MsgDeletePreset&) cmd;
const Preset *presetToDelete = notif.getPreset();
// remove preset from settings
m_settings.deletePreset(presetToDelete);
m_mainCore->m_settings.deletePreset(presetToDelete);
return true;
}
else if (MsgLoadFeatureSetPreset::match(cmd))
else if (MainCore::MsgLoadFeatureSetPreset::match(cmd))
{
MsgLoadFeatureSetPreset& notif = (MsgLoadFeatureSetPreset&) cmd;
MainCore::MsgLoadFeatureSetPreset& notif = (MainCore::MsgLoadFeatureSetPreset&) cmd;
loadFeatureSetPresetSettings(notif.getPreset(), notif.getFeatureSetIndex());
return true;
}
else if (MsgSaveFeatureSetPreset::match(cmd))
else if (MainCore::MsgSaveFeatureSetPreset::match(cmd))
{
MsgSaveFeatureSetPreset& notif = (MsgSaveFeatureSetPreset&) cmd;
MainCore::MsgSaveFeatureSetPreset& notif = (MainCore::MsgSaveFeatureSetPreset&) cmd;
saveFeatureSetPresetSettings(notif.getPreset(), notif.getFeatureSetIndex());
m_settings.sortPresets();
m_settings.save();
m_mainCore->m_settings.sortPresets();
m_mainCore->m_settings.save();
return true;
}
else if (MsgDeleteFeatureSetPreset::match(cmd))
else if (MainCore::MsgDeleteFeatureSetPreset::match(cmd))
{
MsgDeleteFeatureSetPreset& notif = (MsgDeleteFeatureSetPreset&) cmd;
MainCore::MsgDeleteFeatureSetPreset& notif = (MainCore::MsgDeleteFeatureSetPreset&) cmd;
const FeatureSetPreset *presetToDelete = notif.getPreset();
// remove preset from settings
m_settings.deleteFeatureSetPreset(presetToDelete);
m_mainCore->m_settings.deleteFeatureSetPreset(presetToDelete);
return true;
}
else if (MsgAddDeviceSet::match(cmd))
else if (MainCore::MsgAddDeviceSet::match(cmd))
{
MsgAddDeviceSet& notif = (MsgAddDeviceSet&) cmd;
MainCore::MsgAddDeviceSet& notif = (MainCore::MsgAddDeviceSet&) cmd;
int direction = notif.getDirection();
if (direction == 1) { // Single stream Tx
@ -185,17 +167,17 @@ bool MainServer::handleMessage(const Message& cmd)
return true;
}
else if (MsgRemoveLastDeviceSet::match(cmd))
else if (MainCore::MsgRemoveLastDeviceSet::match(cmd))
{
if (m_deviceSets.size() > 0) {
if (m_mainCore->m_deviceSets.size() > 0) {
removeLastDevice();
}
return true;
}
else if (MsgSetDevice::match(cmd))
else if (MainCore::MsgSetDevice::match(cmd))
{
MsgSetDevice& notif = (MsgSetDevice&) cmd;
MainCore::MsgSetDevice& notif = (MainCore::MsgSetDevice&) cmd;
if (notif.getDeviceType() == 1) {
changeSampleSink(notif.getDeviceSetIndex(), notif.getDeviceIndex());
@ -206,32 +188,32 @@ bool MainServer::handleMessage(const Message& cmd)
}
return true;
}
else if (MsgAddChannel::match(cmd))
else if (MainCore::MsgAddChannel::match(cmd))
{
MsgAddChannel& notif = (MsgAddChannel&) cmd;
MainCore::MsgAddChannel& notif = (MainCore::MsgAddChannel&) cmd;
addChannel(notif.getDeviceSetIndex(), notif.getChannelRegistrationIndex());
return true;
}
else if (MsgDeleteChannel::match(cmd))
else if (MainCore::MsgDeleteChannel::match(cmd))
{
MsgDeleteChannel& notif = (MsgDeleteChannel&) cmd;
MainCore::MsgDeleteChannel& notif = (MainCore::MsgDeleteChannel&) cmd;
deleteChannel(notif.getDeviceSetIndex(), notif.getChannelIndex());
return true;
}
else if (MsgAddFeature::match(cmd))
else if (MainCore::MsgAddFeature::match(cmd))
{
MsgAddFeature& notif = (MsgAddFeature&) cmd;
MainCore::MsgAddFeature& notif = (MainCore::MsgAddFeature&) cmd;
addFeature(notif.getFeatureSetIndex(), notif.getFeatureRegistrationIndex());
return true;
}
else if (MsgDeleteFeature::match(cmd))
else if (MainCore::MsgDeleteFeature::match(cmd))
{
MsgDeleteFeature& notif = (MsgDeleteFeature&) cmd;
MainCore::MsgDeleteFeature& notif = (MainCore::MsgDeleteFeature&) cmd;
deleteFeature(notif.getFeatureSetIndex(), notif.getFeatureIndex());
return true;
}
else if (MsgApplySettings::match(cmd))
else if (MainCore::MsgApplySettings::match(cmd))
{
applySettings();
return true;
@ -258,64 +240,15 @@ void MainServer::loadSettings()
{
qDebug() << "MainServer::loadSettings";
m_settings.load();
m_settings.sortPresets();
setLoggingOptions();
m_mainCore->m_settings.load();
m_mainCore->m_settings.sortPresets();
m_mainCore->setLoggingOptions();
}
void MainServer::applySettings()
{
m_settings.sortPresets();
setLoggingOptions();
}
void MainServer::setLoggingOptions()
{
m_logger->setConsoleMinMessageLevel(m_settings.getConsoleMinLogLevel());
if (m_settings.getUseLogFile())
{
qtwebapp::FileLoggerSettings fileLoggerSettings; // default values
if (m_logger->hasFileLogger()) {
fileLoggerSettings = m_logger->getFileLoggerSettings(); // values from file logger if it exists
}
fileLoggerSettings.fileName = m_settings.getLogFileName(); // put new values
m_logger->createOrSetFileLogger(fileLoggerSettings, 2000); // create file logger if it does not exist and apply settings in any case
}
if (m_logger->hasFileLogger()) {
m_logger->setFileMinMessageLevel(m_settings.getFileMinLogLevel());
}
m_logger->setUseFileLogger(m_settings.getUseLogFile());
if (m_settings.getUseLogFile())
{
#if QT_VERSION >= 0x050400
QString appInfoStr(tr("%1 %2 Qt %3 %4b %5 %6 DSP Rx:%7b Tx:%8b PID %9")
.arg(QCoreApplication::applicationName())
.arg(QCoreApplication::applicationVersion())
.arg(QT_VERSION_STR)
.arg(QT_POINTER_SIZE*8)
.arg(QSysInfo::currentCpuArchitecture())
.arg(QSysInfo::prettyProductName())
.arg(SDR_RX_SAMP_SZ)
.arg(SDR_TX_SAMP_SZ)
.arg(QCoreApplication::applicationPid()));
#else
QString appInfoStr(tr("%1 %2 Qt %3 %4b DSP Rx:%5b Tx:%6b PID %7")
.arg(QCoreApplication::applicationName())
.arg(QCoreApplication::applicationVersion())
.arg(QT_VERSION_STR)
.arg(QT_POINTER_SIZE*8)
.arg(SDR_RX_SAMP_SZ)
.arg(SDR_RX_SAMP_SZ)
.arg(QCoreApplication::applicationPid());
#endif
m_logger->logToFile(QtInfoMsg, appInfoStr);
}
m_mainCore->m_settings.sortPresets();
m_mainCore->setLoggingOptions();
}
void MainServer::addSinkDevice()
@ -327,41 +260,41 @@ void MainServer::addSinkDevice()
char uidCStr[16];
sprintf(uidCStr, "UID:%d", dspDeviceSinkEngineUID);
int deviceTabIndex = m_deviceSets.size();
m_deviceSets.push_back(new DeviceSet(deviceTabIndex));
m_deviceSets.back()->m_deviceSourceEngine = nullptr;
m_deviceSets.back()->m_deviceSinkEngine = dspDeviceSinkEngine;
m_deviceSets.back()->m_deviceMIMOEngine = nullptr;
int deviceTabIndex = m_mainCore->m_deviceSets.size();
m_mainCore->m_deviceSets.push_back(new DeviceSet(deviceTabIndex));
m_mainCore->m_deviceSets.back()->m_deviceSourceEngine = nullptr;
m_mainCore->m_deviceSets.back()->m_deviceSinkEngine = dspDeviceSinkEngine;
m_mainCore->m_deviceSets.back()->m_deviceMIMOEngine = nullptr;
char tabNameCStr[16];
sprintf(tabNameCStr, "T%d", deviceTabIndex);
DeviceAPI *deviceAPI = new DeviceAPI(DeviceAPI::StreamSingleTx, deviceTabIndex, nullptr, dspDeviceSinkEngine, nullptr);
m_deviceSets.back()->m_deviceAPI = deviceAPI;
m_mainCore->m_deviceSets.back()->m_deviceAPI = deviceAPI;
QList<QString> channelNames;
// create a file sink by default
int fileSinkDeviceIndex = DeviceEnumerator::instance()->getFileOutputDeviceIndex();
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(fileSinkDeviceIndex);
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
m_deviceSets.back()->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
m_deviceSets.back()->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
m_deviceSets.back()->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
m_deviceSets.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex));
m_mainCore->m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex));
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
QString userArgs = m_mainCore->m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
if (userArgs.size() > 0) {
m_deviceSets.back()->m_deviceAPI->setHardwareUserArguments(userArgs);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setHardwareUserArguments(userArgs);
}
DeviceSampleSink *sink = m_deviceSets.back()->m_deviceAPI->getPluginInterface()->createSampleSinkPluginInstance(
m_deviceSets.back()->m_deviceAPI->getSamplingDeviceId(), m_deviceSets.back()->m_deviceAPI);
m_deviceSets.back()->m_deviceAPI->setSampleSink(sink);
DeviceSampleSink *sink = m_mainCore->m_deviceSets.back()->m_deviceAPI->getPluginInterface()->createSampleSinkPluginInstance(
m_mainCore->m_deviceSets.back()->m_deviceAPI->getSamplingDeviceId(), m_mainCore->m_deviceSets.back()->m_deviceAPI);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setSampleSink(sink);
}
void MainServer::addSourceDevice()
@ -373,78 +306,78 @@ void MainServer::addSourceDevice()
char uidCStr[16];
sprintf(uidCStr, "UID:%d", dspDeviceSourceEngineUID);
int deviceTabIndex = m_deviceSets.size();
m_deviceSets.push_back(new DeviceSet(deviceTabIndex));
m_deviceSets.back()->m_deviceSourceEngine = dspDeviceSourceEngine;
m_deviceSets.back()->m_deviceSinkEngine = nullptr;
m_deviceSets.back()->m_deviceMIMOEngine = nullptr;
int deviceTabIndex = m_mainCore->m_deviceSets.size();
m_mainCore->m_deviceSets.push_back(new DeviceSet(deviceTabIndex));
m_mainCore->m_deviceSets.back()->m_deviceSourceEngine = dspDeviceSourceEngine;
m_mainCore->m_deviceSets.back()->m_deviceSinkEngine = nullptr;
m_mainCore->m_deviceSets.back()->m_deviceMIMOEngine = nullptr;
char tabNameCStr[16];
sprintf(tabNameCStr, "R%d", deviceTabIndex);
DeviceAPI *deviceAPI = new DeviceAPI(DeviceAPI::StreamSingleRx, deviceTabIndex, dspDeviceSourceEngine, nullptr, nullptr);
m_deviceSets.back()->m_deviceAPI = deviceAPI;
m_mainCore->m_deviceSets.back()->m_deviceAPI = deviceAPI;
// Create a file source instance by default
int fileSourceDeviceIndex = DeviceEnumerator::instance()->getFileInputDeviceIndex();
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(fileSourceDeviceIndex);
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
m_deviceSets.back()->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
m_deviceSets.back()->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
m_deviceSets.back()->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
m_deviceSets.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(fileSourceDeviceIndex));
m_mainCore->m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(fileSourceDeviceIndex));
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
QString userArgs = m_mainCore->m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
if (userArgs.size() > 0) {
m_deviceSets.back()->m_deviceAPI->setHardwareUserArguments(userArgs);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setHardwareUserArguments(userArgs);
}
DeviceSampleSource *source = m_deviceSets.back()->m_deviceAPI->getPluginInterface()->createSampleSourcePluginInstance(
m_deviceSets.back()->m_deviceAPI->getSamplingDeviceId(), m_deviceSets.back()->m_deviceAPI);
m_deviceSets.back()->m_deviceAPI->setSampleSource(source);
DeviceSampleSource *source = m_mainCore->m_deviceSets.back()->m_deviceAPI->getPluginInterface()->createSampleSourcePluginInstance(
m_mainCore->m_deviceSets.back()->m_deviceAPI->getSamplingDeviceId(), m_mainCore->m_deviceSets.back()->m_deviceAPI);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setSampleSource(source);
}
void MainServer::removeLastDevice()
{
if (m_deviceSets.back()->m_deviceSourceEngine) // source set
if (m_mainCore->m_deviceSets.back()->m_deviceSourceEngine) // source set
{
DSPDeviceSourceEngine *lastDeviceEngine = m_deviceSets.back()->m_deviceSourceEngine;
DSPDeviceSourceEngine *lastDeviceEngine = m_mainCore->m_deviceSets.back()->m_deviceSourceEngine;
lastDeviceEngine->stopAcquistion();
// deletes old UI and input object
m_deviceSets.back()->freeChannels(); // destroys the channel instances
m_deviceSets.back()->m_deviceAPI->resetSamplingDeviceId();
m_deviceSets.back()->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput(
m_deviceSets.back()->m_deviceAPI->getSampleSource());
m_deviceSets.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
m_mainCore->m_deviceSets.back()->freeChannels(); // destroys the channel instances
m_mainCore->m_deviceSets.back()->m_deviceAPI->resetSamplingDeviceId();
m_mainCore->m_deviceSets.back()->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput(
m_mainCore->m_deviceSets.back()->m_deviceAPI->getSampleSource());
m_mainCore->m_deviceSets.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
DeviceAPI *sourceAPI = m_deviceSets.back()->m_deviceAPI;
delete m_deviceSets.back();
DeviceAPI *sourceAPI = m_mainCore->m_deviceSets.back()->m_deviceAPI;
delete m_mainCore->m_deviceSets.back();
lastDeviceEngine->stop();
m_dspEngine->removeLastDeviceSourceEngine();
delete sourceAPI;
}
else if (m_deviceSets.back()->m_deviceSinkEngine) // sink set
else if (m_mainCore->m_deviceSets.back()->m_deviceSinkEngine) // sink set
{
DSPDeviceSinkEngine *lastDeviceEngine = m_deviceSets.back()->m_deviceSinkEngine;
DSPDeviceSinkEngine *lastDeviceEngine = m_mainCore->m_deviceSets.back()->m_deviceSinkEngine;
lastDeviceEngine->stopGeneration();
// deletes old UI and output object
m_deviceSets.back()->freeChannels();
m_deviceSets.back()->m_deviceAPI->resetSamplingDeviceId();
m_deviceSets.back()->m_deviceAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput(
m_deviceSets.back()->m_deviceAPI->getSampleSink());
m_deviceSets.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
m_mainCore->m_deviceSets.back()->freeChannels();
m_mainCore->m_deviceSets.back()->m_deviceAPI->resetSamplingDeviceId();
m_mainCore->m_deviceSets.back()->m_deviceAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput(
m_mainCore->m_deviceSets.back()->m_deviceAPI->getSampleSink());
m_mainCore->m_deviceSets.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
DeviceAPI *sinkAPI = m_deviceSets.back()->m_deviceAPI;
delete m_deviceSets.back();
DeviceAPI *sinkAPI = m_mainCore->m_deviceSets.back()->m_deviceAPI;
delete m_mainCore->m_deviceSets.back();
lastDeviceEngine->stop();
m_dspEngine->removeLastDeviceSinkEngine();
@ -452,7 +385,7 @@ void MainServer::removeLastDevice()
delete sinkAPI;
}
m_deviceSets.pop_back();
m_mainCore->m_deviceSets.pop_back();
}
void MainServer::changeSampleSource(int deviceSetIndex, int selectedDeviceIndex)
@ -460,8 +393,8 @@ void MainServer::changeSampleSource(int deviceSetIndex, int selectedDeviceIndex)
if (deviceSetIndex >= 0)
{
qDebug("MainServer::changeSampleSource: deviceSet at %d", deviceSetIndex);
DeviceSet *deviceSet = m_deviceSets[deviceSetIndex];
deviceSet->m_deviceAPI->saveSamplingDeviceSettings(m_settings.getWorkingPreset()); // save old API settings
DeviceSet *deviceSet = m_mainCore->m_deviceSets[deviceSetIndex];
deviceSet->m_deviceAPI->saveSamplingDeviceSettings(m_mainCore->m_settings.getWorkingPreset()); // save old API settings
deviceSet->m_deviceAPI->stopDeviceEngine();
// deletes old UI and input object
@ -496,10 +429,10 @@ void MainServer::changeSampleSource(int deviceSetIndex, int selectedDeviceIndex)
}
// add to buddies list
std::vector<DeviceSet*>::iterator it = m_deviceSets.begin();
std::vector<DeviceSet*>::iterator it = m_mainCore->m_deviceSets.begin();
int nbOfBuddies = 0;
for (; it != m_deviceSets.end(); ++it)
for (; it != m_mainCore->m_deviceSets.end(); ++it)
{
if (*it != deviceSet) // do not add to itself
{
@ -534,7 +467,7 @@ void MainServer::changeSampleSource(int deviceSetIndex, int selectedDeviceIndex)
deviceSet->m_deviceAPI->getSamplingDeviceId(), deviceSet->m_deviceAPI);
deviceSet->m_deviceAPI->setSampleSource(source);
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_settings.getWorkingPreset()); // load new API settings
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_mainCore->m_settings.getWorkingPreset()); // load new API settings
}
}
@ -543,8 +476,8 @@ void MainServer::changeSampleSink(int deviceSetIndex, int selectedDeviceIndex)
if (deviceSetIndex >= 0)
{
qDebug("MainServer::changeSampleSink: device set at %d", deviceSetIndex);
DeviceSet *deviceSet = m_deviceSets[deviceSetIndex];
deviceSet->m_deviceAPI->saveSamplingDeviceSettings(m_settings.getWorkingPreset()); // save old API settings
DeviceSet *deviceSet = m_mainCore->m_deviceSets[deviceSetIndex];
deviceSet->m_deviceAPI->saveSamplingDeviceSettings(m_mainCore->m_settings.getWorkingPreset()); // save old API settings
deviceSet->m_deviceAPI->stopDeviceEngine();
// deletes old UI and output object
@ -579,10 +512,10 @@ void MainServer::changeSampleSink(int deviceSetIndex, int selectedDeviceIndex)
}
// add to buddies list
std::vector<DeviceSet*>::iterator it = m_deviceSets.begin();
std::vector<DeviceSet*>::iterator it = m_mainCore->m_deviceSets.begin();
int nbOfBuddies = 0;
for (; it != m_deviceSets.end(); ++it)
for (; it != m_mainCore->m_deviceSets.end(); ++it)
{
if (*it != deviceSet) // do not add to itself
{
@ -617,7 +550,7 @@ void MainServer::changeSampleSink(int deviceSetIndex, int selectedDeviceIndex)
deviceSet->m_deviceAPI->getSamplingDeviceId(), deviceSet->m_deviceAPI);
deviceSet->m_deviceAPI->setSampleSink(sink);
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_settings.getWorkingPreset()); // load new API settings
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_mainCore->m_settings.getWorkingPreset()); // load new API settings
}
}
@ -626,8 +559,8 @@ void MainServer::changeSampleMIMO(int deviceSetIndex, int selectedDeviceIndex)
if (deviceSetIndex >= 0)
{
qDebug("MainServer::changeSampleMIMO: device set at %d", deviceSetIndex);
DeviceSet *deviceSet = m_deviceSets[deviceSetIndex];
deviceSet->m_deviceAPI->saveSamplingDeviceSettings(m_settings.getWorkingPreset()); // save old API settings
DeviceSet *deviceSet = m_mainCore->m_deviceSets[deviceSetIndex];
deviceSet->m_deviceAPI->saveSamplingDeviceSettings(m_mainCore->m_settings.getWorkingPreset()); // save old API settings
deviceSet->m_deviceAPI->stopDeviceEngine();
// deletes old UI and output object
@ -645,7 +578,7 @@ void MainServer::changeSampleMIMO(int deviceSetIndex, int selectedDeviceIndex)
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getMIMOPluginInterface(selectedDeviceIndex));
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
QString userArgs = m_mainCore->m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
if (userArgs.size() > 0) {
deviceSet->m_deviceAPI->setHardwareUserArguments(userArgs);
@ -656,7 +589,7 @@ void MainServer::changeSampleMIMO(int deviceSetIndex, int selectedDeviceIndex)
deviceSet->m_deviceAPI->getSamplingDeviceId(), deviceSet->m_deviceAPI);
deviceSet->m_deviceAPI->setSampleMIMO(mimo);
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_settings.getWorkingPreset()); // load new API settings
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_mainCore->m_settings.getWorkingPreset()); // load new API settings
}
}
@ -664,15 +597,15 @@ void MainServer::addChannel(int deviceSetIndex, int selectedChannelIndex)
{
if (deviceSetIndex >= 0)
{
DeviceSet *deviceSet = m_deviceSets[deviceSetIndex];
DeviceSet *deviceSet = m_mainCore->m_deviceSets[deviceSetIndex];
if (deviceSet->m_deviceSourceEngine) // source device => Rx channels
{
deviceSet->addRxChannel(selectedChannelIndex, m_pluginManager->getPluginAPI());
deviceSet->addRxChannel(selectedChannelIndex, m_mainCore->m_pluginManager->getPluginAPI());
}
else if (deviceSet->m_deviceSinkEngine) // sink device => Tx channels
{
deviceSet->addTxChannel(selectedChannelIndex, m_pluginManager->getPluginAPI());
deviceSet->addTxChannel(selectedChannelIndex, m_mainCore->m_pluginManager->getPluginAPI());
}
}
}
@ -681,7 +614,7 @@ void MainServer::deleteChannel(int deviceSetIndex, int channelIndex)
{
if (deviceSetIndex >= 0)
{
DeviceSet *deviceSet = m_deviceSets[deviceSetIndex];
DeviceSet *deviceSet = m_mainCore->m_deviceSets[deviceSetIndex];
deviceSet->deleteChannel(channelIndex);
}
}
@ -690,16 +623,16 @@ void MainServer::addFeature(int featureSetIndex, int featureIndex)
{
if (featureSetIndex >= 0)
{
FeatureSet *featureSet = m_featureSets[featureSetIndex];
featureSet->addFeature(featureSetIndex, m_pluginManager->getPluginAPI(), m_apiAdapter);
FeatureSet *featureSet = m_mainCore->m_featureSets[featureSetIndex];
featureSet->addFeature(featureSetIndex, m_mainCore->m_pluginManager->getPluginAPI(), m_apiAdapter);
}
}
void MainServer::deleteFeature(int featureSetIndex, int featureIndex)
{
if ((featureSetIndex >= 0) && (featureSetIndex < (int) m_featureSets.size()))
if ((featureSetIndex >= 0) && (featureSetIndex < (int) m_mainCore->m_featureSets.size()))
{
FeatureSet *featureSet = m_featureSets[featureSetIndex];
FeatureSet *featureSet = m_mainCore->m_featureSets[featureSetIndex];
featureSet->deleteFeature(featureIndex);
}
}
@ -712,15 +645,15 @@ void MainServer::loadPresetSettings(const Preset* preset, int tabIndex)
if (tabIndex >= 0)
{
DeviceSet *deviceSet = m_deviceSets[tabIndex];
DeviceSet *deviceSet = m_mainCore->m_deviceSets[tabIndex];
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(preset);
if (deviceSet->m_deviceSourceEngine) { // source device
deviceSet->loadRxChannelSettings(preset, m_pluginManager->getPluginAPI());
deviceSet->loadRxChannelSettings(preset, m_mainCore->m_pluginManager->getPluginAPI());
} else if (deviceSet->m_deviceSinkEngine) { // sink device
deviceSet->loadTxChannelSettings(preset, m_pluginManager->getPluginAPI());
deviceSet->loadTxChannelSettings(preset, m_mainCore->m_pluginManager->getPluginAPI());
} else if (deviceSet->m_deviceMIMOEngine) { // MIMO device
deviceSet->loadMIMOChannelSettings(preset, m_pluginManager->getPluginAPI());
deviceSet->loadMIMOChannelSettings(preset, m_mainCore->m_pluginManager->getPluginAPI());
}
}
}
@ -733,7 +666,7 @@ void MainServer::savePresetSettings(Preset* preset, int tabIndex)
// Save from currently selected source tab
//int currentSourceTabIndex = ui->tabInputsView->currentIndex();
DeviceSet *deviceSet = m_deviceSets[tabIndex];
DeviceSet *deviceSet = m_mainCore->m_deviceSets[tabIndex];
if (deviceSet->m_deviceSourceEngine) // source device
{
@ -766,8 +699,8 @@ void MainServer::loadFeatureSetPresetSettings(const FeatureSetPreset* preset, in
if (featureSetIndex >= 0)
{
FeatureSet *featureSet = m_featureSets[featureSetIndex];
featureSet->loadFeatureSetSettings(preset, m_pluginManager->getPluginAPI(), m_apiAdapter);
FeatureSet *featureSet = m_mainCore->m_featureSets[featureSetIndex];
featureSet->loadFeatureSetSettings(preset, m_mainCore->m_pluginManager->getPluginAPI(), m_apiAdapter);
}
}
@ -779,7 +712,7 @@ void MainServer::saveFeatureSetPresetSettings(FeatureSetPreset* preset, int feat
// Save from currently selected source tab
//int currentSourceTabIndex = ui->tabInputsView->currentIndex();
FeatureSet *featureSet = m_featureSets[featureSetIndex];
FeatureSet *featureSet = m_mainCore->m_featureSets[featureSetIndex];
preset->clearFeatures();
featureSet->saveFeatureSetSettings(preset);

View File

@ -23,8 +23,8 @@
#include <QObject>
#include <QTimer>
#include "maincore.h"
#include "settings/mainsettings.h"
#include "util/message.h"
#include "util/messagequeue.h"
#include "export.h"
#include "mainparser.h"
@ -34,7 +34,6 @@ class DSPDeviceSourceEngine;
class DSPDeviceSinkEngine;
class PluginAPI;
class PluginInterface;
class PluginManager;
class ChannelMarker;
class DeviceSet;
class FeatureSet;
@ -56,9 +55,7 @@ public:
MessageQueue* getInputMessageQueue() { return &m_inputMessageQueue; }
const QTimer& getMasterTimer() const { return m_masterTimer; }
const MainSettings& getMainSettings() const { return m_settings; }
const PluginManager *getPluginManager() const { return m_pluginManager; }
const QTimer& getMasterTimer() const { return m_mainCore->m_masterTimer; }
void addSourceDevice();
void addSinkDevice();
@ -80,341 +77,14 @@ signals:
void finished();
private:
class MsgLoadPreset : public Message {
MESSAGE_CLASS_DECLARATION
public:
const Preset *getPreset() const { return m_preset; }
int getDeviceSetIndex() const { return m_deviceSetIndex; }
static MsgLoadPreset* create(const Preset *preset, int deviceSetIndex)
{
return new MsgLoadPreset(preset, deviceSetIndex);
}
private:
const Preset *m_preset;
int m_deviceSetIndex;
MsgLoadPreset(const Preset *preset, int deviceSetIndex) :
Message(),
m_preset(preset),
m_deviceSetIndex(deviceSetIndex)
{ }
};
class MsgSavePreset : public Message {
MESSAGE_CLASS_DECLARATION
public:
Preset *getPreset() const { return m_preset; }
int getDeviceSetIndex() const { return m_deviceSetIndex; }
bool isNewPreset() const { return m_newPreset; }
static MsgSavePreset* create(Preset *preset, int deviceSetIndex, bool newPreset)
{
return new MsgSavePreset(preset, deviceSetIndex, newPreset);
}
private:
Preset *m_preset;
int m_deviceSetIndex;
bool m_newPreset;
MsgSavePreset(Preset *preset, int deviceSetIndex, bool newPreset) :
Message(),
m_preset(preset),
m_deviceSetIndex(deviceSetIndex),
m_newPreset(newPreset)
{ }
};
class MsgDeletePreset : public Message {
MESSAGE_CLASS_DECLARATION
public:
const Preset *getPreset() const { return m_preset; }
static MsgDeletePreset* create(const Preset *preset)
{
return new MsgDeletePreset(preset);
}
private:
const Preset *m_preset;
MsgDeletePreset(const Preset *preset) :
Message(),
m_preset(preset)
{ }
};
class MsgLoadFeatureSetPreset : public Message {
MESSAGE_CLASS_DECLARATION
public:
const FeatureSetPreset *getPreset() const { return m_preset; }
int getFeatureSetIndex() const { return m_featureSetIndex; }
static MsgLoadFeatureSetPreset* create(const FeatureSetPreset *preset, int featureSetIndex) {
return new MsgLoadFeatureSetPreset(preset, featureSetIndex);
}
private:
const FeatureSetPreset *m_preset;
int m_featureSetIndex;
MsgLoadFeatureSetPreset(const FeatureSetPreset *preset, int featureSetIndex) :
Message(),
m_preset(preset),
m_featureSetIndex(featureSetIndex)
{ }
};
class MsgSaveFeatureSetPreset : public Message {
MESSAGE_CLASS_DECLARATION
public:
FeatureSetPreset *getPreset() const { return m_preset; }
int getFeatureSetIndex() const { return m_featureSetIndex; }
bool isNewPreset() const { return m_newPreset; }
static MsgSaveFeatureSetPreset* create(FeatureSetPreset *preset, int featureSetIndex, bool newPreset)
{
return new MsgSaveFeatureSetPreset(preset, featureSetIndex, newPreset);
}
private:
FeatureSetPreset *m_preset;
int m_featureSetIndex;
bool m_newPreset;
MsgSaveFeatureSetPreset(FeatureSetPreset *preset, int featureSetIndex, bool newPreset) :
Message(),
m_preset(preset),
m_featureSetIndex(featureSetIndex),
m_newPreset(newPreset)
{ }
};
class MsgDeleteFeatureSetPreset : public Message {
MESSAGE_CLASS_DECLARATION
public:
const FeatureSetPreset *getPreset() const { return m_preset; }
static MsgDeleteFeatureSetPreset* create(const FeatureSetPreset *preset)
{
return new MsgDeleteFeatureSetPreset(preset);
}
private:
const FeatureSetPreset *m_preset;
MsgDeleteFeatureSetPreset(const FeatureSetPreset *preset) :
Message(),
m_preset(preset)
{ }
};
class MsgDeleteInstance : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgDeleteInstance* create()
{
return new MsgDeleteInstance();
}
private:
MsgDeleteInstance() :
Message()
{ }
};
class MsgAddDeviceSet : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getDirection() const { return m_direction; }
static MsgAddDeviceSet* create(int direction)
{
return new MsgAddDeviceSet(direction);
}
private:
int m_direction;
MsgAddDeviceSet(int direction) :
Message(),
m_direction(direction)
{ }
};
class MsgRemoveLastDeviceSet : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgRemoveLastDeviceSet* create()
{
return new MsgRemoveLastDeviceSet();
}
private:
MsgRemoveLastDeviceSet() :
Message()
{ }
};
class MsgSetDevice : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getDeviceSetIndex() const { return m_deviceSetIndex; }
int getDeviceIndex() const { return m_deviceIndex; }
int getDeviceType() const { return m_deviceType; }
static MsgSetDevice* create(int deviceSetIndex, int deviceIndex, int deviceType)
{
return new MsgSetDevice(deviceSetIndex, deviceIndex, deviceType);
}
private:
int m_deviceSetIndex;
int m_deviceIndex;
int m_deviceType;
MsgSetDevice(int deviceSetIndex, int deviceIndex, int deviceType) :
Message(),
m_deviceSetIndex(deviceSetIndex),
m_deviceIndex(deviceIndex),
m_deviceType(deviceType)
{ }
};
class MsgAddChannel : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getDeviceSetIndex() const { return m_deviceSetIndex; }
int getChannelRegistrationIndex() const { return m_channelRegistrationIndex; }
bool isTx() const { return m_tx; }
static MsgAddChannel* create(int deviceSetIndex, int channelRegistrationIndex, bool tx)
{
return new MsgAddChannel(deviceSetIndex, channelRegistrationIndex, tx);
}
private:
int m_deviceSetIndex;
int m_channelRegistrationIndex;
bool m_tx;
MsgAddChannel(int deviceSetIndex, int channelRegistrationIndex, bool tx) :
Message(),
m_deviceSetIndex(deviceSetIndex),
m_channelRegistrationIndex(channelRegistrationIndex),
m_tx(tx)
{ }
};
class MsgDeleteChannel : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getDeviceSetIndex() const { return m_deviceSetIndex; }
int getChannelIndex() const { return m_channelIndex; }
static MsgDeleteChannel* create(int deviceSetIndex, int channelIndex)
{
return new MsgDeleteChannel(deviceSetIndex, channelIndex);
}
private:
int m_deviceSetIndex;
int m_channelIndex;
MsgDeleteChannel(int deviceSetIndex, int channelIndex) :
Message(),
m_deviceSetIndex(deviceSetIndex),
m_channelIndex(channelIndex)
{ }
};
class MsgApplySettings : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgApplySettings* create() {
return new MsgApplySettings();
}
private:
MsgApplySettings() :
Message()
{ }
};
class MsgAddFeature : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getFeatureSetIndex() const { return m_featureSetIndex; }
int getFeatureRegistrationIndex() const { return m_featureRegistrationIndex; }
static MsgAddFeature* create(int featureSetIndex, int featureRegistrationIndex)
{
return new MsgAddFeature(featureSetIndex, featureRegistrationIndex);
}
private:
int m_featureSetIndex;
int m_featureRegistrationIndex;
MsgAddFeature(int featureSetIndex, int featureRegistrationIndex) :
Message(),
m_featureSetIndex(featureSetIndex),
m_featureRegistrationIndex(featureRegistrationIndex)
{ }
};
class MsgDeleteFeature : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getFeatureSetIndex() const { return m_featureSetIndex; }
int getFeatureIndex() const { return m_featureIndex; }
static MsgDeleteFeature* create(int m_featureSetIndex, int m_featureIndex) {
return new MsgDeleteFeature(m_featureSetIndex, m_featureIndex);
}
private:
int m_featureSetIndex;
int m_featureIndex;
MsgDeleteFeature(int m_featureSetIndex, int m_featureIndex) :
Message(),
m_featureSetIndex(m_featureSetIndex),
m_featureIndex(m_featureIndex)
{ }
};
static MainServer *m_instance;
MainSettings m_settings;
int m_masterTabIndex;
MainCore *m_mainCore;
DSPEngine* m_dspEngine;
int m_lastEngineState;
qtwebapp::LoggerWithFile *m_logger;
QString m_apiHost;
int m_apiPort;
MessageQueue m_inputMessageQueue;
QTimer m_masterTimer;
std::vector<DeviceSet*> m_deviceSets;
std::vector<FeatureSet*> m_featureSets;
PluginManager* m_pluginManager;
WebAPIRequestMapper *m_requestMapper;
WebAPIServer *m_apiServer;
@ -426,7 +96,6 @@ private:
void savePresetSettings(Preset* preset, int tabIndex);
void loadFeatureSetPresetSettings(const FeatureSetPreset* preset, int featureSetIndex);
void saveFeatureSetPresetSettings(FeatureSetPreset* preset, int featureSetIndex);
void setLoggingOptions();
bool handleMessage(const Message& cmd);

View File

@ -78,7 +78,7 @@
#include "limerfe/limerfecontroller.h"
#endif
WebAPIAdapterSrv::WebAPIAdapterSrv(MainServer& mainCore) :
WebAPIAdapterSrv::WebAPIAdapterSrv(MainCore& mainCore) :
m_mainCore(mainCore)
{
}
@ -124,8 +124,8 @@ int WebAPIAdapterSrv::instanceDelete(
SWGSDRangel::SWGSuccessResponse& response,
SWGSDRangel::SWGErrorResponse& error)
{
MainServer::MsgDeleteInstance *msg = MainServer::MsgDeleteInstance::create();
m_mainCore.getInputMessageQueue()->push(msg);
MainCore::MsgDeleteInstance *msg = MainCore::MsgDeleteInstance::create();
m_mainCore.m_mainMessageQueue->push(msg);
response.init();
*response.getMessage() = QString("Message to stop the SDRangel instance (MsgDeleteInstance) was submitted successfully");
@ -141,11 +141,11 @@ int WebAPIAdapterSrv::instanceConfigGet(
WebAPIAdapterBase webAPIAdapterBase;
webAPIAdapterBase.setPluginManager(m_mainCore.getPluginManager());
SWGSDRangel::SWGPreferences *preferences = response.getPreferences();
WebAPIAdapterBase::webapiFormatPreferences(preferences, m_mainCore.getMainSettings().getPreferences());
WebAPIAdapterBase::webapiFormatPreferences(preferences, m_mainCore.getSettings().getPreferences());
SWGSDRangel::SWGPreset *workingPreset = response.getWorkingPreset();
webAPIAdapterBase.webapiFormatPreset(workingPreset, m_mainCore.getMainSettings().getWorkingPresetConst());
webAPIAdapterBase.webapiFormatPreset(workingPreset, m_mainCore.getSettings().getWorkingPresetConst());
SWGSDRangel::SWGFeatureSetPreset *workingFeatureSetPreset = response.getWorkingFeatureSetPreset();
webAPIAdapterBase.webapiFormatFeatureSetPreset(workingFeatureSetPreset, m_mainCore.getMainSettings().getWorkingFeatureSetPresetConst());
webAPIAdapterBase.webapiFormatFeatureSetPreset(workingFeatureSetPreset, m_mainCore.getSettings().getWorkingFeatureSetPresetConst());
int nbPresets = m_mainCore.m_settings.getPresetCount();
QList<SWGSDRangel::SWGPreset*> *swgPresets = response.getPresets();
@ -234,8 +234,8 @@ int WebAPIAdapterSrv::instanceConfigPutPatch(
m_mainCore.m_settings.addFeatureSetPreset(newPreset);
}
MainServer::MsgApplySettings *msg = MainServer::MsgApplySettings::create();
m_mainCore.m_inputMessageQueue.push(msg);
MainCore::MsgApplySettings *msg = MainCore::MsgApplySettings::create();
m_mainCore.m_mainMessageQueue->push(msg);
return 200;
}
@ -401,8 +401,9 @@ int WebAPIAdapterSrv::instanceAudioGet(
SWGSDRangel::SWGAudioDevices& response,
SWGSDRangel::SWGErrorResponse& error)
{
const QList<QAudioDeviceInfo>& audioInputDevices = m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDevices();
const QList<QAudioDeviceInfo>& audioOutputDevices = m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDevices();
DSPEngine *dspEngine = DSPEngine::instance();
const QList<QAudioDeviceInfo>& audioInputDevices = dspEngine->getAudioDeviceManager()->getInputDevices();
const QList<QAudioDeviceInfo>& audioOutputDevices = dspEngine->getAudioDeviceManager()->getOutputDevices();
int nbInputDevices = audioInputDevices.size();
int nbOutputDevices = audioOutputDevices.size();
@ -417,7 +418,7 @@ int WebAPIAdapterSrv::instanceAudioGet(
// system default input device
inputDevices->append(new SWGSDRangel::SWGAudioInputDevice);
inputDevices->back()->init();
bool found = m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(AudioDeviceManager::m_defaultDeviceName, inputDeviceInfo);
bool found = dspEngine->getAudioDeviceManager()->getInputDeviceInfo(AudioDeviceManager::m_defaultDeviceName, inputDeviceInfo);
*inputDevices->back()->getName() = AudioDeviceManager::m_defaultDeviceName;
inputDevices->back()->setIndex(-1);
inputDevices->back()->setSampleRate(inputDeviceInfo.sampleRate);
@ -431,7 +432,7 @@ int WebAPIAdapterSrv::instanceAudioGet(
inputDevices->append(new SWGSDRangel::SWGAudioInputDevice);
inputDevices->back()->init();
inputDeviceInfo.resetToDefaults();
found = m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(audioInputDevices.at(i).deviceName(), inputDeviceInfo);
found = dspEngine->getAudioDeviceManager()->getInputDeviceInfo(audioInputDevices.at(i).deviceName(), inputDeviceInfo);
*inputDevices->back()->getName() = audioInputDevices.at(i).deviceName();
inputDevices->back()->setIndex(i);
inputDevices->back()->setSampleRate(inputDeviceInfo.sampleRate);
@ -443,7 +444,7 @@ int WebAPIAdapterSrv::instanceAudioGet(
// system default output device
outputDevices->append(new SWGSDRangel::SWGAudioOutputDevice);
outputDevices->back()->init();
found = m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(AudioDeviceManager::m_defaultDeviceName, outputDeviceInfo);
found = dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(AudioDeviceManager::m_defaultDeviceName, outputDeviceInfo);
*outputDevices->back()->getName() = AudioDeviceManager::m_defaultDeviceName;
outputDevices->back()->setIndex(-1);
outputDevices->back()->setSampleRate(outputDeviceInfo.sampleRate);
@ -463,7 +464,7 @@ int WebAPIAdapterSrv::instanceAudioGet(
outputDevices->append(new SWGSDRangel::SWGAudioOutputDevice);
outputDevices->back()->init();
outputDeviceInfo.resetToDefaults();
found = m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(audioOutputDevices.at(i).deviceName(), outputDeviceInfo);
found = dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(audioOutputDevices.at(i).deviceName(), outputDeviceInfo);
*outputDevices->back()->getName() = audioOutputDevices.at(i).deviceName();
outputDevices->back()->setIndex(i);
outputDevices->back()->setSampleRate(outputDeviceInfo.sampleRate);
@ -486,19 +487,19 @@ int WebAPIAdapterSrv::instanceAudioInputPatch(
const QStringList& audioInputKeys,
SWGSDRangel::SWGErrorResponse& error)
{
// TODO
DSPEngine *dspEngine = DSPEngine::instance();
AudioDeviceManager::InputDeviceInfo inputDeviceInfo;
QString deviceName;
int deviceIndex = response.getIndex();
if (!m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceName(deviceIndex, deviceName))
if (!dspEngine->getAudioDeviceManager()->getInputDeviceName(deviceIndex, deviceName))
{
error.init();
*error.getMessage() = QString("There is no input audio device at index %1").arg(deviceIndex);
return 404;
}
m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(deviceName, inputDeviceInfo);
dspEngine->getAudioDeviceManager()->getInputDeviceInfo(deviceName, inputDeviceInfo);
if (audioInputKeys.contains("sampleRate")) {
inputDeviceInfo.sampleRate = response.getSampleRate();
@ -507,8 +508,8 @@ int WebAPIAdapterSrv::instanceAudioInputPatch(
inputDeviceInfo.volume = response.getVolume();
}
m_mainCore.m_dspEngine->getAudioDeviceManager()->setInputDeviceInfo(deviceIndex, inputDeviceInfo);
m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(deviceName, inputDeviceInfo);
dspEngine->getAudioDeviceManager()->setInputDeviceInfo(deviceIndex, inputDeviceInfo);
dspEngine->getAudioDeviceManager()->getInputDeviceInfo(deviceName, inputDeviceInfo);
response.setSampleRate(inputDeviceInfo.sampleRate);
response.setVolume(inputDeviceInfo.volume);
@ -521,18 +522,19 @@ int WebAPIAdapterSrv::instanceAudioOutputPatch(
const QStringList& audioOutputKeys,
SWGSDRangel::SWGErrorResponse& error)
{
DSPEngine *dspEngine = DSPEngine::instance();
AudioDeviceManager::OutputDeviceInfo outputDeviceInfo;
QString deviceName;
int deviceIndex = response.getIndex();
if (!m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceName(deviceIndex, deviceName))
if (!dspEngine->getAudioDeviceManager()->getOutputDeviceName(deviceIndex, deviceName))
{
error.init();
*error.getMessage() = QString("There is no output audio device at index %1").arg(deviceIndex);
return 404;
}
m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(deviceName, outputDeviceInfo);
dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(deviceName, outputDeviceInfo);
if (audioOutputKeys.contains("sampleRate")) {
outputDeviceInfo.sampleRate = response.getSampleRate();
@ -559,8 +561,8 @@ int WebAPIAdapterSrv::instanceAudioOutputPatch(
outputDeviceInfo.udpPort = response.getUdpPort() % (1<<16);
}
m_mainCore.m_dspEngine->getAudioDeviceManager()->setOutputDeviceInfo(deviceIndex, outputDeviceInfo);
m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(deviceName, outputDeviceInfo);
dspEngine->getAudioDeviceManager()->setOutputDeviceInfo(deviceIndex, outputDeviceInfo);
dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(deviceName, outputDeviceInfo);
response.setSampleRate(outputDeviceInfo.sampleRate);
response.setCopyToUdp(outputDeviceInfo.copyToUDP == 0 ? 0 : 1);
@ -584,19 +586,20 @@ int WebAPIAdapterSrv::instanceAudioInputDelete(
SWGSDRangel::SWGAudioInputDevice& response,
SWGSDRangel::SWGErrorResponse& error)
{
DSPEngine *dspEngine = DSPEngine::instance();
AudioDeviceManager::InputDeviceInfo inputDeviceInfo;
QString deviceName;
int deviceIndex = response.getIndex();
if (!m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceName(deviceIndex, deviceName))
if (!dspEngine->getAudioDeviceManager()->getInputDeviceName(deviceIndex, deviceName))
{
error.init();
*error.getMessage() = QString("There is no audio input device at index %1").arg(deviceIndex);
return 404;
}
m_mainCore.m_dspEngine->getAudioDeviceManager()->unsetInputDeviceInfo(deviceIndex);
m_mainCore.m_dspEngine->getAudioDeviceManager()->getInputDeviceInfo(deviceName, inputDeviceInfo);
dspEngine->getAudioDeviceManager()->unsetInputDeviceInfo(deviceIndex);
dspEngine->getAudioDeviceManager()->getInputDeviceInfo(deviceName, inputDeviceInfo);
response.setSampleRate(inputDeviceInfo.sampleRate);
response.setVolume(inputDeviceInfo.volume);
@ -608,19 +611,20 @@ int WebAPIAdapterSrv::instanceAudioOutputDelete(
SWGSDRangel::SWGAudioOutputDevice& response,
SWGSDRangel::SWGErrorResponse& error)
{
DSPEngine *dspEngine = DSPEngine::instance();
AudioDeviceManager::OutputDeviceInfo outputDeviceInfo;
QString deviceName;
int deviceIndex = response.getIndex();
if (!m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceName(deviceIndex, deviceName))
if (!dspEngine->getAudioDeviceManager()->getOutputDeviceName(deviceIndex, deviceName))
{
error.init();
*error.getMessage() = QString("There is no audio output device at index %1").arg(deviceIndex);
return 404;
}
m_mainCore.m_dspEngine->getAudioDeviceManager()->unsetInputDeviceInfo(deviceIndex);
m_mainCore.m_dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(deviceName, outputDeviceInfo);
dspEngine->getAudioDeviceManager()->unsetInputDeviceInfo(deviceIndex);
dspEngine->getAudioDeviceManager()->getOutputDeviceInfo(deviceName, outputDeviceInfo);
response.setSampleRate(outputDeviceInfo.sampleRate);
response.setCopyToUdp(outputDeviceInfo.copyToUDP == 0 ? 0 : 1);
@ -644,7 +648,8 @@ int WebAPIAdapterSrv::instanceAudioInputCleanupPatch(
SWGSDRangel::SWGSuccessResponse& response,
SWGSDRangel::SWGErrorResponse& error)
{
m_mainCore.m_dspEngine->getAudioDeviceManager()->inputInfosCleanup();
DSPEngine *dspEngine = DSPEngine::instance();
dspEngine->getAudioDeviceManager()->inputInfosCleanup();
response.init();
*response.getMessage() = QString("Unregistered parameters for devices not in list of available input devices for this instance");
@ -656,7 +661,8 @@ int WebAPIAdapterSrv::instanceAudioOutputCleanupPatch(
SWGSDRangel::SWGSuccessResponse& response,
SWGSDRangel::SWGErrorResponse& error)
{
m_mainCore.m_dspEngine->getAudioDeviceManager()->outputInfosCleanup();
DSPEngine *dspEngine = DSPEngine::instance();
dspEngine->getAudioDeviceManager()->outputInfosCleanup();
response.init();
*response.getMessage() = QString("Unregistered parameters for devices not in list of available output devices for this instance");
@ -698,10 +704,11 @@ int WebAPIAdapterSrv::instanceDVSerialGet(
SWGSDRangel::SWGDVSerialDevices& response,
SWGSDRangel::SWGErrorResponse& error)
{
DSPEngine *dspEngine = DSPEngine::instance();
response.init();
std::vector<std::string> deviceNames;
m_mainCore.m_dspEngine->getDVSerialNames(deviceNames);
dspEngine->getDVSerialNames(deviceNames);
response.setNbDevices((int) deviceNames.size());
QList<SWGSDRangel::SWGDVSerialDevice*> *deviceNamesList = response.getDvSerialDevices();
@ -723,13 +730,14 @@ int WebAPIAdapterSrv::instanceDVSerialPatch(
SWGSDRangel::SWGDVSerialDevices& response,
SWGSDRangel::SWGErrorResponse& error)
{
m_mainCore.m_dspEngine->setDVSerialSupport(dvserial);
DSPEngine *dspEngine = DSPEngine::instance();
dspEngine->setDVSerialSupport(dvserial);
response.init();
if (dvserial)
{
std::vector<std::string> deviceNames;
m_mainCore.m_dspEngine->getDVSerialNames(deviceNames);
dspEngine->getDVSerialNames(deviceNames);
response.setNbDevices((int) deviceNames.size());
QList<SWGSDRangel::SWGDVSerialDevice*> *deviceNamesList = response.getDvSerialDevices();
@ -757,11 +765,12 @@ int WebAPIAdapterSrv::instanceAMBESerialGet(
SWGSDRangel::SWGErrorResponse& error)
{
(void) error;
DSPEngine *dspEngine = DSPEngine::instance();
response.init();
std::vector<std::string> deviceNames;
std::vector<QString> qDeviceNames;
m_mainCore.m_dspEngine->getAMBEEngine()->scan(qDeviceNames);
dspEngine->getAMBEEngine()->scan(qDeviceNames);
for (std::vector<QString>::const_iterator it = qDeviceNames.begin(); it != qDeviceNames.end(); ++it) {
deviceNames.push_back(it->toStdString());
@ -788,10 +797,11 @@ int WebAPIAdapterSrv::instanceAMBEDevicesGet(
SWGSDRangel::SWGErrorResponse& error)
{
(void) error;
DSPEngine *dspEngine = DSPEngine::instance();
response.init();
std::vector<std::string> deviceNames;
m_mainCore.m_dspEngine->getDVSerialNames(deviceNames);
dspEngine->getDVSerialNames(deviceNames);
response.setNbDevices((int) deviceNames.size());
QList<SWGSDRangel::SWGAMBEDevice*> *deviceNamesList = response.getAmbeDevices();
@ -814,7 +824,8 @@ int WebAPIAdapterSrv::instanceAMBEDevicesDelete(
SWGSDRangel::SWGErrorResponse& error)
{
(void) error;
m_mainCore.m_dspEngine->getAMBEEngine()->releaseAll();
DSPEngine *dspEngine = DSPEngine::instance();
dspEngine->getAMBEEngine()->releaseAll();
response.init();
*response.getMessage() = QString("All AMBE devices released");
@ -827,12 +838,13 @@ int WebAPIAdapterSrv::instanceAMBEDevicesPut(
SWGSDRangel::SWGAMBEDevices& response,
SWGSDRangel::SWGErrorResponse& error)
{
m_mainCore.m_dspEngine->getAMBEEngine()->releaseAll();
DSPEngine *dspEngine = DSPEngine::instance();
dspEngine->getAMBEEngine()->releaseAll();
QList<SWGSDRangel::SWGAMBEDevice *> *ambeList = query.getAmbeDevices();
for (QList<SWGSDRangel::SWGAMBEDevice *>::const_iterator it = ambeList->begin(); it != ambeList->end(); ++it) {
m_mainCore.m_dspEngine->getAMBEEngine()->registerController((*it)->getDeviceRef()->toStdString());
dspEngine->getAMBEEngine()->registerController((*it)->getDeviceRef()->toStdString());
}
instanceAMBEDevicesGet(response, error);
@ -844,14 +856,15 @@ int WebAPIAdapterSrv::instanceAMBEDevicesPatch(
SWGSDRangel::SWGAMBEDevices& response,
SWGSDRangel::SWGErrorResponse& error)
{
DSPEngine *dspEngine = DSPEngine::instance();
QList<SWGSDRangel::SWGAMBEDevice *> *ambeList = query.getAmbeDevices();
for (QList<SWGSDRangel::SWGAMBEDevice *>::const_iterator it = ambeList->begin(); it != ambeList->end(); ++it)
{
if ((*it)->getDelete()) {
m_mainCore.m_dspEngine->getAMBEEngine()->releaseController((*it)->getDeviceRef()->toStdString());
dspEngine->getAMBEEngine()->releaseController((*it)->getDeviceRef()->toStdString());
} else {
m_mainCore.m_dspEngine->getAMBEEngine()->registerController((*it)->getDeviceRef()->toStdString());
dspEngine->getAMBEEngine()->registerController((*it)->getDeviceRef()->toStdString());
}
}
@ -1284,8 +1297,8 @@ int WebAPIAdapterSrv::instancePresetPatch(
return 404;
}
MainServer::MsgLoadPreset *msg = MainServer::MsgLoadPreset::create(selectedPreset, deviceSetIndex);
m_mainCore.m_inputMessageQueue.push(msg);
MainCore::MsgLoadPreset *msg = MainCore::MsgLoadPreset::create(selectedPreset, deviceSetIndex);
m_mainCore.m_mainMessageQueue->push(msg);
response.init();
response.setCenterFrequency(selectedPreset->getCenterFrequency());
@ -1353,8 +1366,8 @@ int WebAPIAdapterSrv::instancePresetPut(
}
}
MainServer::MsgSavePreset *msg = MainServer::MsgSavePreset::create(const_cast<Preset*>(selectedPreset), deviceSetIndex, false);
m_mainCore.m_inputMessageQueue.push(msg);
MainCore::MsgSavePreset *msg = MainCore::MsgSavePreset::create(const_cast<Preset*>(selectedPreset), deviceSetIndex, false);
m_mainCore.m_mainMessageQueue->push(msg);
response.init();
response.setCenterFrequency(selectedPreset->getCenterFrequency());
@ -1420,8 +1433,8 @@ int WebAPIAdapterSrv::instancePresetPost(
return 409;
}
MainServer::MsgSavePreset *msg = MainServer::MsgSavePreset::create(const_cast<Preset*>(selectedPreset), deviceSetIndex, true);
m_mainCore.m_inputMessageQueue.push(msg);
MainCore::MsgSavePreset *msg = MainCore::MsgSavePreset::create(const_cast<Preset*>(selectedPreset), deviceSetIndex, true);
m_mainCore.m_mainMessageQueue->push(msg);
response.init();
response.setCenterFrequency(deviceCenterFrequency);
@ -1457,8 +1470,8 @@ int WebAPIAdapterSrv::instancePresetDelete(
*response.getType() = selectedPreset->isSourcePreset() ? "R" : selectedPreset->isSinkPreset() ? "T" : selectedPreset->isMIMOPreset() ? "M" : "X";
*response.getName() = selectedPreset->getDescription();
MainServer::MsgDeletePreset *msg = MainServer::MsgDeletePreset::create(const_cast<Preset*>(selectedPreset));
m_mainCore.m_inputMessageQueue.push(msg);
MainCore::MsgDeletePreset *msg = MainCore::MsgDeletePreset::create(const_cast<Preset*>(selectedPreset));
m_mainCore.m_mainMessageQueue->push(msg);
return 202;
}
@ -1485,8 +1498,8 @@ int WebAPIAdapterSrv::instanceDeviceSetPost(
SWGSDRangel::SWGSuccessResponse& response,
SWGSDRangel::SWGErrorResponse& error)
{
MainServer::MsgAddDeviceSet *msg = MainServer::MsgAddDeviceSet::create(direction);
m_mainCore.m_inputMessageQueue.push(msg);
MainCore::MsgAddDeviceSet *msg = MainCore::MsgAddDeviceSet::create(direction);
m_mainCore.m_mainMessageQueue->push(msg);
response.init();
*response.getMessage() = QString("Message to add a new device set (MsgAddDeviceSet) was submitted successfully");
@ -1500,8 +1513,8 @@ int WebAPIAdapterSrv::instanceDeviceSetDelete(
{
if (m_mainCore.m_deviceSets.size() > 0)
{
MainServer::MsgRemoveLastDeviceSet *msg = MainServer::MsgRemoveLastDeviceSet::create();
m_mainCore.m_inputMessageQueue.push(msg);
MainCore::MsgRemoveLastDeviceSet *msg = MainCore::MsgRemoveLastDeviceSet::create();
m_mainCore.m_mainMessageQueue->push(msg);
response.init();
*response.getMessage() = QString("Message to remove last device set (MsgRemoveLastDeviceSet) was submitted successfully");
@ -1635,8 +1648,8 @@ int WebAPIAdapterSrv::devicesetDevicePut(
continue;
}
MainServer::MsgSetDevice *msg = MainServer::MsgSetDevice::create(deviceSetIndex, i, query.getDirection());
m_mainCore.m_inputMessageQueue.push(msg);
MainCore::MsgSetDevice *msg = MainCore::MsgSetDevice::create(deviceSetIndex, i, query.getDirection());
m_mainCore.m_mainMessageQueue->push(msg);
response.init();
*response.getDisplayedName() = samplingDevice->displayedName;
@ -2192,8 +2205,8 @@ int WebAPIAdapterSrv::devicesetChannelPost(
if (index < nbRegistrations)
{
MainServer::MsgAddChannel *msg = MainServer::MsgAddChannel::create(deviceSetIndex, index, false);
m_mainCore.m_inputMessageQueue.push(msg);
MainCore::MsgAddChannel *msg = MainCore::MsgAddChannel::create(deviceSetIndex, index, false);
m_mainCore.m_mainMessageQueue->push(msg);
response.init();
*response.getMessage() = QString("Message to add a channel (MsgAddChannel) was submitted successfully");
@ -2228,8 +2241,8 @@ int WebAPIAdapterSrv::devicesetChannelPost(
if (index < nbRegistrations)
{
MainServer::MsgAddChannel *msg = MainServer::MsgAddChannel::create(deviceSetIndex, index, true);
m_mainCore.m_inputMessageQueue.push(msg);
MainCore::MsgAddChannel *msg = MainCore::MsgAddChannel::create(deviceSetIndex, index, true);
m_mainCore.m_mainMessageQueue->push(msg);
response.init();
*response.getMessage() = QString("Message to add a channel (MsgAddChannel) was submitted successfully");
@ -2264,8 +2277,8 @@ int WebAPIAdapterSrv::devicesetChannelPost(
if (index < nbRegistrations)
{
MainServer::MsgAddChannel *msg = MainServer::MsgAddChannel::create(deviceSetIndex, index, true);
m_mainCore.m_inputMessageQueue.push(msg);
MainCore::MsgAddChannel *msg = MainCore::MsgAddChannel::create(deviceSetIndex, index, true);
m_mainCore.m_mainMessageQueue->push(msg);
response.init();
*response.getMessage() = QString("Message to add a channel (MsgAddChannel) was submitted successfully");
@ -2306,8 +2319,8 @@ int WebAPIAdapterSrv::devicesetChannelDelete(
if (channelIndex < deviceSet->getNumberOfChannels())
{
MainServer::MsgDeleteChannel *msg = MainServer::MsgDeleteChannel::create(deviceSetIndex, channelIndex);
m_mainCore.m_inputMessageQueue.push(msg);
MainCore::MsgDeleteChannel *msg = MainCore::MsgDeleteChannel::create(deviceSetIndex, channelIndex);
m_mainCore.m_mainMessageQueue->push(msg);
response.init();
*response.getMessage() = QString("Message to delete a channel (MsgDeleteChannel) was submitted successfully");
@ -2842,8 +2855,8 @@ int WebAPIAdapterSrv::featuresetFeaturePost(
if (index < nbRegistrations)
{
MainServer::MsgAddFeature *msg = MainServer::MsgAddFeature::create(featureSetIndex, index);
m_mainCore.m_inputMessageQueue.push(msg);
MainCore::MsgAddFeature *msg = MainCore::MsgAddFeature::create(featureSetIndex, index);
m_mainCore.m_mainMessageQueue->push(msg);
response.init();
*response.getMessage() = QString("Message to add a feature (MsgAddFeature) was submitted successfully");
@ -2877,8 +2890,8 @@ int WebAPIAdapterSrv::featuresetFeatureDelete(
if (featureIndex < featureSet->getNumberOfFeatures())
{
MainServer::MsgDeleteFeature *msg = MainServer::MsgDeleteFeature::create(featureSetIndex, featureIndex);
m_mainCore.m_inputMessageQueue.push(msg);
MainCore::MsgDeleteFeature *msg = MainCore::MsgDeleteFeature::create(featureSetIndex, featureIndex);
m_mainCore.m_mainMessageQueue->push(msg);
response.init();
*response.getMessage() = QString("Message to delete a feature (MsgDeleteFeature) was submitted successfully");

View File

@ -24,14 +24,14 @@
#include "webapi/webapiadapterinterface.h"
class MainServer;
class MainCore;
class DeviceSet;
class FeatureSet;
class WebAPIAdapterSrv: public WebAPIAdapterInterface
{
public:
WebAPIAdapterSrv(MainServer& mainCore);
WebAPIAdapterSrv(MainCore& mainCore);
virtual ~WebAPIAdapterSrv();
virtual int instanceSummary(
@ -399,7 +399,7 @@ public:
SWGSDRangel::SWGErrorResponse& error);
private:
MainServer& m_mainCore;
MainCore& m_mainCore;
void getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList);
void getDeviceSet(SWGSDRangel::SWGDeviceSet *swgDeviceSet, const DeviceSet* deviceSet, int deviceUISetIndex);